etherlab/EtherCATManagementEditor.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 28 Sep 2018 19:25:18 +0300
changeset 2369 24db1e592e20
parent 2368 642ae95218b6
child 2373 73d35ba8f982
permissions -rw-r--r--
cleanup etherlab: pep8, E201 whitespace after '('
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
     1
#!/usr/bin/env python
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
     2
# -*- coding: utf-8 -*-
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
     3
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
     4
# This file is part of Beremiz
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
     5
#
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
     6
# Copyright (C) 2013: Real-Time & Embedded Systems (RTES) Lab., University of Seoul
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
     7
#
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
     8
# See COPYING file for copyrights details.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
     9
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    10
import os
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    11
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    12
import wx
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    13
import wx.grid
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    14
import wx.gizmos
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    15
import wx.lib.buttons
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    16
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    17
# --------------------------------------------------------------------
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    18
from controls import CustomGrid, CustomTable
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    19
# --------------------------------------------------------------------
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    20
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    21
# ------------ for SDO Management --------------------
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    22
import string
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    23
import wx.grid as gridlib
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
    24
# -------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    25
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
    26
# ------------ for register management ---------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    27
from xml.dom import minidom
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
    28
# -------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    29
2360
2a3d022a7dac cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2358
diff changeset
    30
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    31
# ----------------------------- For Sync Manager Table -----------------------------------
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    32
def GetSyncManagersTableColnames():
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    33
    """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    34
    Returns column names of SyncManager Table in Slave state panel.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    35
    """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    36
    _ = lambda x : x
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    37
    return ["#", _("Name"), _("Start Address"), _("Default Size"), _("Control Byte"), _("Enable")]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    38
2360
2a3d022a7dac cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2358
diff changeset
    39
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
    40
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    41
#                    Sync Managers Table
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
    42
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    43
class SyncManagersTable(CustomTable):
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
    44
    def GetValue(self, row, col):
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    45
        if row < self.GetNumberRows():
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    46
            if col == 0:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    47
                return row
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    48
            return self.data[row].get(self.GetColLabelValue(col, False), "")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    49
2360
2a3d022a7dac cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2358
diff changeset
    50
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
    51
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    52
#                    EtherCAT Management Treebook
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
    53
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    54
class EtherCATManagementTreebook(wx.Treebook):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    55
    def __init__(self, parent, controler, node_editor):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    56
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    57
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    58
        @param parent: Reference to the parent wx.ScrolledWindow object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    59
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    60
        @param node_editor: Reference to Beremiz frame
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    61
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    62
        wx.Treebook.__init__(self, parent, -1, size=wx.DefaultSize, style=wx.BK_DEFAULT)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    63
        self.parent = parent
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    64
        self.Controler = controler
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    65
        self.NodeEditor = node_editor
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
    66
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    67
        self.EtherCATManagementClassObject = {}
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
    68
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    69
        # fill EtherCAT Management Treebook
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    70
        for pname, pclass, subs in [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    71
            ("Slave State",        SlaveStatePanelClass, []),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    72
            ("SDO Management",     SDOPanelClass, []),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    73
            ("PDO Monitoring",     PDOPanelClass, []),
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
    74
            ("ESC Management",     EEPROMAccessPanel, [
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    75
                    ("Smart View", SlaveSiiSmartView),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    76
                    ("Hex View", HexView)]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    77
            ("Register Access",     RegisterAccessPanel, [])]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    78
                self.AddPage(pclass(self, self.Controler), pname)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    79
                for spname, spclass in subs:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    80
                    self.AddSubPage(spclass(self, self.Controler), spname)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    81
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    82
        self.Bind(wx.EVT_TREEBOOK_PAGE_CHANGED, self.OnPageChanged)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    83
        self.Bind(wx.EVT_TREEBOOK_PAGE_CHANGING, self.OnPageChanging)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
    84
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    85
    def OnPageChanged(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    86
        old = event.GetOldSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    87
        new = event.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    88
        sel = event.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    89
        event.Skip()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
    90
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    91
    def OnPageChanging(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    92
        old = event.GetOldSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    93
        new = event.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    94
        sel = event.GetSelection()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
    95
        event.Skip()
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
    96
2360
2a3d022a7dac cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2358
diff changeset
    97
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
    98
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
    99
#                    For SlaveState Panel
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   100
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   101
class SlaveStatePanelClass(wx.Panel):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   102
    def __init__(self, parent, controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   103
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   104
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   105
        @param parent: Reference to the parent EtherCATManagementTreebook class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   106
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   107
        """
2366
d635680e4c2c cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2365
diff changeset
   108
        wx.Panel.__init__(self, parent, -1, (0, 0), size=wx.DefaultSize, style=wx.SUNKEN_BORDER)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   109
        self.Controler = controler
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   110
        self.parent = parent
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   111
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   112
        # initialize SlaveStatePanel UI dictionaries
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   113
        self.StaticBoxDic = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   114
        self.StaticTextDic = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   115
        self.TextCtrlDic = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   116
        self.ButtonDic = {}
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   117
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   118
        # iniitalize BoxSizer and FlexGridSizer
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   119
        self.SizerDic = {
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   120
            "SlaveState_main_sizer" : wx.BoxSizer(wx.VERTICAL),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   121
            "SlaveState_inner_main_sizer" : wx.FlexGridSizer(cols=1, hgap=50, rows=3, vgap=10),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   122
            "SlaveInfosDetailsInnerSizer" : wx.FlexGridSizer(cols=4, hgap=10, rows=2, vgap=10),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   123
            "SyncManagerInnerSizer" : wx.FlexGridSizer(cols=1, hgap=5, rows=1, vgap=5),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   124
            "SlaveState_sizer" : wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   125
            "SlaveState_up_sizer" : wx.FlexGridSizer(cols=4, hgap=10, rows=2, vgap=10),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   126
            "SlaveState_down_sizer" : wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=10)}
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   127
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   128
        # initialize StaticBox and StaticBoxSizer
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   129
        for box_name, box_label in [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   130
                ("SlaveInfosDetailsBox", "Slave Informations"),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   131
                ("SyncManagerBox", "Sync Manager"),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   132
                ("SlaveStateBox", "Slave State Transition && Monitoring")]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   133
            self.StaticBoxDic[box_name] = wx.StaticBox(self, label=_(box_label))
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   134
            self.SizerDic[box_name] = wx.StaticBoxSizer(self.StaticBoxDic[box_name])
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   135
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   136
        for statictext_name, statictext_label, textctrl_name in [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   137
                ("VendorLabel", "Vendor:", "vendor"),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   138
                ("ProductcodeLabel", "Product code:", "product_code"),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   139
                ("RevisionnumberLabel", "Slave Count:", "revision_number"),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   140
                ("PhysicsLabel", "Physics:", "physics")]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   141
            self.StaticTextDic[statictext_name] = wx.StaticText(self, label=_(statictext_label))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   142
            self.TextCtrlDic[textctrl_name] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   143
            self.SizerDic["SlaveInfosDetailsInnerSizer"].AddMany([self.StaticTextDic[statictext_name],
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   144
                                                               self.TextCtrlDic[textctrl_name]])
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   145
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   146
        self.SizerDic["SlaveInfosDetailsBox"].AddSizer(self.SizerDic["SlaveInfosDetailsInnerSizer"])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   147
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   148
        self.SyncManagersGrid = CustomGrid(self, size=wx.Size(605, 155), style=wx.VSCROLL)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   149
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   150
        self.SizerDic["SyncManagerInnerSizer"].Add(self.SyncManagersGrid)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   151
        self.SizerDic["SyncManagerBox"].Add(self.SizerDic["SyncManagerInnerSizer"])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   152
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   153
        for button_name, button_id, button_label, button_tooltipstring, event_method, sub_item in [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   154
                ("InitButton",   0, "INIT", "State Transition to \"Init\" State",     self.OnButtonClick, []),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   155
                ("PreOPButton",  1, "PREOP", "State Transition to \"PreOP\" State",   self.OnButtonClick, [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   156
                        ("TargetStateLabel", "Target State:" , "TargetState")]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   157
                ("SafeOPButton", 2, "SAFEOP", "State Transition to \"SafeOP\" State", self.OnButtonClick, []),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   158
                ("OPButton",     3, "OP",  "State Transition to \"OP\" State",        self.OnButtonClick, [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   159
                        ("CurrentStateLabel", "Current State:", "CurrentState")])]:
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   160
            self.ButtonDic[button_name] = wx.Button(self, id=button_id, label=_(button_label))
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   161
            self.ButtonDic[button_name].Bind(wx.EVT_BUTTON, event_method)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   162
            self.ButtonDic[button_name].SetToolTipString(button_tooltipstring)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   163
            self.SizerDic["SlaveState_up_sizer"].Add(self.ButtonDic[button_name])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   164
            for statictext_name, statictext_label, textctrl_name in sub_item :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   165
                self.StaticTextDic[statictext_name] = wx.StaticText(self, label=_(statictext_label))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   166
                self.TextCtrlDic[textctrl_name] = wx.TextCtrl(self, size=wx.DefaultSize, style=wx.TE_READONLY)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   167
                self.SizerDic["SlaveState_up_sizer"].AddMany([self.StaticTextDic[statictext_name],
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   168
                                                               self.TextCtrlDic[textctrl_name]])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   169
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   170
        for button_name, button_label, button_tooltipstring, event_method in [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   171
                ("StartTimerButton", "Start State Monitoring", "Slave State Update Restart", self.StartTimer),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   172
                ("StopTimerButton", "Stop State Monitoring", "Slave State Update Stop", self.CurrentStateThreadStop)]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   173
            self.ButtonDic[button_name] = wx.Button(self, label=_(button_label))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   174
            self.ButtonDic[button_name].Bind(wx.EVT_BUTTON, event_method)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   175
            self.ButtonDic[button_name].SetToolTipString(button_tooltipstring)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   176
            self.SizerDic["SlaveState_down_sizer"].Add(self.ButtonDic[button_name])
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   177
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   178
        self.SizerDic["SlaveState_sizer"].AddMany([self.SizerDic["SlaveState_up_sizer"],
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   179
            self.SizerDic["SlaveState_down_sizer"]])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   180
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   181
        self.SizerDic["SlaveStateBox"].Add(self.SizerDic["SlaveState_sizer"])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   182
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   183
        self.SizerDic["SlaveState_inner_main_sizer"].AddMany([
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   184
            self.SizerDic["SlaveInfosDetailsBox"], self.SizerDic["SyncManagerBox"],
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   185
            self.SizerDic["SlaveStateBox"]])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   186
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   187
        self.SizerDic["SlaveState_main_sizer"].Add(self.SizerDic["SlaveState_inner_main_sizer"])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   188
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   189
        self.SetSizer(self.SizerDic["SlaveState_main_sizer"])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   190
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   191
        # register a timer for periodic exectuion of slave state update (period: 1000 ms)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   192
        self.Bind(wx.EVT_TIMER, self.GetCurrentState)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   193
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   194
        self.CreateSyncManagerTable()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   195
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   196
        self.Centre()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   197
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   198
    def CreateSyncManagerTable(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   199
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   200
        Create grid for "SyncManager"
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   201
        """
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   202
        # declare Table object
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   203
        self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames())
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   204
        self.SyncManagersGrid.SetTable(self.SyncManagersTable)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   205
        # set grid alignment attr. (CENTER)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   206
        self.SyncManagersGridColAlignements = [wx.ALIGN_CENTRE, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE,
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   207
                                               wx.ALIGN_CENTRE, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   208
        # set grid size
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   209
        self.SyncManagersGridColSizes = [40, 150, 100, 100, 100, 100]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   210
        self.SyncManagersGrid.SetRowLabelSize(0)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   211
        for col in range(self.SyncManagersTable.GetNumberCols()):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   212
            attr = wx.grid.GridCellAttr()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   213
            attr.SetAlignment(self.SyncManagersGridColAlignements[col], wx.ALIGN_CENTRE)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   214
            self.SyncManagersGrid.SetColAttr(col, attr)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   215
            self.SyncManagersGrid.SetColMinimalWidth(col, self.SyncManagersGridColSizes[col])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   216
            self.SyncManagersGrid.AutoSizeColumn(col, False)
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   217
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   218
        self.RefreshSlaveInfos()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   219
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   220
    def RefreshSlaveInfos(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   221
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   222
        Fill data in "Slave Information" and "SyncManager"
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   223
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   224
        slave_infos = self.Controler.GetSlaveInfos()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   225
        sync_manager_section = ["vendor", "product_code", "revision_number", "physics"]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   226
        if slave_infos is not None:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   227
            # this method is same as "TextCtrl.SetValue"
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   228
            for textctrl_name in sync_manager_section:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   229
                self.TextCtrlDic[textctrl_name].SetValue(slave_infos[textctrl_name])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   230
            self.SyncManagersTable.SetData(slave_infos["sync_managers"])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   231
            self.SyncManagersTable.ResetView(self.SyncManagersGrid)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   232
        else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   233
            for textctrl_name in sync_manager_section:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   234
                self.TextCtrlDic[textctrl_name].SetValue("")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   235
            self.SyncManagersTable.SetData([])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   236
            self.SyncManagersTable.ResetView(self.SyncManagersGrid)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   237
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   238
    def OnButtonClick(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   239
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   240
        Event handler for slave state transition button click (Init, PreOP, SafeOP, OP button)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   241
        @param event : wx.EVT_BUTTON object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   242
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   243
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(False)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   244
        if check_connect_flag :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   245
            state_dic = ["INIT", "PREOP", "SAFEOP", "OP"]
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   246
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   247
            # If target state is one of {INIT, PREOP, SAFEOP}, request slave state transition immediately.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   248
            if event.GetId() < 3 :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   249
                self.Controler.CommonMethod.RequestSlaveState(state_dic[event.GetId()])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   250
                self.TextCtrlDic["TargetState"].SetValue(state_dic[event.GetId()])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   251
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   252
            # If target state is OP, first check "PLC status".
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   253
            #  (1) If current PLC status is "Started", then request slave state transition
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   254
            #  (2) Otherwise, show error message and return
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   255
            else :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   256
                status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   257
                if status == "Started" :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   258
                    self.Controler.CommonMethod.RequestSlaveState("OP")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   259
                    self.TextCtrlDic["TargetState"].SetValue("OP")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   260
                else :
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   261
                    self.Controler.CommonMethod.CreateErrorDialog("PLC is Not Started")
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   262
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   263
    def GetCurrentState(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   264
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   265
        Timer event handler for periodic slave state monitoring (Default period: 1 sec = 1000 msec).
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   266
        @param event : wx.TIMER object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   267
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   268
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(True)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   269
        if check_connect_flag:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   270
            returnVal = self.Controler.CommonMethod.GetSlaveStateFromSlave()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   271
            line = returnVal.split("\n")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   272
            try :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   273
                self.SetCurrentState(line[self.Controler.GetSlavePos()])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   274
            except Exception:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   275
                pass
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   276
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   277
    def SetCurrentState(self, line):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   278
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   279
        Show current slave state using the executiob result of "ethercat slaves" command.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   280
        @param line : result of "ethercat slaves" command
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   281
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   282
        state_array = ["INIT", "PREOP", "SAFEOP", "OP"]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   283
        try :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   284
            # parse the execution result of  "ethercat slaves" command
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   285
            # Result example : 0  0:0  PREOP  +  EL9800 (V4.30) (PIC24, SPI, ET1100)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   286
            token = line.split("  ")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   287
            if token[2] in state_array:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   288
                self.TextCtrlDic["CurrentState"].SetValue(token[2])
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   289
        except Exception:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   290
            pass
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   291
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   292
    def StartTimer(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   293
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   294
        Event handler for "Start State Monitoring" button.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   295
          - start slave state monitoring thread
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   296
        @param event : wx.EVT_BUTTON object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   297
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   298
        self.SlaveStateThread = wx.Timer(self)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   299
        # set timer period (1000 ms)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   300
        self.SlaveStateThread.Start(1000)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   301
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   302
    def CurrentStateThreadStop(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   303
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   304
        Event handler for "Stop State Monitoring" button.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   305
          - stop slave state monitoring thread
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   306
        @param event : wx.EVT_BUTTON object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   307
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   308
        try:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   309
            self.SlaveStateThread.Stop()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   310
        except Exception:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   311
            pass
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   312
2360
2a3d022a7dac cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2358
diff changeset
   313
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   314
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   315
#                    For SDO Management Panel
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   316
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   317
class SDOPanelClass(wx.Panel):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   318
    def __init__(self, parent, controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   319
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   320
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   321
        @param parent: Reference to the parent EtherCATManagementTreebook class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   322
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   323
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   324
        wx.Panel.__init__(self, parent, -1)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   325
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   326
        self.DatatypeDescription, self.CommunicationObject, self.ManufacturerSpecific, \
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   327
        self.ProfileSpecific, self.Reserved, self.AllSDOData = range(6)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   328
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   329
        self.Controler = controler
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   330
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   331
        self.SDOManagementMainSizer = wx.BoxSizer(wx.VERTICAL)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   332
        self.SDOManagementInnerMainSizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   333
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   334
        self.SDOUpdate = wx.Button(self, label=_('update'))
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   335
        self.SDOUpdate.Bind(wx.EVT_BUTTON, self.SDOInfoUpdate)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   336
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   337
        self.CallSDONoteBook = SDONoteBook(self, controler=self.Controler)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   338
        self.SDOManagementInnerMainSizer.Add(self.SDOUpdate)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   339
        self.SDOManagementInnerMainSizer.Add(self.CallSDONoteBook, wx.ALL | wx.EXPAND)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   340
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   341
        self.SDOManagementMainSizer.Add(self.SDOManagementInnerMainSizer)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   342
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   343
        self.SetSizer(self.SDOManagementMainSizer)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   344
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   345
    def SDOInfoUpdate(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   346
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   347
        Evenet handler for SDO "update" button.
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   348
          - Load SDO data from current slave
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   349
        @param event : wx.EVT_BUTTON object
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   350
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   351
        self.Controler.CommonMethod.SaveSDOData = []
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   352
        self.Controler.CommonMethod.ClearSDODataSet()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   353
        self.SDOFlag = False
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   354
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   355
        # Check whether beremiz connected or not.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   356
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(False)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   357
        if check_connect_flag:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   358
            self.SDOs = self.Controler.CommonMethod.GetSlaveSDOFromSlave()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   359
            # SDOFlag is "False", user click "Cancel" button
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   360
            self.SDOFlag = self.SDOParser()
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   361
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   362
            if self.SDOFlag :
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   363
                self.CallSDONoteBook.CreateNoteBook()
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   364
                self.Refresh()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   365
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   366
    def SDOParser(self):
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   367
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   368
        Parse SDO data set that obtain "SDOInfoUpdate" Method
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   369
        @return True or False
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   370
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   371
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   372
        slaveSDO_progress = wx.ProgressDialog("Slave SDO Monitoring", "Now Uploading...",
2366
d635680e4c2c cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2365
diff changeset
   373
                               maximum=len(self.SDOs.splitlines()), parent=self,
d635680e4c2c cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2365
diff changeset
   374
                               style=wx.PD_CAN_ABORT | wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME |
d635680e4c2c cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2365
diff changeset
   375
                                     wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME |
d635680e4c2c cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2365
diff changeset
   376
                                     wx.PD_AUTO_HIDE | wx.PD_SMOOTH)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   377
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   378
        # If keep_going flag is False, SDOParser method is stop and return "False".
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   379
        keep_going = True
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   380
        count = 0
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   381
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   382
        # SDO data example
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   383
        # SDO 0x1000, "Device type"
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   384
        # 0x1000:00,r-r-r-,uint32,32 bit,"Device type",0x00020192, 131474
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   385
        for details_line in self.SDOs.splitlines():
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   386
            count += 1
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   387
            line_token = details_line.split("\"")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   388
            # len(line_token[2]) case : SDO 0x1000, "Device type"
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   389
            if len(line_token[2]) == 0:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   390
                title_name = line_token[1]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   391
            # else case : 0x1000:00,r-r-r-,uint32,32 bit,"Device type",0x00020192, 131474
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   392
            else :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   393
                # line_token = ['0x1000:00,r-r-r-,uint32,32 bit,', 'Device type', ',0x00020192, 131474']
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   394
                token_head, name, token_tail = line_token
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   395
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   396
                # token_head = ['0x1000:00', 'r-r-r-', 'uint32', '32 bit', '']
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   397
                token_head = token_head.split(",")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   398
                ful_idx, access, type, size, empty = token_head
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   399
                # ful_idx.split(":") = ['0x1000', '00']
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   400
                idx, sub_idx = ful_idx.split(":")
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   401
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   402
                # token_tail = ['', '0x00020192', '131474']
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   403
                token_tail = token_tail.split(",")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   404
                try :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   405
                    empty, hex_val, dec_val = token_tail
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   406
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   407
                # SDO data is not return "dec value"
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   408
                # line example :
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   409
                # 0x1702:01,rwr-r-,uint32,32 bit," 1st mapping", ----
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   410
                except Exception:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   411
                    empty, hex_val = token_tail
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   412
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   413
                name_after_check = self.StringTest(name)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   414
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   415
                # convert hex type
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   416
                sub_idx = "0x" + sub_idx
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   417
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   418
                if type == "octet_string":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   419
                    hex_val = ' ---- '
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   420
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   421
                # SResult of SlaveSDO data parsing. (data type : dictionary)
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   422
                self.Data = {'idx': idx.strip(), 'subIdx': sub_idx.strip(), 'access': access.strip(),
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   423
                             'type': type.strip(), 'size': size.strip(),  'name': name_after_check.strip("\""),
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   424
                             'value': hex_val.strip(), "category": title_name.strip("\"")}
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   425
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   426
                category_divide_value = [0x1000, 0x2000, 0x6000, 0xa000, 0xffff]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   427
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   428
                for count in range(len(category_divide_value)) :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   429
                    if int(idx, 0) < category_divide_value[count]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   430
                        self.Controler.CommonMethod.SaveSDOData[count].append(self.Data)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   431
                        break
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   432
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   433
                self.Controler.CommonMethod.SaveSDOData[self.AllSDOData].append(self.Data)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   434
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   435
            if count >= len(self.SDOs.splitlines()) / 2:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   436
                (keep_going, skip) = slaveSDO_progress.Update(count, "Please waiting a moment!!")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   437
            else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   438
                (keep_going, skip) = slaveSDO_progress.Update(count)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   439
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   440
            # If user click "Cancel" loop suspend immediately
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   441
            if (keep_going == False):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   442
                break
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   443
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   444
        slaveSDO_progress.Destroy()
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   445
        return keep_going
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   446
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   447
    def StringTest(self, check_string):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   448
        """
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   449
        Test value 'name' is alphanumeric
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   450
        @param check_string : input data for check
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   451
        @return result : output data after check
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   452
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   453
        # string.printable is print this result
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   454
        # '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   455
        # !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   456
        allow_range = string.printable
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   457
        result = check_string
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   458
        for i in range(0, len(check_string)):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   459
            # string.isalnum() is check whether string is alphanumeric or not
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   460
            if check_string[len(check_string)-1-i:len(check_string)-i] in allow_range :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   461
                result = check_string[:len(check_string) - i]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   462
                break
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   463
        return result
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   464
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   465
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   466
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   467
#                    For SDO Notebook (divide category)
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   468
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   469
class SDONoteBook(wx.Notebook):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   470
    def __init__(self, parent, controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   471
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   472
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   473
        @param parent: Reference to the parent SDOPanelClass class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   474
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   475
        """
2366
d635680e4c2c cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2365
diff changeset
   476
        wx.Notebook.__init__(self, parent, id=-1, size=(850, 500))
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   477
        self.Controler = controler
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   478
        self.parent = parent
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   479
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   480
        self.CreateNoteBook()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   481
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   482
        self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGED, self.OnPageChanged)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   483
        self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGING, self.OnPageChanging)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   484
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   485
    def CreateNoteBook(self):
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   486
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   487
        Create each NoteBook page, divided SDO index
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   488
        According to EtherCAT Communication(03/2011), 158p
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   489
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   490
        self.Data = []
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   491
        count = 1
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   492
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   493
        page_texts = [("all", self.parent.AllSDOData),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   494
                     ("0x0000 - 0x0ff", self.parent.DatatypeDescription),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   495
                     ("0x1000 - 0x1fff", self.parent.CommunicationObject),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   496
                     ("0x2000 - 0x5fff", self.parent.ManufacturerSpecific),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   497
                     ("0x6000 - 0x9fff", self.parent.ProfileSpecific),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   498
                     ("0xa000 - 0xffff", self.parent.Reserved)]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   499
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   500
        page_tooltip_string = ["SDO Index 0x0000 - 0x0fff : Data Type Description",
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   501
                               "SDO Index 0x1000 - 0x1fff : Communication object",
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   502
                               "SDO Index 0x2000 - 0x5fff : Manufacturer specific",
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   503
                               "SDO Index 0x6000 - 0x9fff : Profile specific",
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   504
                               "SDO Index 0xa000 - 0xffff : Reserved",
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   505
                               "All SDO Object"]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   506
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   507
        self.DeleteAllPages()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   508
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   509
        for txt, count in page_texts:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   510
            self.Data = self.Controler.CommonMethod.SaveSDOData[count]
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   511
            self.Win = SlaveSDOTable(self, self.Data)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   512
            self.AddPage(self.Win, txt)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   513
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   514
    def OnPageChanged(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   515
        old = event.GetOldSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   516
        new = event.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   517
        sel = self.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   518
        event.Skip()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   519
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   520
    def OnPageChanging(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   521
        old = event.GetOldSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   522
        new = event.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   523
        sel = self.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   524
        event.Skip()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   525
2360
2a3d022a7dac cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2358
diff changeset
   526
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   527
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   528
#                    For SDO Grid (fill index, subindex, etc...)
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   529
# -------------------------------------------------------------------------------
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   530
class SlaveSDOTable(wx.grid.Grid):
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   531
    def __init__(self, parent, data):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   532
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   533
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   534
        @param parent: Reference to the parent SDOPanelClass class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   535
        @param data: SDO data after parsing "SDOParser" method
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   536
        """
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   537
        wx.grid.Grid.__init__(self, parent, -1, size=(830, 490),
2367
0fb54172a18b cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2366
diff changeset
   538
                              style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   539
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   540
        self.Controler = parent.Controler
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   541
        self.parent = parent
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   542
        self.SDOFlag = True
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   543
        if data is None :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   544
            self.SDOs = []
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   545
        else :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   546
            self.SDOs = data
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   547
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   548
        self.CreateGrid(len(self.SDOs), 8)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   549
        SDOCellSize = [(0, 65), (1, 65), (2, 50), (3, 55),
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   550
                         (4, 40), (5, 200), (6, 250), (7, 85)]
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   551
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   552
        for (index, size) in SDOCellSize:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   553
            self.SetColSize(index, size)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   554
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   555
        self.SetRowLabelSize(0)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   556
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   557
        SDOTableLabel = [(0, "Index"), (1, "Subindex"), (2, "Access"),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   558
                         (3, "Type"), (4, "Size"), (5, "Category"),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   559
                         (6, "Name"), (7, "Value")]
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   560
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   561
        for (index, label) in SDOTableLabel:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   562
            self.SetColLabelValue(index, label)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   563
            self.SetColLabelAlignment(index, wx.ALIGN_CENTRE)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   564
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   565
        attr = wx.grid.GridCellAttr()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   566
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   567
        # for SDO download
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   568
        self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.SDOModifyDialog)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   569
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   570
        for i in range(7):
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   571
            self.SetColAttr(i, attr)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   572
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   573
        self.SetColLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   574
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   575
        self.SetTableValue()
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   576
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   577
    def SetTableValue(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   578
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   579
        Cell is filled by new parsing data
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   580
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   581
        sdo_list = ['idx', 'subIdx', 'access', 'type', 'size', 'category', 'name', 'value']
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   582
        for row_idx in range(len(self.SDOs)):
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   583
            for col_idx in range(len(self.SDOs[row_idx])):
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   584
                self.SetCellValue(row_idx, col_idx, self.SDOs[row_idx][sdo_list[col_idx]])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   585
                self.SetReadOnly(row_idx, col_idx, True)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   586
                if col_idx < 5 :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   587
                    self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   588
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   589
    def CheckSDODataAccess(self, row):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   590
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   591
        CheckSDODataAccess method is checking that access data has "w"
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   592
        Access field consist 6 char, if mean
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   593
           rw      rw     rw
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   594
        (preop) (safeop) (op)
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   595
        Example Access field : rwrwrw, rwrw--
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   596
        @param row : Selected cell by user
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   597
        @return Write_flag : If data has "w", flag is true
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   598
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   599
        write_flag = False
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   600
        check = self.SDOs[row]['access']
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   601
        if check[1:2] == 'w' :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   602
            self.Controler.CommonMethod.Check_PREOP = True
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   603
            write_flag = True
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   604
        if check[3:4] == 'w' :
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   605
            self.Controler.CommonMethod.Check_SAFEOP = True
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   606
            write_flag = True
2365
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
   607
        if check[5:] == 'w' :
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   608
            self.Controler.CommonMethod.Check_OP = True
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   609
            write_flag = True
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   610
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   611
        return write_flag
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   612
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   613
    def DecideSDODownload(self, state):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   614
        """
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   615
        compare current state and "access" field,
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   616
        result notify SDOModifyDialog method
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   617
        @param state : current slave state
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   618
        @return True or False
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   619
        """
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   620
        # Example of 'state' parameter : "0  0:0  PREOP  +  EL9800 (V4.30) (PIC24, SPI, ET1100)"
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   621
        state = state[self.Controler.GetSlavePos()].split("  ")[2]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   622
        if state == "PREOP" and self.Controler.CommonMethod.Check_PREOP :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   623
            return True
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   624
        elif state == "SAFEOP" and self.Controler.CommonMethod.Check_SAFEOP :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   625
            return True
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   626
        elif state == "OP" and self.Controler.CommonMethod.Check_OP :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   627
            return True
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   628
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   629
        return False
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   630
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   631
    def ClearStateFlag(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   632
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   633
        Initialize StateFlag
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   634
        StateFlag is notice SDOData access each slave state
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   635
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   636
        self.Controler.CommonMethod.Check_PREOP = False
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   637
        self.Controler.CommonMethod.Check_SAFEOP = False
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   638
        self.Controler.CommonMethod.Check_OP = False
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   639
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   640
    def SDOModifyDialog (self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   641
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   642
        Create dialog for SDO value modify
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   643
        if user enter data, perform command "ethercat download"
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   644
        @param event : gridlib.EVT_GRID_CELL_LEFT_DCLICK object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   645
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   646
        self.ClearStateFlag()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   647
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   648
        # CheckSDODataAccess is checking that OD(Object Dictionary) has "w"
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   649
        if event.GetCol() == 7 and self.CheckSDODataAccess(event.GetRow()) :
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   650
            dlg = wx.TextEntryDialog (self, "Enter hex or dec value (if enter dec value, it automatically conversed hex value)",
2366
d635680e4c2c cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2365
diff changeset
   651
                                      "SDOModifyDialog", style=wx.OK | wx.CANCEL)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   652
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   653
            start_value = self.GetCellValue(event.GetRow(), event.GetCol())
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   654
            dlg.SetValue(start_value)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   655
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   656
            if dlg.ShowModal() == wx.ID_OK:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   657
                try :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   658
                    int(dlg.GetValue(), 0)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   659
                    # check "Access" field
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   660
                    if self.DecideSDODownload(self.Controler.CommonMethod.SlaveState[self.Controler.GetSlavePos()]) :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   661
                        # Request "SDODownload"
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   662
                        self.Controler.CommonMethod.SDODownload(self.SDOs[event.GetRow()]['type'], self.SDOs[event.GetRow()]['idx'],
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   663
                                                   self.SDOs[event.GetRow()]['subIdx'], dlg.GetValue())
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   664
                        self.SetCellValue(event.GetRow(), event.GetCol(), hex(int(dlg.GetValue(), 0)))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   665
                    else :
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   666
                        self.Controler.CommonMethod.CreateErrorDialog('You cannot SDO download this state')
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   667
                # Error occured process of "int(variable)"
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   668
                # User input is not hex, dec value
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   669
                except ValueError:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   670
                    self.Controler.CommonMethod.CreateErrorDialog('You can input only hex, dec value')
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   671
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   672
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   673
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   674
#                 For PDO Monitoring Panel
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   675
# PDO Class UI  : Panel -> Choicebook (RxPDO, TxPDO) ->
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   676
#                 Notebook (PDO Index) -> Grid (PDO entry)
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   677
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   678
class PDOPanelClass(wx.Panel):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   679
    def __init__(self, parent, controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   680
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   681
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   682
        @param parent: Reference to the parent EtherCATManagementTreebook class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   683
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   684
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   685
        wx.Panel.__init__(self, parent, -1)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   686
        self.Controler = controler
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   687
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   688
        self.PDOMonitoringEditorMainSizer = wx.BoxSizer(wx.VERTICAL)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   689
        self.PDOMonitoringEditorInnerMainSizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   690
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   691
        self.CallPDOChoicebook = PDOChoicebook(self, controler=self.Controler)
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   692
        self.PDOMonitoringEditorInnerMainSizer.Add(self.CallPDOChoicebook, wx.ALL)
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   693
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   694
        self.PDOMonitoringEditorMainSizer.Add(self.PDOMonitoringEditorInnerMainSizer)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   695
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   696
        self.SetSizer(self.PDOMonitoringEditorMainSizer)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   697
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   698
    def PDOInfoUpdate(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   699
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   700
        Call RequestPDOInfo method and create Choicebook
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   701
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   702
        self.Controler.CommonMethod.RequestPDOInfo()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   703
        self.CallPDOChoicebook.Destroy()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   704
        self.CallPDOChoicebook = PDOChoicebook(self, controler=self.Controler)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   705
        self.Refresh()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   706
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   707
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   708
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   709
#                    For PDO Choicebook (divide Tx, Rx PDO)
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   710
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   711
class PDOChoicebook(wx.Choicebook):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   712
    def __init__(self, parent, controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   713
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   714
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   715
        @param parent: Reference to the parent PDOPanelClass class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   716
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   717
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   718
        wx.Choicebook.__init__(self, parent, id=-1, size=(500, 500), style=wx.CHB_DEFAULT)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   719
        self.Controler = controler
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   720
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   721
        RxWin = PDONoteBook(self, controler=self.Controler, name="Rx")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   722
        TxWin = PDONoteBook(self, controler=self.Controler, name="Tx")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   723
        self.AddPage(RxWin, "RxPDO")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   724
        self.AddPage(TxWin, "TxPDO")
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   725
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   726
        self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGED, self.OnPageChanged)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   727
        self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGING, self.OnPageChanging)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   728
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   729
    def OnPageChanged(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   730
        old = event.GetOldSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   731
        new = event.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   732
        sel = self.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   733
        event.Skip()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   734
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   735
    def OnPageChanging(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   736
        old = event.GetOldSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   737
        new = event.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   738
        sel = self.GetSelection()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   739
        event.Skip()
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   740
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   741
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   742
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   743
#                    For PDO Notebook (divide PDO index)
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   744
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   745
class PDONoteBook(wx.Notebook):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   746
    def __init__(self, parent, name, controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   747
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   748
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   749
        @param parent: Reference to the parent PDOChoicebook class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   750
        @param name: identifier whether RxPDO or TxPDO
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   751
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   752
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   753
        wx.Notebook.__init__(self, parent, id=-1, size=(640, 400))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   754
        self.Controler = controler
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   755
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   756
        count = 0
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   757
        page_texts = []
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   758
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   759
        self.Controler.CommonMethod.RequestPDOInfo()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   760
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   761
        if name == "Tx" :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   762
            # obtain pdo_info and pdo_entry
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   763
            # pdo_info include (PDO index, name, number of entry)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   764
            pdo_info =  self.Controler.CommonMethod.GetTxPDOCategory()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   765
            pdo_entry = self.Controler.CommonMethod.GetTxPDOInfo()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   766
            for tmp in pdo_info :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   767
                title = str(hex(tmp['pdo_index']))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   768
                page_texts.append(title)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   769
        # RX PDO case
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   770
        else :
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   771
            pdo_info = self.Controler.CommonMethod.GetRxPDOCategory()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   772
            pdo_entry = self.Controler.CommonMethod.GetRxPDOInfo()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   773
            for tmp in pdo_info :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   774
                title = str(hex(tmp['pdo_index']))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   775
                page_texts.append(title)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   776
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   777
        # Add page depending on the number of pdo_info
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   778
        for txt in page_texts:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   779
            win = PDOEntryTable(self, pdo_info, pdo_entry, count)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   780
            self.AddPage(win, txt)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   781
            count += 1
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   782
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   783
        self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGED, self.OnPageChanged)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   784
        self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGING, self.OnPageChanging)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   785
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   786
    def OnPageChanged(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   787
        old = event.GetOldSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   788
        new = event.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   789
        sel = self.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   790
        event.Skip()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   791
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   792
    def OnPageChanging(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   793
        old = event.GetOldSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   794
        new = event.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   795
        sel = self.GetSelection()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   796
        event.Skip()
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   797
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   798
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   799
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   800
#                    For PDO Grid (fill entry index, subindex etc...)
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   801
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   802
class PDOEntryTable(wx.grid.Grid):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   803
    def __init__(self, parent, info, entry, count):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   804
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   805
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   806
        @param parent: Reference to the parent PDONoteBook class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   807
        @param info : data structure including entry index, sub index, name, length, type
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   808
        @param entry : data structure including index, name, entry number
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   809
        @param count : page number
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   810
        """
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   811
        wx.grid.Grid.__init__(self, parent, -1, size=(500, 400), pos=wx.Point(0, 0),
2367
0fb54172a18b cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2366
diff changeset
   812
                              style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   813
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   814
        self.Controler = parent.Controler
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   815
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   816
        self.PDOInfo = info
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   817
        self.PDOEntry = entry
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   818
        self.Count = count
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   819
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   820
        self.CreateGrid(self.PDOInfo[self.Count]['number_of_entry'], 5)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   821
        self.SetColLabelSize(25)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   822
        self.SetRowLabelSize(0)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   823
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   824
        PDOTableLabel = [(0, "Index"), (1, "Subindex"), (2, "Length"),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   825
                         (3, "Type"), (4, "Name")]
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   826
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   827
        for (index, label) in PDOTableLabel:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   828
            self.SetColLabelValue(index, label)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   829
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   830
        PDOCellSize = [(0, 45), (1, 65), (2, 55), (3, 40), (4, 300)]
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   831
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   832
        for (index, size) in PDOCellSize:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   833
            self.SetColSize(index, size)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   834
            self.SetColLabelAlignment(index, wx.ALIGN_LEFT)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   835
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   836
        attr = wx.grid.GridCellAttr()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   837
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   838
        for i in range(5):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   839
            self.SetColAttr(i, attr)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   840
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   841
        self.SetTableValue()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   842
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   843
    def SetTableValue(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   844
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   845
        Cell is filled by new parsing data in XML
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   846
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   847
        list_index = 0
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   848
        # number of entry
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   849
        for i in range(self.Count + 1) :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   850
            list_index += self.PDOInfo[i]['number_of_entry']
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   851
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   852
        start_value = list_index - self.PDOInfo[self.Count]['number_of_entry']
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   853
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   854
        pdo_list = ['entry_index', 'subindex', 'bitlen', 'type', 'name']
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   855
        for row_idx in range(self.PDOInfo[self.Count]['number_of_entry']):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   856
            for col_idx in range(len(self.PDOEntry[row_idx])):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   857
                # entry index is converted hex value.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   858
                if col_idx == 0 :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   859
                    self.SetCellValue(row_idx, col_idx, hex(self.PDOEntry[start_value][pdo_list[col_idx]]))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   860
                else :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   861
                    self.SetCellValue(row_idx, col_idx, str(self.PDOEntry[start_value][pdo_list[col_idx]]))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   862
                if col_idx != 4 :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   863
                    self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   864
                else :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   865
                    self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_LEFT, wx.ALIGN_CENTRE)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   866
                self.SetReadOnly(row_idx, col_idx, True)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   867
                self.SetRowSize(row_idx, 25)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   868
            start_value += 1
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   869
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   870
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   871
# -------------------------------------------------------------------------------
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   872
#                    For EEPROM Access Main Panel
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   873
#                 (This class explain EEPROM Access)
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   874
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   875
class EEPROMAccessPanel(wx.Panel):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   876
    def __init__(self, parent, controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   877
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   878
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   879
        @param parent: Reference to the parent EtherCATManagementTreebook class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   880
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   881
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   882
        wx.Panel.__init__(self, parent, -1)
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   883
        sizer = wx.FlexGridSizer(cols=1, hgap=20, rows=3, vgap=20)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   884
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   885
        line = wx.StaticText(self, -1, "\n  EEPROM Access is composed to SmartView and HexView. \
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   886
                                              \n\n   - SmartView shows Config Data, Device Identity, Mailbox settings, etc. \
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   887
                                              \n\n   - HexView shows EEPROM's contents.")
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   888
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   889
        sizer.Add(line)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   890
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   891
        self.SetSizer(sizer)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   892
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   893
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   894
# -------------------------------------------------------------------------------
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   895
#                    For Smart View Panel
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
   896
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   897
class SlaveSiiSmartView(wx.Panel):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   898
    def __init__(self, parent, controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   899
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   900
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   901
        @param parent: Reference to the parent EtherCATManagementTreebook class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   902
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   903
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   904
        wx.Panel.__init__(self, parent, -1)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   905
        self.parent = parent
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   906
        self.Controler = controler
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   907
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   908
        self.PDIType = {
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   909
            0  : ['none', '00000000'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   910
            4  : ['Digital I/O', '00000100'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   911
            5  : ['SPI Slave', '00000101'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   912
            7  : ['EtherCAT Bridge (port3)', '00000111'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   913
            8  : ['uC async. 16bit', '00001000'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   914
            9  : ['uC async. 8bit', '00001001'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   915
            10 : ['uC sync. 16bit', '00001010'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   916
            11 : ['uC sync. 8bit', '00001011'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   917
            16 : ['32 Digtal Input and 0 Digital Output', '00010000'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   918
            17 : ['24 Digtal Input and 8 Digital Output', '00010001'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   919
            18 : ['16 Digtal Input and 16 Digital Output', '00010010'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   920
            19 : ['8 Digtal Input and 24 Digital Output', '00010011'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   921
            20 : ['0 Digtal Input and 32 Digital Output', '00010100'],
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   922
            128: ['On-chip bus', '11111111']
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   923
        }
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   924
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   925
        sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=2, vgap=5)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   926
        button_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=1, vgap=5)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   927
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   928
        for button, mapping_method in [("Write EEPROM", self.WriteToEEPROM),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   929
                                       ("Read EEPROM", self.ReadFromEEPROM)]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   930
            btn = wx.Button(self, -1, button, size=(150, 40))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   931
            button_sizer.Add(btn, border=10, flag=wx.ALL)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   932
            btn.Bind(wx.EVT_BUTTON, mapping_method)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   933
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   934
        self.TreeListCtrl = SmartViewTreeListCtrl(self, self.Controler)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   935
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   936
        sizer.Add(button_sizer, border=10, flag=wx.ALL)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   937
        sizer.Add(self.TreeListCtrl, border=10, flag=wx.ALL)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   938
        self.SetSizer(sizer)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   939
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   940
        self.Create_SmartView()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   941
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   942
    def Create_SmartView(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   943
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   944
        SmartView shows information based on XML as initial value.
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   945
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   946
        self.Controler.CommonMethod.SmartViewInfosFromXML = self.Controler.CommonMethod.GetSmartViewInfos()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   947
        self.SetXMLData()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   948
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   949
    def WriteToEEPROM(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   950
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   951
        Open binary file (user select) and write the selected binary data to EEPROM
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   952
        @param event : wx.EVT_BUTTON object
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   953
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   954
        # Check whether beremiz connected or not, and whether status is "Started" or not.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   955
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(False)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   956
        if check_connect_flag:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   957
            status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   958
            if status is not "Started":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   959
                dialog = wx.FileDialog(self, _("Choose a binary file"), os.getcwd(), "",  _("bin files (*.bin)|*.bin"), wx.OPEN)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   960
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   961
                if dialog.ShowModal() == wx.ID_OK:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   962
                    filepath = dialog.GetPath()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   963
                    try:
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   964
                        binfile = open(filepath, "rb")
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   965
                        self.SiiBinary = binfile.read()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   966
                        dialog.Destroy()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   967
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   968
                        self.Controler.CommonMethod.SiiWrite(self.SiiBinary)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   969
                        # refresh data structure kept by master
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   970
                        self.Controler.CommonMethod.Rescan()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   971
                        # save binary data as inner global data of beremiz
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   972
                        # for fast loading when slave plugin node is reopened.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   973
                        self.Controler.CommonMethod.SiiData = self.SiiBinary
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   974
                        self.SetEEPROMData()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   975
                    except Exception:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   976
                        self.Controler.CommonMethod.CreateErrorDialog('The file does not exist!')
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   977
                        dialog.Destroy()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   978
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   979
    def ReadFromEEPROM(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   980
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   981
        Refresh displayed data based on slave EEPROM and save binary file through dialog
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   982
        @param event : wx.EVT_BUTTON object
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   983
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   984
        # Check whether beremiz connected or not.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   985
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(False)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   986
        if check_connect_flag:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   987
            self.SiiBinary = self.Controler.CommonMethod.LoadData()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   988
            self.SetEEPROMData()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   989
            dialog = wx.FileDialog(self, _("Save as..."), os.getcwd(),
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   990
                                   "slave0.bin",  _("bin files (*.bin)|*.bin|All files|*.*"),
2367
0fb54172a18b cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2366
diff changeset
   991
                                   wx.SAVE | wx.OVERWRITE_PROMPT)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   992
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   993
            if dialog.ShowModal() == wx.ID_OK:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   994
                filepath = dialog.GetPath()
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
   995
                binfile = open(filepath, "wb")
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   996
                binfile.write(self.SiiBinary)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   997
                binfile.close()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
   998
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
   999
            dialog.Destroy()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1000
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1001
    def SetXMLData(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1002
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1003
        Set data based on XML initially
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1004
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1005
        # Config Data: EEPROM Size, PDI Type, Device Emulation
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1006
        # Find PDI Type in pdiType dictionary
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1007
        cnt_pdi_type = self.Controler.CommonMethod.SmartViewInfosFromXML["pdi_type"]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1008
        for i in self.PDIType.keys():
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1009
            if cnt_pdi_type == i:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1010
                cnt_pdi_type = self.PDIType[i][0]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1011
                break
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1012
        #  Set Config Data
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1013
        for treelist, data in [("EEPROM Size (Bytes)",
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1014
                                str(self.Controler.CommonMethod.SmartViewInfosFromXML["eeprom_size"])),
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1015
                               ("PDI Type",
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1016
                                cnt_pdi_type),
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1017
                               ("Device Emulation",
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1018
                                self.Controler.CommonMethod.SmartViewInfosFromXML["device_emulation"])]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1019
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.ConfigData[treelist], data, 1)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1020
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1021
        # Device Identity: Vendor ID, Product Code, Revision No., Serial No.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1022
        #  Set Device Identity
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1023
        for treelist, data in [("Vendor ID", self.Controler.CommonMethod.SmartViewInfosFromXML["vendor_id"]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1024
                               ("Product Code", self.Controler.CommonMethod.SmartViewInfosFromXML["product_code"]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1025
                               ("Revision No.", self.Controler.CommonMethod.SmartViewInfosFromXML["revision_no"]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1026
                               ("Serial No.", self.Controler.CommonMethod.SmartViewInfosFromXML["serial_no"])]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1027
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.DeviceIdentity[treelist], data, 1)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1028
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1029
        # Mailbox: Supported Mailbox, Bootstrap Configuration, Standard Configuration
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1030
        #  Set Mailbox
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1031
        for treelist, data in [("Supported Mailbox", self.Controler.CommonMethod.SmartViewInfosFromXML["supported_mailbox"]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1032
                               ("Bootstrap Configuration", ""),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1033
                               ("Standard Configuration", "")]:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1034
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.Mailbox[treelist], data, 1)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1035
        #  Set Bootstrap Configuration: Receive Offset, Receive Size, Send Offset, Send Size
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1036
        for treelist, data in [("Receive Offset", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_bootstrapconf_outstart"]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1037
                               ("Receive Size", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_bootstrapconf_outlength"]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1038
                               ("Send Offset", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_bootstrapconf_instart"]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1039
                               ("Send Size", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_bootstrapconf_inlength"])]:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1040
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.BootstrapConfig[treelist], data, 1)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1041
        #  Set Standard Configuration: Receive Offset, Receive Size, Send Offset, Send Size
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1042
        for treelist, data in [("Receive Offset", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_standardconf_outstart"]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1043
                               ("Receive Size", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_standardconf_outlength"]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1044
                               ("Send Offset", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_standardconf_instart"]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1045
                               ("Send Size", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_standardconf_inlength"])]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1046
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.StandardConfig[treelist], data, 1)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1047
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1048
    def SetEEPROMData(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1049
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1050
        Set data based on slave EEPROM.
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1051
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1052
        # sii_dict = { Parameter : (WordAddress, WordSize) }
2365
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1053
        sii_dict = {
2369
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1054
            'PDIControl' :                          ('0', 1),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1055
            'PDIConfiguration' :                    ('1', 1),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1056
            'PulseLengthOfSYNCSignals' :            ('2', 1),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1057
            'ExtendedPDIConfiguration' :            ('3', 1),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1058
            'ConfiguredStationAlias' :              ('4', 1),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1059
            'Checksum' :                            ('7', 1),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1060
            'VendorID' :                            ('8', 2),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1061
            'ProductCode' :                         ('a', 2),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1062
            'RevisionNumber' :                      ('c', 2),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1063
            'SerialNumber' :                        ('e', 2),
2365
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1064
            'Execution Delay' :                     ('10', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1065
            'Port0Delay' :                          ('11', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1066
            'Port1Delay' :                          ('12', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1067
            'BootstrapReceiveMailboxOffset' :       ('14', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1068
            'BootstrapReceiveMailboxSize' :         ('15', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1069
            'BootstrapSendMailboxOffset' :          ('16', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1070
            'BootstrapSendMailboxSize' :            ('17', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1071
            'StandardReceiveMailboxOffset' :        ('18', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1072
            'StandardReceiveMailboxSize' :          ('19', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1073
            'StandardSendMailboxOffset' :           ('1a', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1074
            'StandardSendMailboxSize' :             ('1b', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1075
            'MailboxProtocol' :                     ('1c', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1076
            'Size' :                                ('3e', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1077
            'Version' :                             ('3f', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1078
            'First Category Type/Vendor Specific' : ('40', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1079
            'Following Category Word Size' :        ('41', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1080
            'Category Data' :                       ('42', 1),
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1081
        }
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1082
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1083
        # Config Data: EEPROM Size, PDI Type, Device Emulation
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1084
        # EEPROM's data in address '0x003f' is Size of EEPROM in KBit-1
2369
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1085
        eeprom_size = str((int(self.GetWordAddressData(sii_dict.get('Size'), 10))+1)/8*1024)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1086
        # Find PDI Type in pdiType dictionary
2369
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1087
        cnt_pdi_type = int(self.GetWordAddressData(sii_dict.get('PDIControl'), 16).split('x')[1][2:4], 16)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1088
        for i in self.PDIType.keys():
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1089
            if cnt_pdi_type == i:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1090
                cnt_pdi_type = self.PDIType[i][0]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1091
                break
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1092
        #  Get Device Emulation
2369
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1093
        device_emulation = str(bool(int("{:0>16b}".format(int(self.GetWordAddressData(sii_dict.get('PDIControl'), 16), 16))[7])))
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1094
        #  Set Config Data
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1095
        for treelist, data in [("EEPROM Size (Bytes)", eeprom_size),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1096
                               ("PDI Type", cnt_pdi_type),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1097
                               ("Device Emulation", device_emulation)]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1098
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.ConfigData[treelist], data, 1)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1099
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1100
        # Device Identity: Vendor ID, Product Code, Revision No., Serial No.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1101
        #  Set Device Identity
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
  1102
        for treelist, data in [
2369
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1103
                ("Vendor ID", self.GetWordAddressData(sii_dict.get('VendorID'), 16)),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1104
                ("Product Code", self.GetWordAddressData(sii_dict.get('ProductCode'), 16)),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1105
                ("Revision No.", self.GetWordAddressData(sii_dict.get('RevisionNumber'), 16)),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1106
                ("Serial No.", self.GetWordAddressData(sii_dict.get('SerialNumber'), 16))]:
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1107
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.DeviceIdentity[treelist], data, 1)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1108
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1109
        # Mailbox
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1110
        # EEORPOM's word address '1c' indicates supported mailbox protocol.
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1111
        # each value of mailbox protocol :
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1112
        # VoE(0x0020), SoE(0x0010), FoE(0x0008), CoE(0x0004), EoE(0x0002), AoE(0x0001)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1113
        supported_mailbox = ""
2365
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1114
        mailbox_protocol = ["VoE,  ", "SoE,  ", "FoE,  ", "CoE,  ", "EoE,  ", "AoE,  "]
2369
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1115
        mailbox_data = "{:0>8b}".format(int(self.GetWordAddressData(sii_dict.get('MailboxProtocol'), 16), 16))
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1116
        for protocol in range(6):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1117
            if mailbox_data[protocol+2] == '1':
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1118
                supported_mailbox += mailbox_protocol[protocol]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1119
        supported_mailbox = supported_mailbox.strip(",  ")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1120
        #  Set Mailbox
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1121
        for treelist, data in [("Supported Mailbox", supported_mailbox),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1122
                               ("Bootstrap Configuration", ""),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1123
                               ("Standard Configuration", "")]:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1124
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.Mailbox[treelist], data, 1)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1125
        #  Set Bootstrap Configuration: Receive Offset, Receive Size, Send Offset, Send Size
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
  1126
        for treelist, data in [
2369
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1127
                ("Receive Offset", self.GetWordAddressData(sii_dict.get('BootstrapReceiveMailboxOffset'), 10)),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1128
                ("Receive Size", self.GetWordAddressData(sii_dict.get('BootstrapReceiveMailboxSize'), 10)),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1129
                ("Send Offset", self.GetWordAddressData(sii_dict.get('BootstrapSendMailboxOffset'), 10)),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1130
                ("Send Size", self.GetWordAddressData(sii_dict.get('BootstrapSendMailboxSize'), 10))]:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1131
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.BootstrapConfig[treelist], data, 1)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1132
        #  Set Standard Configuration: Receive Offset, Receive Size, Send Offset, Send Size
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
  1133
        for treelist, data in [
2369
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1134
                ("Receive Offset", self.GetWordAddressData(sii_dict.get('StandardReceiveMailboxOffset'), 10)),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1135
                ("Receive Size", self.GetWordAddressData(sii_dict.get('StandardReceiveMailboxSize'), 10)),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1136
                ("Send Offset", self.GetWordAddressData(sii_dict.get('StandardSendMailboxOffset'), 10)),
24db1e592e20 cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2368
diff changeset
  1137
                ("Send Size", self.GetWordAddressData(sii_dict.get('StandardSendMailboxSize'), 10))]:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1138
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.StandardConfig[treelist], data, 1)
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1139
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1140
    def MakeStaticBoxSizer(self, boxlabel):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1141
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1142
        Make StaticBoxSizer
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1143
        @param boxlabel : label of box sizer
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1144
        @return sizer : the StaticBoxSizer labeled 'boxlabel'
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1145
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1146
        box = wx.StaticBox(self, -1, boxlabel)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1147
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1148
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1149
        return sizer
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1150
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1151
    def GetWordAddressData(self, dict_tuple, format):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1152
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1153
        This method converts word address data from EEPROM binary.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1154
        @param dict_tuple : element of 'sii_dict' dictionary in SetEEPROMData()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1155
        @param format : format of data. It can be 16(hex), 10(decimal) and 2(binary).
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1156
        @return formatted value
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1157
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1158
        offset = int(str(dict_tuple[0]), 16) * 2
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1159
        length = int(str(dict_tuple[1]), 16) * 2
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1160
        list = []
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1161
        data = ''
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1162
        for index in range(length):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1163
            hexdata = hex(ord(self.SiiBinary[offset + index]))[2:]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1164
            list.append(hexdata.zfill(2))
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1165
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1166
        list.reverse()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1167
        data = list[0:length]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1168
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1169
        if format == 16:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1170
            return '0x' + ''.join(data)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1171
        elif format == 10:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1172
            return str(int(str(''.join(data)), 16))
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1173
        elif format == 2:
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1174
            ''.join(data)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1175
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1176
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1177
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1178
#                    For Smart View TreeListCtrl
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1179
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1180
class SmartViewTreeListCtrl(wx.Panel):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1181
    def __init__(self, parent, Controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1182
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1183
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1184
        @param parent: Reference to the parent SlaveSiiSmartView class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1185
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1186
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1187
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1188
        wx.Panel.__init__(self, parent, -1, size=(350, 500))
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1189
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1190
        self.Tree = wx.gizmos.TreeListCtrl(self, -1, size=(350, 500),
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1191
                                           style=wx.TR_DEFAULT_STYLE
2365
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1192
                                               | wx.TR_FULL_ROW_HIGHLIGHT
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1193
                                               | wx.TR_HIDE_ROOT
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1194
                                               | wx.TR_COLUMN_LINES
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1195
                                               | wx.TR_ROW_LINES)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1196
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1197
        self.Tree.AddColumn("Description", width=200)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1198
        self.Tree.AddColumn("Value", width=140)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1199
        self.Tree.SetMainColumn(0)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1200
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1201
        self.Root = self.Tree.AddRoot("")
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1202
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1203
        # Add item
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1204
        #  Level 1 nodes
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1205
        self.Level1Nodes = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1206
        for lv1 in ["Config Data", "Device Identity", "Mailbox"]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1207
            self.Level1Nodes[lv1] = self.Tree.AppendItem(self.Root, lv1)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1208
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1209
        #  Level 2 nodes
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1210
        #   Config Data
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1211
        self.ConfigData = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1212
        for lv2 in ["EEPROM Size (Bytes)", "PDI Type", "Device Emulation"]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1213
            self.ConfigData[lv2] = self.Tree.AppendItem(self.Level1Nodes["Config Data"], lv2)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1214
        #   Device Identity
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1215
        self.DeviceIdentity = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1216
        for lv2 in ["Vendor ID", "Product Code", "Revision No.", "Serial No."]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1217
            self.DeviceIdentity[lv2] = self.Tree.AppendItem(self.Level1Nodes["Device Identity"], lv2)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1218
        #   Mailbox
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1219
        self.Mailbox = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1220
        for lv2 in ["Supported Mailbox", "Bootstrap Configuration", "Standard Configuration"]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1221
            self.Mailbox[lv2] = self.Tree.AppendItem(self.Level1Nodes["Mailbox"], lv2)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1222
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1223
        #  Level 3 nodes
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1224
        #   Children of Bootstrap Configuration
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1225
        self.BootstrapConfig = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1226
        for lv3 in ["Receive Offset", "Receive Size", "Send Offset", "Send Size"]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1227
            self.BootstrapConfig[lv3] = self.Tree.AppendItem(self.Mailbox["Bootstrap Configuration"], lv3)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1228
        #   Children of Standard Configuration
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1229
        self.StandardConfig = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1230
        for lv3 in ["Receive Offset", "Receive Size", "Send Offset", "Send Size"]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1231
            self.StandardConfig[lv3] = self.Tree.AppendItem(self.Mailbox["Standard Configuration"], lv3)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1232
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1233
        # Expand Tree
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1234
        for tree in [self.Root,
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1235
                     self.Level1Nodes["Config Data"],
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1236
                     self.Level1Nodes["Device Identity"],
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1237
                     self.Level1Nodes["Mailbox"],
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1238
                     self.Mailbox["Bootstrap Configuration"],
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1239
                     self.Mailbox["Standard Configuration"]]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1240
            self.Tree.Expand(tree)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1241
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1242
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1243
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1244
#                         For Hex View Panel
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1245
#            shows EEPROM binary as hex data and characters.
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1246
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1247
class HexView(wx.Panel):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1248
    def __init__(self, parent, controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1249
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1250
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1251
        @param parent: Reference to the parent EtherCATManagementTreebook class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1252
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1253
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1254
        wx.Panel.__init__(self, parent, -1)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1255
        self.parent = parent
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1256
        self.Controler = controler
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1257
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1258
        self.HexRow = 8
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1259
        self.HexCol = 17
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1260
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1261
        self.HexViewSizer = {"view" : wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1262
                             "siiButton" : wx.BoxSizer()}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1263
        self.HexViewButton = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1264
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1265
        for key, evt_handler in [("Sii Upload", self.OnButtonSiiUpload),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1266
                                ("Sii Download", self.OnButtonSiiDownload),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1267
                                ("Write to File", self.OnButtonWriteToBinFile),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1268
                                ("Read from File", self.OnButtonReadFromBinFile),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1269
                                ("XML to EEPROM Image", self.OnButtonXmlToEEPROMImg)]:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1270
            self.HexViewButton[key] = wx.Button(self, -1, key)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1271
            self.HexViewButton[key].Bind(wx.EVT_BUTTON, evt_handler)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1272
            self.HexViewSizer["siiButton"].Add(self.HexViewButton[key])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1273
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1274
        self.SiiBinary = self.Controler.CommonMethod.XmlToEeprom()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1275
        self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1276
        self.SiiGrid = SiiGridTable(self, self.Controler, self.HexRow, self.HexCol)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1277
        self.HexViewSizer["view"].AddMany([self.HexViewSizer["siiButton"], self.SiiGrid])
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1278
        self.SiiGrid.CreateGrid(self.HexRow, self.HexCol)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1279
        self.SetSizer(self.HexViewSizer["view"])
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1280
        self.HexViewSizer["view"].FitInside(self.parent.parent)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1281
        self.parent.parent.FitInside()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1282
        self.SiiGrid.SetValue(self.HexCode)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1283
        self.SiiGrid.Update()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1284
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1285
    def UpdateSiiGridTable(self, row, col):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1286
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1287
        Destroy existing grid and recreate
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1288
        @param row, col : Hex View grid size
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1289
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1290
        self.HexViewSizer["view"].Detach(self.SiiGrid)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1291
        self.SiiGrid.Destroy()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1292
        self.SiiGrid = SiiGridTable(self, self.Controler, row, col)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1293
        self.HexViewSizer["view"].Add(self.SiiGrid)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1294
        self.SiiGrid.CreateGrid(row, col)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1295
        self.SetSizer(self.HexViewSizer["view"])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1296
        self.HexViewSizer["view"].FitInside(self.parent.parent)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1297
        self.parent.parent.FitInside()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1298
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1299
    def OnButtonSiiUpload(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1300
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1301
        Load EEPROM data from slave and refresh Hex View grid
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1302
        Binded to 'Sii Upload' button.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1303
        @param event : wx.EVT_BUTTON object
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1304
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1305
        # Check whether beremiz connected or not.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1306
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(False)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1307
        if check_connect_flag:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1308
            # load from EEPROM data and parsing
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1309
            self.SiiBinary = self.Controler.CommonMethod.LoadData()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1310
            self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1311
            self.UpdateSiiGridTable(self.HexRow, self.HexCol)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1312
            self.SiiGrid.SetValue(self.HexCode)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1313
            self.SiiGrid.Update()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1314
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1315
    def OnButtonSiiDownload(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1316
        """
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1317
        Write current EEPROM data to slave and refresh data structure kept by master
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1318
        Binded to 'Sii Download' button.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1319
        @param event : wx.EVT_BUTTON object
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1320
        """
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1321
        # Check whether beremiz connected or not,
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1322
        # and whether status is "Started" or not.
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1323
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(False)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1324
        if check_connect_flag:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1325
            status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1326
            if status is not "Started":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1327
                self.Controler.CommonMethod.SiiWrite(self.SiiBinary)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1328
                self.Controler.CommonMethod.Rescan()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1329
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1330
    def OnButtonWriteToBinFile(self, event):
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1331
        """
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1332
        Save current EEPROM data to binary file through FileDialog
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1333
        Binded to 'Write to File' button.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1334
        @param event : wx.EVT_BUTTON object
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1335
        """
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1336
        dialog = wx.FileDialog(self, _("Save as..."), os.getcwd(), "slave0.bin",
2367
0fb54172a18b cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2366
diff changeset
  1337
                               _("bin files (*.bin)|*.bin|All files|*.*"), wx.SAVE | wx.OVERWRITE_PROMPT)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1338
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1339
        if dialog.ShowModal() == wx.ID_OK:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1340
            filepath = dialog.GetPath()
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
  1341
            binfile = open(filepath, "wb")
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1342
            binfile.write(self.SiiBinary)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1343
            binfile.close()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1344
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1345
        dialog.Destroy()
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1346
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1347
    def OnButtonReadFromBinFile(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1348
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1349
        Load binary file through FileDialog
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1350
        Binded to 'Read from File' button.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1351
        @param event : wx.EVT_BUTTON object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1352
        """
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1353
        dialog = wx.FileDialog(self, _("Choose a binary file"), os.getcwd(), "",
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1354
                               _("bin files (*.bin)|*.bin"), wx.OPEN)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1355
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1356
        if dialog.ShowModal() == wx.ID_OK:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1357
            filepath = dialog.GetPath()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1358
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1359
            try:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1360
                binfile = open(filepath, "rb")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1361
                self.SiiBinary = binfile.read()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1362
                self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1363
                self.UpdateSiiGridTable(self.HexRow, self.HexCol)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1364
                self.SiiGrid.SetValue(self.HexCode)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1365
                self.SiiGrid.Update()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1366
            except Exception:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1367
                self.Controler.CommonMethod.CreateErrorDialog('The file does not exist!')
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1368
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1369
        dialog.Destroy()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1370
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1371
    def OnButtonXmlToEEPROMImg(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1372
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1373
        Create EEPROM data based XML data that current imported
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1374
        Binded to 'XML to EEPROM' button.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1375
        @param event : wx.EVT_BUTTON object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1376
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1377
        self.SiiBinary = self.Controler.CommonMethod.XmlToEeprom()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1378
        self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1379
        self.UpdateSiiGridTable(self.HexRow, self.HexCol)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1380
        self.SiiGrid.SetValue(self.HexCode)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1381
        self.SiiGrid.Update()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1382
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1383
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1384
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1385
#                    For Hex View grid (fill hex data)
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1386
# -------------------------------------------------------------------------------
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1387
class SiiGridTable(wx.grid.Grid):
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1388
    def __init__(self, parent, controler, row, col):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1389
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1390
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1391
        @param parent: Reference to the parent HexView class
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1392
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1393
        @param row, col: Hex View grid size
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1394
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1395
        self.parent = parent
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1396
        self.Controler = controler
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1397
        self.Row = row
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1398
        self.Col = col
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1399
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
  1400
        wx.grid.Grid.__init__(self, parent, -1, size=(830, 450),
2367
0fb54172a18b cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2366
diff changeset
  1401
                              style=wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1402
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1403
    def SetValue(self, value):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1404
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1405
        Set data in the table
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1406
        @param value: EEPROM data list of which element is 1 Byte hex data
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1407
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1408
        # set label name and size
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1409
        self.SetRowLabelSize(100)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1410
        for col in range(self.Col):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1411
            if col == 16:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1412
                self.SetColLabelValue(16, "Text View")
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1413
                self.SetColSize(16, (self.GetSize().x-120)*4/20)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1414
            else:
2358
8e5a9830867e cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2356
diff changeset
  1415
                self.SetColLabelValue(col, '%s' % col)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1416
                self.SetColSize(col, (self.GetSize().x-120)/20)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1417
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1418
        # set data into table
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1419
        row = col = 0
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1420
        for row_idx in value:
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1421
            col = 0
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1422
            self.SetRowLabelValue(row, "0x"+"{:0>4x}".format(row*(self.Col-1)))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1423
            for hex in row_idx:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1424
                self.SetCellValue(row, col, hex)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1425
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1426
                if col == 16:
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1427
                    self.SetCellAlignment(row, col, wx.ALIGN_LEFT, wx.ALIGN_CENTER)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1428
                else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1429
                    self.SetCellAlignment(row, col, wx.ALIGN_CENTRE, wx.ALIGN_CENTER)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1430
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1431
                self.SetReadOnly(row, col, True)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1432
                col = col + 1
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1433
            row = row + 1
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1434
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1435
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1436
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1437
#                    For Register Access Panel
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1438
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1439
class RegisterAccessPanel(wx.Panel):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1440
    def __init__(self, parent, controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1441
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1442
	    Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1443
	    @param parent: EEPROMAccessPanel object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1444
	    @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1445
	    """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1446
        self.parent = parent
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1447
        self.Controler = controler
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1448
        self.__init_data()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1449
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1450
        wx.Panel.__init__(self, parent, -1)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1451
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1452
        sizer = wx.FlexGridSizer(cols=1, hgap=20, rows=2, vgap=5)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1453
        button_sizer = wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=10)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1454
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1455
        self.ReloadButton = wx.Button(self, -1, "Reload")
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1456
        self.CompactViewCheckbox = wx.CheckBox(self, -1, "Compact View")
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1457
        self.RegisterNotebook = RegisterNotebook(self, self.Controler)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1458
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1459
        button_sizer.AddMany([self.ReloadButton, self.CompactViewCheckbox])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1460
        sizer.AddMany([button_sizer, self.RegisterNotebook])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1461
        self.SetSizer(sizer)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1462
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1463
        self.ReloadButton.Bind(wx.EVT_BUTTON, self.OnReloadButton)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1464
        self.CompactViewCheckbox.Bind(wx.EVT_CHECKBOX, self.ToggleCompactViewCheckbox)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1465
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1466
        for index in range(4):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1467
            self.RegisterNotebook.RegPage[index].MainTable.CreateGrid(self.MainRow[index], self.MainCol)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1468
            self.RegisterNotebook.RegPage[index].MainTable.SetValue(self, 0, index*512, (index+1)*512)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1469
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1470
        # data default setting
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1471
        if self.Controler.CommonMethod.RegData == "":
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1472
            self.CompactViewCheckbox.Disable()
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1473
            for index in range(4):
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1474
                self.RegisterNotebook.RegPage[index].MainTable.SetValue(self, 0, index*512, (index+1)*512)
2361
5d6ce74f7835 cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2360
diff changeset
  1475
        else:  # If data was saved,
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1476
            self.BasicSetData()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1477
            self.ParseData()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1478
            for index in range(4):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1479
                self.RegisterNotebook.RegPage[index].MainTable.SetValue(self, self.RegMonitorData, index*512, (index+1)*512)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1480
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1481
    def __init_data(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1482
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1483
	    Declare initial data.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1484
	    """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1485
        # flag for compact view
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1486
        self.CompactFlag = False
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1487
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1488
        # main grid의 rows and cols
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1489
        self.MainRow = [512, 512, 512, 512]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1490
        self.MainCol = 4
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1491
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1492
        # main grids' data range
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1493
        self.PageRange = []
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1494
        for index in range(4):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1495
            self.PageRange.append([512*index, 512*(index+1)])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1496
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1497
        #  Previous value of register data for register description configuration
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1498
        self.PreRegSpec = {"ESCType": "",
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1499
                           "FMMUNumber": "",
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1500
                           "SMNumber": "",
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1501
                           "PDIType": ""}
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1502
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1503
    def LoadData(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1504
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1505
        Get data from the register.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1506
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1507
        self.Controler.CommonMethod.RegData = ""
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1508
        # ethercat reg_read
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1509
        # ex : ethercat reg_read -p 0 0x0000 0x0001
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1510
        # return value : 0x11
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1511
        for index in range(4):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1512
            self.Controler.CommonMethod.RegData = self.Controler.CommonMethod.RegData + " " + self.Controler.CommonMethod.RegRead("0x"+"{:0>4x}".format(index*1024), "0x0400")
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1513
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1514
        # store previous value
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1515
        # (ESC type, port number of FMMU, port number of SM, and PDI type))
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
  1516
        for reg_spec in ["ESCType", "FMMUNumber", "SMNumber", "PDIType"]:
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1517
            self.PreRegSpec[reg_spec] = self.Controler.CommonMethod.CrtRegSpec[reg_spec]
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1518
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1519
        # update registers' description
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1520
        # (ESC type, port number of FMMU, port number of SM, and PDI type)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1521
        for reg_spec, address in [("ESCType", "0x0000"),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1522
                                  ("FMMUNumber", "0x0004"),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1523
                                  ("SMNumber", "0x0005"),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1524
                                  ("PDIType", "0x0140")]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1525
            self.Controler.CommonMethod.CrtRegSpec[reg_spec] = self.Controler.CommonMethod.RegRead(address, "0x0001")
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1526
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1527
        # Enable compactView checkbox
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1528
        self.CompactViewCheckbox.Enable()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1529
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1530
    def BasicSetData(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1531
        """
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1532
        Get and save the description of registers.
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1533
        It's done by parsing register_information.xml.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1534
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1535
        # parse the above register's value
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1536
        # If the value is 0x12, the result is 12
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1537
        self.ESCType = self.Controler.CommonMethod.CrtRegSpec["ESCType"].split('x')[1]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1538
        self.PDIType = self.Controler.CommonMethod.CrtRegSpec["PDIType"].split('x')[1]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1539
        # If the value is 0x12, the result is 18 (It's converted to decimal value)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1540
        self.FMMUNumber = int(self.Controler.CommonMethod.CrtRegSpec["FMMUNumber"], 16)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1541
        self.SMNumber = int(self.Controler.CommonMethod.CrtRegSpec["SMNumber"], 16)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1542
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1543
        # initialize description dictionary of register main table and register sub table.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1544
        self.RegisterDescriptionDict = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1545
        self.RegisterSubGridDict = {}
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1546
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1547
        # ./EthercatMaster/register_information.xml contains register description.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1548
        if wx.Platform == '__WXMSW__':
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1549
            reg_info_file = open("../../EthercatMaster/register_information.xml", 'r')
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1550
        else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1551
            reg_info_file = open("./EthercatMaster/register_information.xml", 'r')
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1552
        reg_info_tree = minidom.parse(reg_info_file)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1553
        reg_info_file.close()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1554
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1555
        # parse register description
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1556
        for register_info in reg_info_tree.childNodes:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1557
            for register in register_info.childNodes:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1558
                if register.nodeType == reg_info_tree.ELEMENT_NODE and register.nodeName == "Register":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1559
                    # If it depends on the property(ESC type, PDI type, FMMU number, SM number)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1560
                    for property, type, value in [("esc", "type", self.ESCType),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1561
                                                  ("pdi", "type", self.PDIType),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1562
                                                  ("fmmu", "number", self.FMMUNumber),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1563
                                                  ("sm", "number", self.SMNumber)]:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1564
                        if property in register.attributes.keys():
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1565
                            if type == "type":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1566
                                if register.attributes[property].value == value:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1567
                                    self.GetRegisterInfo(reg_info_tree, register)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1568
                                    break
2361
5d6ce74f7835 cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2360
diff changeset
  1569
                            else:  # type == "number"
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1570
                                if register.attributes[property].value < value:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1571
                                    self.GetRegisterInfo(reg_info_tree, register)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1572
                                    break
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1573
                        else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1574
                            self.GetRegisterInfo(reg_info_tree, register)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1575
                            break
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1576
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1577
    def GetRegisterInfo(self, reg_info_tree, register):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1578
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1579
        Save the register's description into the dictionary.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1580
        reg_info_tree is based on the register_information.xml.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1581
        @param reg_info_tree: XML tree
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1582
        @param register: register which you want to get the description
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1583
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1584
        # temporary variables for register main table idescription dictionary
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1585
        reg_index = ""
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1586
        reg_main_description = ""
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1587
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1588
        for data in register.childNodes:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1589
            if data.nodeType == reg_info_tree.ELEMENT_NODE and data.nodeName == "Index":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1590
                for index in data.childNodes:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1591
                    reg_index = index.nodeValue
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1592
            if data.nodeType == reg_info_tree.ELEMENT_NODE and data.nodeName == "Description":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1593
                for description in data.childNodes:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1594
                    reg_main_description = description.nodeValue
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1595
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1596
            # Add description for register main table
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1597
            if reg_index is not "" and reg_main_description is not "":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1598
                self.RegisterDescriptionDict[reg_index] = reg_main_description
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1599
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1600
            if data.nodeType == reg_info_tree.ELEMENT_NODE and data.nodeName == "Details":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1601
                # declare register sub table description dictionary about this index
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1602
                self.RegisterSubGridDict[reg_index] = []
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1603
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1604
                for detail in data.childNodes:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1605
                    if detail.nodeType == reg_info_tree.ELEMENT_NODE and detail.nodeName == "Detail":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1606
                        # If it depends on the property(ESC type, PDI type, FMMU number, SM number)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1607
                        for property, type, value in [("esc", "type", self.ESCType),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1608
                                                      ("pdi", "type", self.PDIType),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1609
                                                      ("fmmu", "number", self.FMMUNumber),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1610
                                                      ("sm", "number", self.SMNumber)]:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1611
                            if property in detail.attributes.keys():
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1612
                                if type == "type":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1613
                                    if detail.attributes[property].value == value:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1614
                                        self.GetRegisterDetailInfo(reg_info_tree, reg_index, detail)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1615
                                        break
2361
5d6ce74f7835 cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2360
diff changeset
  1616
                                else:  # type == "number"
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1617
                                    if detail.attributes[property].value < value:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1618
                                        self.GetRegisterDetailInfo(reg_info_tree, reg_index, detail)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1619
                                        break
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1620
                            else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1621
                                self.GetRegisterDetailInfo(reg_info_tree, reg_index, detail)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1622
                                break
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1623
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1624
    def GetRegisterDetailInfo(self, reg_info_tree, reg_index, detail):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1625
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1626
        Get the resgister's detailed description(for sub table) from the reg_info_tree.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1627
        @param reg_info_tree: XML tree (register_information.xml)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1628
        @param reg_index: index of the register
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1629
        @param detail: description of the register
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1630
        """
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1631
        # temporary variables for register sub table description dictionary
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1632
        # - It is initialized in every sub description
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1633
        reg_bit_range = ""
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1634
        reg_sub_description = ""
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1635
        reg_enum_dictionary = {}
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1636
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1637
        for detail_data in detail.childNodes:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1638
            if detail_data.nodeType == reg_info_tree.ELEMENT_NODE and detail_data.nodeName == "Range":
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1639
                for range in detail_data.childNodes:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1640
                    reg_bit_range = range.nodeValue
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1641
            if detail_data.nodeType == reg_info_tree.ELEMENT_NODE and detail_data.nodeName == "Description":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1642
                for description in detail_data.childNodes:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1643
                    reg_sub_description = description.nodeValue
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1644
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1645
            if detail_data.nodeType == reg_info_tree.ELEMENT_NODE and detail_data.nodeName == "Enum":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1646
                for enum in detail_data.childNodes:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1647
                    if enum.nodeType == reg_info_tree.ELEMENT_NODE and enum.nodeName == "item":
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1648
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1649
                        # temporary variables for a description of each value
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1650
                        # For example, if the bit is 1, it is 'enabled'('On', 'True', etc.),
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1651
                        # otherwise 'disabled'('Off', 'False', etc.).
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1652
                        reg_sub_value = ""
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1653
                        reg_sub_value_description = ""
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1654
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1655
                        for item in enum.childNodes:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1656
                            if item.nodeType == reg_info_tree.ELEMENT_NODE and item.nodeName == "value":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1657
                                for value in item.childNodes:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1658
                                    reg_sub_value = value.nodeValue
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1659
                            if item.nodeType == reg_info_tree.ELEMENT_NODE and item.nodeName == "Description":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1660
                                for description in item.childNodes:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1661
                                    reg_sub_value_description = description.nodeValue
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1662
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1663
                            # Add a description of each value to register enum dictionary
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1664
                            if reg_sub_value is not "" and reg_sub_value_description is not "":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1665
                                reg_enum_dictionary[reg_sub_value] = reg_sub_value_description
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1666
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1667
        # add a description to register sub table description dictionary
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1668
        if reg_bit_range is not "" and reg_sub_description is not "":
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1669
            self.RegisterSubGridDict[reg_index].append([reg_bit_range,
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1670
                                                         reg_sub_description, reg_enum_dictionary])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1671
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1672
    def ParseData(self):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1673
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1674
        Transform the data into dec, hex, string, and description
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1675
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1676
        row_data = []
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1677
        self.RegMonitorData = []
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1678
        reg_word = ""
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1679
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1680
        reg_data = self.Controler.CommonMethod.RegData.split()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1681
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1682
        # loop for register(0x0000:0x0fff)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1683
        for address in range(0x1000):
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1684
            # arrange 2 Bytes of register data
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1685
            reg_word = reg_data[address].split('x')[1] + reg_word
2358
8e5a9830867e cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2356
diff changeset
  1686
            if (address % 2) == 1:
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1687
                # append address
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1688
                hex_address = "{:0>4x}".format(address-1)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1689
                row_data.append(hex_address)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1690
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1691
                # append description
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1692
                if self.RegisterDescriptionDict.has_key(hex_address):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1693
                    row_data.append(self.RegisterDescriptionDict[hex_address])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1694
                else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1695
                    row_data.append("")
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1696
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1697
                # append Decimal value
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1698
                row_data.append(str(int(reg_word, 16)))
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1699
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1700
                # append Hex value
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1701
                row_data.append('0x'+reg_word)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1702
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1703
                # append ASCII value
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1704
                char_data = ""
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1705
                for iter in range(2):
2365
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1706
                    if int(reg_word[iter*2:iter*2+2], 16) >= 32 and int(reg_word[iter*2:iter*2+2], 16) <= 126:
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1707
                        char_data = char_data + chr(int(reg_word[iter*2:iter*2+2], 16))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1708
                    else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1709
                        char_data = char_data + "."
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1710
                row_data.append(char_data)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1711
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1712
                self.RegMonitorData.append(row_data)
2361
5d6ce74f7835 cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2360
diff changeset
  1713
                reg_word = ""  # initialize regWord
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1714
                row_data = []
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1715
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1716
    def OnReloadButton(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1717
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1718
        Handle the click event of the 'Reload' button.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1719
        Get the data from registers again, and update the table.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1720
        @param event: wx.EVT_BUTTON object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1721
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1722
        # Check whether beremiz connected or not.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1723
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(False)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1724
        if check_connect_flag:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1725
            self.LoadData()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1726
            self.BasicSetData()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1727
            self.ParseData()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1728
            # set data into UI
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1729
            if self.CompactFlag:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1730
                self.ToggleCompactViewCheckbox(True)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1731
            else :
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1732
                for index in range(4):
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1733
                    self.RegisterNotebook.RegPage[index].UpdateMainTable(self.MainRow[index], self.MainCol,
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1734
                                                                         self.PageRange[index][0], self.PageRange[index][1],
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1735
                                                                         self.RegMonitorData)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1736
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1737
    def ToggleCompactViewCheckbox(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1738
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1739
        Handles the event of the 'Compact view' check box.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1740
        If it's checked, show only the registers that have a description.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1741
        If not, show all the registers.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1742
        @param event: wx.EVT_CHECKBOX object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1743
        """
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1744
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1745
        # If "Compact View" Checkbox is True
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1746
        ## 'event' is argument of this method or event of checkbox.
2365
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1747
        if event == True or event.GetEventObject().GetValue():
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1748
            self.CompactFlag = True
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1749
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1750
            reg_compact_data = []
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1751
            page_row = [0, 0, 0, 0]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1752
            for index in range(4):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1753
                self.PageRange[index] = [0, 0]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1754
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1755
            for reg_row_data in self.RegMonitorData:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1756
                if reg_row_data[1] is not "":
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1757
                    # data structure for "compact view"
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1758
                    reg_compact_data.append(reg_row_data)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1759
                    # count for each register notebooks' row
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1760
                    # It compare with register's address.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1761
                    for index in range(4):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1762
                        if int('0x'+reg_row_data[0], 16) < (index+1)*1024:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1763
                            page_row[index] += 1
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1764
                            break
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1765
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1766
            # Setting tables' rows and cols, range for compact view
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1767
            for index in range(4):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1768
                self.MainRow[index] = page_row[index]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1769
                self.PageRange[index][1] = page_row[index]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1770
                for iter in range(index):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1771
                    self.PageRange[index][0] += page_row[iter]
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1772
                    self.PageRange[index][1] += page_row[iter]
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1773
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1774
            # Update table
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1775
            for index in range(4):
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1776
                self.RegisterNotebook.RegPage[index].UpdateMainTable(self.MainRow[index], self.MainCol,
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1777
                                                                      self.PageRange[index][0], self.PageRange[index][1],
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1778
                                                                      reg_compact_data)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1779
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1780
        # Compact View Checkbox is False
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1781
        else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1782
            self.CompactFlag = False
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1783
            # Setting original rows, cols and range
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1784
            self.MainRow = [512, 512, 512, 512]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1785
            self.PageRange = []
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1786
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1787
            for index in range(4):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1788
                self.PageRange.append([512*index, 512*(index+1)])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1789
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1790
            # Update table
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1791
            for index in range(4):
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1792
                self.RegisterNotebook.RegPage[index].UpdateMainTable(self.MainRow[index], self.MainCol,
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1793
                                                                      self.PageRange[index][0], self.PageRange[index][1],
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1794
                                                                      self.RegMonitorData)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1795
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1796
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1797
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1798
#                    For Register Access Notebook (divide index range)
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1799
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1800
class RegisterNotebook(wx.Notebook):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1801
    def __init__(self, parent, controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1802
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1803
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1804
        @param parent: RegisterAccessPanel object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1805
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1806
        """
2366
d635680e4c2c cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2365
diff changeset
  1807
        wx.Notebook.__init__(self, parent, id=-1)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1808
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1809
        self.parent = parent
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1810
        self.Controler = controler
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1811
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1812
        # Initialize pages
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1813
        self.RegPage = []
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1814
        for iter in range(4):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1815
            self.RegPage.append(None)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1816
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1817
        for index in range(4):
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1818
            self.RegPage[index] = RegisterNotebookPanel(self, self.Controler,
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1819
                                                    parent.MainRow[index], parent.MainCol)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1820
            self.AddPage(self.RegPage[index],
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1821
                         "0x"+"{:0>4x}".format(index*1024)+" - 0x"+"{:0>4x}".format((index+1)*1024-1))
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1822
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1823
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1824
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1825
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1826
    def OnPageChanged(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1827
        old = event.GetOldSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1828
        new = event.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1829
        sel = self.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1830
        event.Skip()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1831
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1832
    def OnPageChanging(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1833
        old = event.GetOldSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1834
        new = event.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1835
        sel = self.GetSelection()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1836
        event.Skip()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1837
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1838
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1839
# -------------------------------------------------------------------------------
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1840
#                    For Register Access Notebook Panel
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1841
#                  (Main UI : including main, sub table)
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1842
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1843
class RegisterNotebookPanel(wx.Panel):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1844
    def __init__(self, parent, controler, row, col):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1845
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1846
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1847
        @param parent: RegisterAccessPanel object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1848
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1849
        @param row, col: size of the table
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1850
    	"""
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1851
        wx.Panel.__init__(self, parent, -1)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1852
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1853
        self.parent = parent
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1854
        self.Controler = controler
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1855
        self.Row = row
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1856
        self.Col = col
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1857
        sub_row = 0
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1858
        sub_col = 4
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1859
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1860
        self.Sizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=30)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1861
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1862
        self.MainTable = RegisterMainTable(self, self.Row, self.Col, self.Controler)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1863
        self.SubTable = RegisterSubTable(self, sub_row, sub_col)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1864
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1865
        self.SubTable.CreateGrid(sub_row, sub_col)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1866
        self.SubTable.SetValue(self, [])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1867
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1868
        self.Sizer.AddMany([self.MainTable, self.SubTable])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1869
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1870
        self.SetSizer(self.Sizer)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1871
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1872
    def UpdateMainTable(self, row, col, low_index, high_index, data):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1873
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1874
        Updates main table.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1875
        It's done by deleting the main table and creating it again.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1876
        @param row, col: size of the table
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1877
        @param low_index: the lowest index of the page
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1878
        @param high_index: the highest index of the page
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1879
        @param data: data
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1880
    	"""
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1881
        self.MainTable.Destroy()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1882
        self.MainTable = RegisterMainTable(self, row, col, self.Controler)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1883
        self.Sizer.Detach(self.SubTable)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1884
        self.Sizer.AddMany([self.MainTable, self.SubTable])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1885
        self.SetSizer(self.Sizer)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1886
        self.MainTable.CreateGrid(row, col)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1887
        self.MainTable.SetValue(self, data, low_index, high_index)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1888
        self.MainTable.Update()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1889
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1890
    def UpdateSubTable(self, row, col, data):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1891
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1892
        Updates sub table.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1893
        It's done by deleting the sub table and creating it again.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1894
        @param row, col: size of the table
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1895
        @param data: data
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1896
    	"""
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1897
        self.SubTable.Destroy()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1898
        self.SubTable = RegisterSubTable(self, row, col)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1899
        self.Sizer.Detach(self.MainTable)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1900
        self.Sizer.AddMany([self.MainTable, self.SubTable])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1901
        self.Sizer.Layout()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1902
        self.SetSizer(self.Sizer)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1903
        self.SubTable.CreateGrid(row, col)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1904
        self.SubTable.SetValue(self, data)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1905
        self.SubTable.Update()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1906
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1907
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1908
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1909
#                    For Register Access Notebook Panel (Main Table)
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  1910
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1911
class RegisterMainTable(wx.grid.Grid):
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1912
    def __init__(self, parent, row, col, controler):
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1913
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1914
	    Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1915
	    @param parent: RegisterNotebook object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1916
	    @param row, col: size of the table
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1917
	    @param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1918
	    """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1919
        self.parent = parent
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1920
        self.Data = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1921
        self.Row = row
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1922
        self.Col = col
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1923
        self.Controler = controler
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1924
        self.RegisterAccessPanel = self.parent.parent.parent
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1925
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
  1926
        wx.grid.Grid.__init__(self, parent, -1, size=(820, 300),
2367
0fb54172a18b cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2366
diff changeset
  1927
                              style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1928
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1929
        for evt, mapping_method in [(gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1930
                                    (gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1931
                                    (gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnRegModifyDialog)]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1932
            self.Bind(evt, mapping_method)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1933
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1934
    def SetValue(self, parent, reg_monitor_data, low_index, high_index):
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1935
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1936
	    Set the RegMonitorData into the main table.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1937
	    @param parent: RegisterNotebook object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1938
	    @param reg_monitor_data: data
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1939
	    @param low_index: the lowest index of the page
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1940
	    @param high_index: the highest index of the page
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1941
	    """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1942
        self.RegMonitorData = reg_monitor_data
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1943
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1944
        # set label name and size
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1945
        register_maintable_label = [(0, "Description"), (1, "Dec"),
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1946
                                    (2, "Hex"), (3, "Char")]
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1947
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1948
        for (index, label) in register_maintable_label:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1949
            self.SetColLabelValue(index, label)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1950
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1951
        self.SetColSize(0, 200)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1952
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1953
        # if reg_monitor_data is 0, it is initialization of register access.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1954
        if reg_monitor_data == 0:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1955
            return 0
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1956
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1957
        # set data into UI
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1958
        row = col = 0
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1959
        for row_index in reg_monitor_data[low_index:high_index]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1960
            col = 0
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1961
            self.SetRowLabelValue(row, row_index[0])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1962
            for data_index in range(4):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1963
                self.SetCellValue(row, col, row_index[data_index+1])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1964
                self.SetCellAlignment(row, col, wx.ALIGN_CENTRE, wx.ALIGN_CENTER)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1965
                self.SetReadOnly(row, col, True)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1966
                col = col + 1
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1967
            row = row + 1
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1968
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1969
    def OnSelectCell(self, event):
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1970
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1971
	    Handles the event of the cell of the main table.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1972
	    @param event: gridlib object (left click)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1973
	    """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1974
        # if reg_monitor_data is 0, it is initialization of register access.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1975
        if self.RegMonitorData == 0:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1976
            event.Skip()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1977
            return 0
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1978
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1979
        sub_row = 0
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1980
        sub_col = 4
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1981
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1982
        address = self.GetRowLabelValue(event.GetRow())
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1983
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1984
        reg_sub_grid_data = []
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1985
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1986
        BIT_RANGE, NAME, DESCRIPTIONS = range(3)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1987
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  1988
        # Check if this register's detail description is exist or not,
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1989
        # and create data structure for the detail description table ; sub grid
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1990
        if address in self.RegisterAccessPanel.RegisterSubGridDict:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1991
            for element in self.RegisterAccessPanel.RegisterSubGridDict[address]:
2365
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  1992
                row_data = []
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1993
                row_data.append(element[BIT_RANGE])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1994
                row_data.append(element[NAME])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1995
                bin_data = "{:0>16b}".format(int(self.GetCellValue(event.GetRow(), 1)))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1996
                value_range = element[BIT_RANGE].split('-')
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1997
                value = (bin_data[8:16][::-1]+bin_data[0:8][::-1])[int(value_range[0]):(int(value_range[-1])+1)][::-1]
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1998
                row_data.append(str(int(('0b'+str(value)), 2)))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  1999
                if value in element[DESCRIPTIONS]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2000
                    row_data.append(element[DESCRIPTIONS][value])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2001
                else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2002
                    row_data.append('')
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2003
                reg_sub_grid_data.append(row_data)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2004
                sub_row = sub_row + 1
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2005
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2006
        self.parent.UpdateSubTable(sub_row, sub_col, reg_sub_grid_data)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2007
        # event.Skip() updates UI of selecting cell
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2008
        event.Skip()
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2009
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2010
    def OnRegModifyDialog(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2011
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2012
        Handle the event of the cell of the main table.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2013
        Display the window where the user modifies the value of the cell.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2014
        @param event: gridlib object (double click)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2015
	    """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2016
        # user can enter a value in case that user double-clicked 'Dec' or 'Hex' value.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2017
        if event.GetCol() == 1 or event.GetCol() == 2:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2018
            dlg = wx.TextEntryDialog(self, "Enter hex(0xnnnn) or dec(n) value",
2367
0fb54172a18b cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2366
diff changeset
  2019
                                     "Register Modify Dialog", style=wx.OK | wx.CANCEL)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2020
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2021
            # Setting value in initial dialog value
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2022
            start_value = self.GetCellValue(event.GetRow(), event.GetCol())
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2023
            dlg.SetValue(start_value)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2024
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2025
            if dlg.ShowModal() == wx.ID_OK:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2026
                try:
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2027
                    # It int(input) success, this input is dev or hex value.
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2028
                    # Otherwise, it's error, so it goes except.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2029
                    int(dlg.GetValue(), 0)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2030
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2031
                    # reg_write
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2032
                    # ex) ethercat reg_write -p 0 -t uint16 0x0000 0x0000
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2033
                    return_val = self.Controler.CommonMethod.RegWrite('0x'+self.GetRowLabelValue(event.GetRow()), dlg.GetValue())
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2034
2365
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  2035
                    if len(return_val) == 0:
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2036
                        # set dec
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2037
                        self.SetCellValue(event.GetRow(), 1, str(int(dlg.GetValue(), 0)))
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2038
                        # set hex
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2039
                        hex_data = '0x'+"{:0>4x}".format(int(dlg.GetValue(), 0))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2040
                        self.SetCellValue(event.GetRow(), 2, hex_data)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2041
                        # set char
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2042
                        char_data = ""
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2043
                        # If hex_data is been able to convert to ascii code, append ascii code.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2044
                        for iter in range(2):
2365
bc07b9910cdb cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2364
diff changeset
  2045
                            if int(hex_data[(iter+1)*2:(iter+2)*2], 16) >= 32 and int(hex_data[(iter+1)*2:(iter+2)*2], 16) <= 126:
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2046
                                char_data = char_data + chr(int(hex_data[(iter+1)*2:(iter+2)*2], 16))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2047
                            else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2048
                                char_data = char_data + "."
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2049
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2050
                        self.SetCellValue(event.GetRow(), 3, char_data)
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2051
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2052
                    else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2053
                        self.Controler.CommonMethod.CreateErrorDialog('You can\'t modify it. This register is read-only or it\'s not connected.')
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2054
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2055
                except ValueError:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2056
                    self.Controler.CommonMethod.CreateErrorDialog('You entered wrong value. You can enter dec or hex value only.')
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2057
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2058
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  2059
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2060
#                    For Register Access Notebook Panel (Sub Table)
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  2061
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2062
class RegisterSubTable(wx.grid.Grid):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2063
    def __init__(self, parent, row, col):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2064
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2065
    	 Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2066
    	 @param parent: RegisterNotebook object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2067
    	 @param row, col: size of the table
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2068
    	"""
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2069
        self.parent = parent
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2070
        self.Data = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2071
        self.Row = row
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2072
        self.Col = col
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2073
2363
9c7da6ff6a34 cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2361
diff changeset
  2074
        wx.grid.Grid.__init__(self, parent, -1, size=(820, 150),
2367
0fb54172a18b cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2366
diff changeset
  2075
                              style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2076
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2077
    def SetValue(self, parent, data):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2078
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2079
	    Set the data into the subtable.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2080
	    @param parent: RegisterNotebook object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2081
	    @param data: data
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2082
	    """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2083
        # lset label name and size
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2084
        Register_SubTable_Label = [(0, "Bits"), (1, "Name"),
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2085
                                    (2, "Value"), (3, "Enum")]
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2086
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2087
        for (index, label) in Register_SubTable_Label:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2088
            self.SetColLabelValue(index, label)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2089
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2090
        self.SetColSize(1, 200)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2091
        self.SetColSize(3, 200)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2092
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2093
        # set data into table
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2094
        row = col = 0
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2095
        for rowData in data:
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2096
            col = 0
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2097
            for element in rowData:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2098
                self.SetCellValue(row, col, element)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2099
                self.SetCellAlignment(row, col, wx.ALIGN_CENTRE, wx.ALIGN_CENTER)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2100
                self.SetReadOnly(row, col, True)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2101
                col = col + 1
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2102
            row = row + 1
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2103
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2104
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  2105
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2106
#                    For Master State Panel
2356
c26e0c66d8d5 cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2355
diff changeset
  2107
# -------------------------------------------------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2108
class MasterStatePanelClass(wx.Panel):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2109
    def __init__(self, parent, controler):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2110
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2111
        Constructor
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2112
        @param parent: wx.ScrollWindow object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2113
        @Param controler: _EthercatSlaveCTN class in EthercatSlave.py
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2114
        """
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2115
        wx.Panel.__init__(self, parent, -1, (0, 0),
2366
d635680e4c2c cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2365
diff changeset
  2116
                          size=wx.DefaultSize, style=wx.SUNKEN_BORDER)
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2117
        self.Controler = controler
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2118
        self.parent = parent
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2119
        self.StaticBox = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2120
        self.StaticText = {}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2121
        self.TextCtrl = {}
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2122
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2123
        # ----------------------- Main Sizer and Update Button --------------------------------------------
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2124
        self.MasterStateSizer = {"main" : wx.BoxSizer(wx.VERTICAL)}
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2125
        for key, attr in [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2126
            ("innerMain",           [1, 10, 2, 10]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2127
            ("innerTopHalf",        [2, 10, 1, 10]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2128
            ("innerBottomHalf",     [2, 10, 1, 10]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2129
            ("innerMasterState",    [2, 10, 3, 10]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2130
            ("innerDeviceInfo",     [4, 10, 3, 10]),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2131
            ("innerFrameInfo",      [4, 10, 5, 10])]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2132
            self.MasterStateSizer[key] = wx.FlexGridSizer(cols=attr[0], hgap=attr[1], rows=attr[2], vgap=attr[3])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2133
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2134
        self.UpdateButton = wx.Button(self, label=_('Update'))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2135
        self.UpdateButton.Bind(wx.EVT_BUTTON, self.OnButtonClick)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2136
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2137
        for key, label in [
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2138
            ('masterState', 'EtherCAT Master State'),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2139
            ('deviceInfo', 'Ethernet Network Card Information'),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2140
            ('frameInfo', 'Network Frame Information')]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2141
            self.StaticBox[key] = wx.StaticBox(self, label=_(label))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2142
            self.MasterStateSizer[key] = wx.StaticBoxSizer(self.StaticBox[key])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2143
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2144
        # ----------------------- Master State -----------------------------------------------------------
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2145
        for key, label in [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2146
            ('Phase', 'Phase:'),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2147
            ('Active', 'Active:'),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2148
            ('Slaves', 'Slave Count:')]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2149
            self.StaticText[key] = wx.StaticText(self, label=_(label))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2150
            self.TextCtrl[key] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY)
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2151
            self.MasterStateSizer['innerMasterState'].AddMany([self.StaticText[key], self.TextCtrl[key]])
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2152
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2153
        self.MasterStateSizer['masterState'].AddSizer(self.MasterStateSizer['innerMasterState'])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2154
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2155
        # ----------------------- Ethernet Network Card Information ---------------------------------------
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2156
        for key, label in [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2157
            ('Main', 'MAC Address:'),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2158
            ('Link', 'Link State:'),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2159
            ('Tx frames', 'Tx Frames:'),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2160
            ('Rx frames', 'Rx Frames:'),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2161
            ('Lost frames', 'Lost Frames:')]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2162
            self.StaticText[key] = wx.StaticText(self, label=_(label))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2163
            self.TextCtrl[key] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2164
            self.MasterStateSizer['innerDeviceInfo'].AddMany([self.StaticText[key], self.TextCtrl[key]])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2165
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2166
        self.MasterStateSizer['deviceInfo'].AddSizer(self.MasterStateSizer['innerDeviceInfo'])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2167
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2168
        # ----------------------- Network Frame Information -----------------------------------------------
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2169
        for key, label in [
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2170
            ('Tx frame rate [1/s]', 'Tx Frame Rate [1/s]:'),
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2171
            ('Rx frame rate [1/s]', 'Tx Rate [kByte/s]:'),
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2172
            ('Loss rate [1/s]', 'Loss Rate [1/s]:'),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2173
            ('Frame loss [%]', 'Frame Loss [%]:')]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2174
            self.StaticText[key] = wx.StaticText(self, label=_(label))
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2175
            self.MasterStateSizer['innerFrameInfo'].Add(self.StaticText[key])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2176
            self.TextCtrl[key] = {}
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2177
            for index in ['0', '1', '2']:
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2178
                self.TextCtrl[key][index] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2179
                self.MasterStateSizer['innerFrameInfo'].Add(self.TextCtrl[key][index])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2180
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2181
        self.MasterStateSizer['frameInfo'].AddSizer(self.MasterStateSizer['innerFrameInfo'])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2182
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2183
        # --------------------------------- Main Sizer ----------------------------------------------------
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2184
        for key, sub, in [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2185
            ('innerTopHalf', [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2186
                    'masterState', 'deviceInfo']),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2187
            ('innerBottomHalf', [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2188
                    'frameInfo']),
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2189
            ('innerMain', [
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2190
                    'innerTopHalf', 'innerBottomHalf'])]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2191
            for key2 in sub:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2192
                self.MasterStateSizer[key].AddSizer(self.MasterStateSizer[key2])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2193
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2194
        self.MasterStateSizer['main'].AddSizer(self.UpdateButton)
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2195
        self.MasterStateSizer['main'].AddSizer(self.MasterStateSizer['innerMain'])
2355
fec77f2b9e07 cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2354
diff changeset
  2196
2354
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2197
        self.SetSizer(self.MasterStateSizer['main'])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2198
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2199
    def OnButtonClick(self, event):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2200
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2201
        Handle the event of the 'Update' button.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2202
        Update the data of the master state.
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2203
        @param event: wx.EVT_BUTTON object
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2204
        """
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2205
        if self.Controler.GetCTRoot()._connector is not None:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2206
            self.MasterState = self.Controler.CommonMethod.GetMasterState()
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2207
            # Update each TextCtrl
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2208
            if self.MasterState:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2209
                for key in self.TextCtrl:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2210
                    if isinstance(self.TextCtrl[key], dict):
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2211
                        for index in self.TextCtrl[key]:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2212
                            self.TextCtrl[key][index].SetValue(self.MasterState[key][int(index)])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2213
                    else:
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2214
                        self.TextCtrl[key].SetValue(self.MasterState[key][0])
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2215
        else :
9460872f1440 convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2353
diff changeset
  2216
            self.Controler.CommonMethod.CreateErrorDialog('PLC not connected!')