author | Donggu Kang <dgkang@higenmotor.com> |
Thu, 22 Dec 2011 14:44:58 +0900 | |
changeset 2024 | 08d67a0af2c1 |
parent 2022 | c2295d311402 |
child 2023 | f9f884cf3033 |
permissions | -rw-r--r-- |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1 |
import wx |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
3 |
from controls import CustomGrid, CustomTable, EditorPanel |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
4 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
5 |
[ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
6 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
7 |
def AppendMenu(parent, help, id, kind, text): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
8 |
if wx.VERSION >= (2, 6, 0): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
9 |
parent.Append(help=help, id=id, kind=kind, text=text) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
10 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
11 |
parent.Append(helpString=help, id=id, kind=kind, item=text) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
12 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
13 |
[ID_SLAVETYPECHOICEDIALOG, ID_SLAVETYPECHOICEDIALOGSTATICTEXT1, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
14 |
ID_SLAVETYPECHOICEDIALOGSLAVETYPESLIBRARY |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
15 |
] = [wx.NewId() for _init_ctrls in range(3)] |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
16 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
17 |
class SlaveTypeChoiceDialog(wx.Dialog): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
18 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
19 |
if wx.VERSION < (2, 6, 0): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
20 |
def Bind(self, event, function, id = None): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
21 |
if id is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
22 |
event(self, id, function) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
23 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
24 |
event(self, function) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
25 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
26 |
def _init_coll_flexGridSizer1_Items(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
27 |
parent.AddWindow(self.staticText1, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
28 |
parent.AddWindow(self.SlaveTypesLibrary, 0, border=20, flag=wx.GROW|wx.LEFT|wx.RIGHT) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
29 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
30 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
31 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
32 |
parent.AddGrowableCol(0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
33 |
parent.AddGrowableRow(1) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
34 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
35 |
def _init_sizers(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
36 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
37 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
38 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
39 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
40 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
41 |
self.SetSizer(self.flexGridSizer1) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
42 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
43 |
def _init_ctrls(self, prnt): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
44 |
wx.Dialog.__init__(self, id=ID_SLAVETYPECHOICEDIALOG, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
45 |
name='SlaveTypeChoiceDialog', parent=prnt, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
46 |
size=wx.Size(600, 400), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
47 |
title=_('Browse slave types library')) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
48 |
self.SetClientSize(wx.Size(600, 400)) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
49 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
50 |
self.staticText1 = wx.StaticText(id=ID_SLAVETYPECHOICEDIALOGSTATICTEXT1, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
51 |
label=_('Choose a slave type:'), name='staticText1', parent=self, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
52 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
53 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
54 |
self.SlaveTypesLibrary = wx.TreeCtrl(id=ID_SLAVETYPECHOICEDIALOGSLAVETYPESLIBRARY, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
55 |
name='TypeTree', parent=self, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
56 |
size=wx.Size(0, 0), style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_HIDE_ROOT|wx.TR_LINES_AT_ROOT) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
57 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
58 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
59 |
if wx.VERSION >= (2, 5, 0): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
60 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
61 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
62 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
63 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
64 |
self._init_sizers() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
65 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
66 |
def __init__(self, parent, controler, default=None): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
67 |
self._init_ctrls(parent) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
68 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
69 |
slaves_types = controler.GetSlaveTypesLibrary() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
70 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
71 |
root = self.SlaveTypesLibrary.AddRoot("") |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
72 |
self.GenerateSlaveTypesLibraryTreeBranch(root, slaves_types, default) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
73 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
74 |
def GenerateSlaveTypesLibraryTreeBranch(self, root, children, default): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
75 |
for infos in children: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
76 |
item = self.SlaveTypesLibrary.AppendItem(root, infos["name"]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
77 |
if infos["type"] == ETHERCAT_DEVICE: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
78 |
self.SlaveTypesLibrary.SetPyData(item, infos["infos"]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
79 |
if infos["infos"] == default: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
80 |
self.SlaveTypesLibrary.SelectItem(item) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
81 |
self.SlaveTypesLibrary.EnsureVisible(item) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
82 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
83 |
self.GenerateSlaveTypesLibraryTreeBranch(item, infos["children"], default) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
84 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
85 |
def GetType(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
86 |
selected = self.SlaveTypesLibrary.GetSelection() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
87 |
return self.SlaveTypesLibrary.GetPyData(selected) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
88 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
89 |
def OnOK(self, event): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
90 |
selected = self.SlaveTypesLibrary.GetSelection() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
91 |
if not selected.IsOk() or self.SlaveTypesLibrary.GetPyData(selected) is None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
92 |
message = wx.MessageDialog(self, _("No valid slave type selected!"), _("Error"), wx.OK|wx.ICON_ERROR) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
93 |
message.ShowModal() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
94 |
message.Destroy() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
95 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
96 |
self.EndModal(wx.ID_OK) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
97 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
98 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
99 |
def GetPDOsTableColnames(): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
100 |
_ = lambda x : x |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
101 |
return ["#", _("Index"), _("Name"), _("Type")] |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
102 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
103 |
def GetVariablesTableColnames(): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
104 |
_ = lambda x : x |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
105 |
return ["#", _("Index"), _("SubIndex"), _("Name"), _("Type"), _("PDO")] |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
106 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
107 |
class PDOsTable(CustomTable): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
108 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
109 |
def GetValue(self, row, col): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
110 |
if row < self.GetNumberRows(): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
111 |
if col == 0: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
112 |
return row + 1 |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
113 |
colname = self.GetColLabelValue(col, False) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
114 |
value = self.data[row].get(colname, "") |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
115 |
if colname == "Type": |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
116 |
value = _(value) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
117 |
return value |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
118 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
119 |
class VariablesTable(CustomTable): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
120 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
121 |
def GetValue(self, row, col): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
122 |
if row < self.GetNumberRows(): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
123 |
if col == 0: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
124 |
return row + 1 |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
125 |
return self.data[row].get(self.GetColLabelValue(col, False), "") |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
126 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
127 |
[ID_SLAVEPANEL, ID_SLAVEPANELTYPELABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
128 |
ID_SLAVEPANELTYPE, ID_SLAVEPANELTYPEBROWSE, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
129 |
ID_SLAVEPANELALIASLABEL, ID_SLAVEPANELALIAS, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
130 |
ID_SLAVEPANELPOSLABEL, ID_SLAVEPANELPOS, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
131 |
ID_SLAVEPANELSLAVEINFOSSTATICBOX, ID_SLAVEPANELVENDORLABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
132 |
ID_SLAVEPANELVENDOR, ID_SLAVEPANELPRODUCTCODELABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
133 |
ID_SLAVEPANELPRODUCTCODE, ID_SLAVEPANELREVISIONNUMBERLABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
134 |
ID_SLAVEPANELREVISIONNUMBER, ID_SLAVEPANELPHYSICSLABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
135 |
ID_SLAVEPANELPHYSICS, ID_SLAVEPANELPDOSLABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
136 |
ID_SLAVEPANELPDOSGRID, ID_SLAVEPANELVARIABLESLABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
137 |
ID_SLAVEPANELVARIABLESGRID, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
138 |
] = [wx.NewId() for _init_ctrls in range(21)] |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
139 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
140 |
class SlavePanel(wx.Panel): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
141 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
142 |
if wx.VERSION < (2, 6, 0): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
143 |
def Bind(self, event, function, id = None): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
144 |
if id is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
145 |
event(self, id, function) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
146 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
147 |
event(self, function) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
148 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
149 |
def _init_coll_MainSizer_Items(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
150 |
parent.AddSizer(self.PositionSizer, 0, border=5, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
151 |
parent.AddSizer(self.SlaveInfosBoxSizer, 0, border=5, flag=wx.GROW|wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
152 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
153 |
def _init_coll_MainSizer_Growables(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
154 |
parent.AddGrowableCol(0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
155 |
parent.AddGrowableRow(1) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
156 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
157 |
def _init_coll_PositionSizer_Items(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
158 |
parent.AddWindow(self.TypeLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
159 |
parent.AddSizer(self.TypeSizer, 0, border=0, flag=wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
160 |
parent.AddWindow(self.AliasLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
161 |
parent.AddWindow(self.Alias, 0, border=0, flag=wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
162 |
parent.AddWindow(self.PosLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
163 |
parent.AddWindow(self.Pos, 0, border=0, flag=wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
164 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
165 |
def _init_coll_PositionSizer_Growables(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
166 |
parent.AddGrowableCol(1) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
167 |
parent.AddGrowableCol(3) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
168 |
parent.AddGrowableCol(5) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
169 |
parent.AddGrowableRow(0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
170 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
171 |
def _init_coll_TypeSizer_Items(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
172 |
parent.AddWindow(self.Type, 1, border=0, flag=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
173 |
parent.AddWindow(self.TypeBrowse, 0, border=0, flag=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
174 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
175 |
def _init_coll_SlaveInfosBoxSizer_Items(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
176 |
parent.AddSizer(self.SlaveInfosSizer, 1, border=5, flag=wx.GROW|wx.ALL) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
177 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
178 |
def _init_coll_SlaveInfosSizer_Items(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
179 |
parent.AddSizer(self.SlaveInfosDetailsSizer, 0, border=0, flag=wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
180 |
parent.AddWindow(self.PDOsLabel, 0, border=0, flag=wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
181 |
parent.AddWindow(self.PDOsGrid, 0, border=0, flag=wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
182 |
parent.AddWindow(self.VariablesLabel, 0, border=0, flag=wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
183 |
parent.AddWindow(self.VariablesGrid, 0, border=0, flag=wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
184 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
185 |
def _init_coll_SlaveInfosSizer_Growables(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
186 |
parent.AddGrowableCol(0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
187 |
parent.AddGrowableRow(2) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
188 |
parent.AddGrowableRow(4) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
189 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
190 |
def _init_coll_SlaveInfosDetailsSizer_Items(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
191 |
parent.AddWindow(self.VendorLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
192 |
parent.AddWindow(self.Vendor, 0, border=0, flag=wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
193 |
parent.AddWindow(self.ProductCodeLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
194 |
parent.AddWindow(self.ProductCode, 0, border=0, flag=wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
195 |
parent.AddWindow(self.RevisionNumberLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
196 |
parent.AddWindow(self.RevisionNumber, 0, border=0, flag=wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
197 |
parent.AddWindow(self.PhysicsLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
198 |
parent.AddWindow(self.Physics, 0, border=0, flag=wx.GROW) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
199 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
200 |
def _init_coll_SlaveInfosDetailsSizer_Growables(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
201 |
parent.AddGrowableCol(1) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
202 |
parent.AddGrowableCol(3) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
203 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
204 |
def _init_sizers(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
205 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
206 |
self.PositionSizer = wx.FlexGridSizer(cols=6, hgap=5, rows=1, vgap=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
207 |
self.TypeSizer = wx.BoxSizer(wx.HORIZONTAL) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
208 |
self.SlaveInfosBoxSizer = wx.StaticBoxSizer(self.SlaveInfosStaticBox, wx.VERTICAL) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
209 |
self.SlaveInfosSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
210 |
self.SlaveInfosDetailsSizer = wx.FlexGridSizer(cols=4, hgap=5, rows=2, vgap=5) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
211 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
212 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
213 |
self._init_coll_MainSizer_Items(self.MainSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
214 |
self._init_coll_PositionSizer_Growables(self.PositionSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
215 |
self._init_coll_PositionSizer_Items(self.PositionSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
216 |
self._init_coll_TypeSizer_Items(self.TypeSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
217 |
self._init_coll_SlaveInfosBoxSizer_Items(self.SlaveInfosBoxSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
218 |
self._init_coll_SlaveInfosSizer_Growables(self.SlaveInfosSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
219 |
self._init_coll_SlaveInfosSizer_Items(self.SlaveInfosSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
220 |
self._init_coll_SlaveInfosDetailsSizer_Growables(self.SlaveInfosDetailsSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
221 |
self._init_coll_SlaveInfosDetailsSizer_Items(self.SlaveInfosDetailsSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
222 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
223 |
self.SetSizer(self.MainSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
224 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
225 |
def _init_ctrls(self, prnt): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
226 |
wx.Panel.__init__(self, id=ID_SLAVEPANEL, name='SlavePanel', parent=prnt, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
227 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
228 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
229 |
self.TypeLabel = wx.StaticText(id=ID_SLAVEPANELTYPELABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
230 |
label=_('Type:'), name='TypeLabel', parent=self, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
231 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
232 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
233 |
self.Type = wx.TextCtrl(id=ID_SLAVEPANELTYPE, value='', |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
234 |
name='Type', parent=self, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
235 |
size=wx.Size(0, 24), style=wx.TE_READONLY) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
236 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
237 |
self.TypeBrowse = wx.Button(id=ID_SLAVEPANELTYPEBROWSE, label='...', |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
238 |
name='TypeBrowse', parent=self, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
239 |
size=wx.Size(30, 24), style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
240 |
self.Bind(wx.EVT_BUTTON, self.OnTypeBrowseClick, id=ID_SLAVEPANELTYPEBROWSE) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
241 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
242 |
self.AliasLabel = wx.StaticText(id=ID_SLAVEPANELALIASLABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
243 |
label=_('Alias:'), name='AliasLabel', parent=self, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
244 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
245 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
246 |
self.Alias = wx.SpinCtrl(id=ID_SLAVEPANELALIAS, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
247 |
name='Alias', parent=self, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
248 |
size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0, max=0xffff) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
249 |
self.Bind(wx.EVT_SPINCTRL, self.OnAliasChanged, id=ID_SLAVEPANELALIAS) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
250 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
251 |
self.PosLabel = wx.StaticText(id=ID_SLAVEPANELPOSLABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
252 |
label=_('Position:'), name='PositionLabel', parent=self, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
253 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
254 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
255 |
self.Pos = wx.SpinCtrl(id=ID_SLAVEPANELPOS, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
256 |
name='Pos', parent=self, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
257 |
size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0, max=0xffff) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
258 |
self.Bind(wx.EVT_SPINCTRL, self.OnPositionChanged, id=ID_SLAVEPANELPOS) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
259 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
260 |
self.SlaveInfosStaticBox = wx.StaticBox(id=ID_SLAVEPANELSLAVEINFOSSTATICBOX, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
261 |
label=_('Slave infos:'), name='SlaveInfosStaticBox', parent=self, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
262 |
pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
263 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
264 |
self.VendorLabel = wx.StaticText(id=ID_SLAVEPANELVENDORLABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
265 |
label=_('Vendor:'), name='VendorLabel', parent=self, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
266 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
267 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
268 |
self.Vendor = wx.TextCtrl(id=ID_SLAVEPANELVENDOR, value='', |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
269 |
name='Vendor', parent=self, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
270 |
size=wx.Size(0, 24), style=wx.TE_READONLY) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
271 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
272 |
self.ProductCodeLabel = wx.StaticText(id=ID_SLAVEPANELPRODUCTCODELABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
273 |
label=_('Product code:'), name='ProductCodeLabel', parent=self, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
274 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
275 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
276 |
self.ProductCode = wx.TextCtrl(id=ID_SLAVEPANELPRODUCTCODE, value='', |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
277 |
name='ProductCode', parent=self, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
278 |
size=wx.Size(0, 24), style=wx.TE_READONLY) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
279 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
280 |
self.RevisionNumberLabel = wx.StaticText(id=ID_SLAVEPANELREVISIONNUMBERLABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
281 |
label=_('Revision number:'), name='RevisionNumberLabel', parent=self, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
282 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
283 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
284 |
self.RevisionNumber = wx.TextCtrl(id=ID_SLAVEPANELREVISIONNUMBER, value='', |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
285 |
name='RevisionNumber', parent=self, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
286 |
size=wx.Size(0, 24), style=wx.TE_READONLY) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
287 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
288 |
self.PhysicsLabel = wx.StaticText(id=ID_SLAVEPANELPHYSICSLABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
289 |
label=_('Physics:'), name='PhysicsLabel', parent=self, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
290 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
291 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
292 |
self.Physics = wx.TextCtrl(id=ID_SLAVEPANELPHYSICS, value='', |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
293 |
name='Physics', parent=self, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
294 |
size=wx.Size(0, 24), style=wx.TE_READONLY) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
295 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
296 |
self.PDOsLabel = wx.StaticText(id=ID_SLAVEPANELPDOSLABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
297 |
label=_('PDO entries:'), name='PDOsLabel', parent=self, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
298 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
299 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
300 |
self.PDOsGrid = CustomGrid(id=ID_SLAVEPANELPDOSGRID, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
301 |
name='PDOsGrid', parent=self, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
302 |
size=wx.Size(0, 0), style=wx.VSCROLL) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
303 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
304 |
self.VariablesLabel = wx.StaticText(id=ID_SLAVEPANELVARIABLESLABEL, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
305 |
label=_('Variable entries:'), name='VariablesLabel', parent=self, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
306 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
307 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
308 |
self.VariablesGrid = CustomGrid(id=ID_SLAVEPANELPDOSGRID, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
309 |
name='PDOsGrid', parent=self, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
310 |
size=wx.Size(0, 0), style=wx.VSCROLL) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
311 |
if wx.VERSION >= (2, 5, 0): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
312 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnVariablesGridCellLeftClick) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
313 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
314 |
wx.grid.EVT_GRID_CELL_LEFT_CLICK(self.VariablesGrid, self.OnVariablesGridCellLeftClick) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
315 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
316 |
self._init_sizers() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
317 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
318 |
def __init__(self, parent, controler, window, slave): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
319 |
self._init_ctrls(parent) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
320 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
321 |
self.Controler = controler |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
322 |
self.ParentWindow = window |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
323 |
self.Slave = slave |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
324 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
325 |
self.PDOsTable = PDOsTable(self, [], GetPDOsTableColnames()) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
326 |
self.PDOsGrid.SetTable(self.PDOsTable) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
327 |
self.PDOsGridColAlignements = [wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_LEFT] |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
328 |
self.PDOsGridColSizes = [40, 100, 150, 150] |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
329 |
self.PDOsGrid.SetRowLabelSize(0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
330 |
for col in range(self.PDOsTable.GetNumberCols()): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
331 |
attr = wx.grid.GridCellAttr() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
332 |
attr.SetAlignment(self.PDOsGridColAlignements[col], wx.ALIGN_CENTRE) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
333 |
self.PDOsGrid.SetColAttr(col, attr) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
334 |
self.PDOsGrid.SetColMinimalWidth(col, self.PDOsGridColSizes[col]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
335 |
self.PDOsGrid.AutoSizeColumn(col, False) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
336 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
337 |
self.VariablesTable = VariablesTable(self, [], GetVariablesTableColnames()) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
338 |
self.VariablesGrid.SetTable(self.VariablesTable) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
339 |
self.VariablesGridColAlignements = [wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT] |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
340 |
self.VariablesGridColSizes = [40, 100, 100, 150, 150, 100] |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
341 |
self.VariablesGrid.SetRowLabelSize(0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
342 |
for col in range(self.VariablesTable.GetNumberCols()): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
343 |
attr = wx.grid.GridCellAttr() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
344 |
attr.SetAlignment(self.VariablesGridColAlignements[col], wx.ALIGN_CENTRE) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
345 |
self.VariablesGrid.SetColAttr(col, attr) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
346 |
self.VariablesGrid.SetColMinimalWidth(col, self.VariablesGridColSizes[col]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
347 |
self.VariablesGrid.AutoSizeColumn(col, False) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
348 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
349 |
self.RefreshView() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
350 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
351 |
def GetSlaveTitle(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
352 |
type_infos = self.Controler.GetSlaveType(self.Slave) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
353 |
return "%s (%d:%d)" % (type_infos["device_type"], self.Slave[0], self.Slave[1]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
354 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
355 |
def GetSlave(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
356 |
return self.Slave |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
357 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
358 |
def SetSlave(self, slave): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
359 |
if self.Slave != slave: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
360 |
self.Slave = slave |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
361 |
self.RefreshView() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
362 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
363 |
def RefreshView(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
364 |
self.Alias.SetValue(self.Slave[0]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
365 |
self.Pos.SetValue(self.Slave[1]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
366 |
slave_infos = self.Controler.GetSlaveInfos(self.Slave) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
367 |
if slave_infos is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
368 |
self.Type.SetValue(slave_infos["device_type"]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
369 |
self.Vendor.SetValue(slave_infos["vendor"]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
370 |
self.ProductCode.SetValue(slave_infos["product_code"]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
371 |
self.RevisionNumber.SetValue(slave_infos["revision_number"]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
372 |
self.Physics.SetValue(slave_infos["physics"]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
373 |
self.PDOsTable.SetData(slave_infos["pdos"]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
374 |
self.PDOsTable.ResetView(self.PDOsGrid) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
375 |
self.VariablesTable.SetData(slave_infos["variables"]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
376 |
self.VariablesTable.ResetView(self.VariablesGrid) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
377 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
378 |
type_infos = self.Controler.GetSlaveType(self.Slave) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
379 |
self.Type.SetValue(type_infos["device_type"]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
380 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
381 |
def OnAliasChanged(self, event): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
382 |
alias = self.Alias.GetValue() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
383 |
if alias != self.Slave[0]: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
384 |
result = self.Controler.SetSlavePos(self.Slave[:2], alias = alias) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
385 |
if result is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
386 |
message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
387 |
message.ShowModal() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
388 |
message.Destroy() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
389 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
390 |
wx.CallAfter(self.ParentWindow.RefreshView, (alias, self.Slave[1])) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
391 |
wx.CallAfter(self.ParentWindow.RefreshParentWindow) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
392 |
event.Skip() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
393 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
394 |
def OnPositionChanged(self, event): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
395 |
position = self.Pos.GetValue() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
396 |
if position != self.Slave[1]: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
397 |
result = self.Controler.SetSlavePos(self.Slave, position = position) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
398 |
if result is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
399 |
message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
400 |
message.ShowModal() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
401 |
message.Destroy() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
402 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
403 |
wx.CallAfter(self.ParentWindow.RefreshView, (self.Slave[0], position)) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
404 |
wx.CallAfter(self.ParentWindow.RefreshParentWindow) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
405 |
event.Skip() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
406 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
407 |
def OnTypeBrowseClick(self, event): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
408 |
dialog = SlaveTypeChoiceDialog(self, self.Controler, self.Controler.GetSlaveType(self.Slave)) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
409 |
if dialog.ShowModal() == wx.ID_OK: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
410 |
result = self.Controler.SetSlaveType(self.Slave, dialog.GetType()) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
411 |
if result is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
412 |
message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
413 |
message.ShowModal() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
414 |
message.Destroy() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
415 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
416 |
wx.CallAfter(self.RefreshView) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
417 |
wx.CallAfter(self.ParentWindow.RefreshSlaveNodesTitles) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
418 |
wx.CallAfter(self.ParentWindow.RefreshParentWindow) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
419 |
dialog.Destroy() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
420 |
event.Skip() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
421 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
422 |
def OnVariablesGridCellLeftClick(self, event): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
423 |
if event.GetCol() == 0: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
424 |
row = event.GetRow() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
425 |
data_type = self.VariablesTable.GetValueByName(row, "Type") |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
426 |
var_name = self.VariablesTable.GetValueByName(row, "Name") |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
427 |
entry_index = self.Controler.ExtractHexDecValue(self.VariablesTable.GetValueByName(row, "Index")) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
428 |
entry_subindex = self.VariablesTable.GetValueByName(row, "SubIndex") |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
429 |
pdo_index = self.VariablesTable.GetValueByName(row, "PDO") |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
430 |
for pdo_row in xrange(self.PDOsTable.GetNumberRows()): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
431 |
if self.PDOsTable.GetValueByName(row, "Index") == pdo_index: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
432 |
if self.PDOsTable.GetValueByName(row, "Type") == "Transmit": |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
433 |
dir = "%I" |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
434 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
435 |
dir = "%Q" |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
436 |
break |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
437 |
location = "%s%s" % (dir, self.Controler.GetSizeOfType(data_type)) + \ |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
438 |
".".join(map(lambda x:str(x), self.Controler.GetCurrentLocation() + self.Slave + (entry_index, entry_subindex))) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
439 |
data = wx.TextDataObject(str((location, "location", data_type, var_name, ""))) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
440 |
dragSource = wx.DropSource(self.VariablesGrid) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
441 |
dragSource.SetData(data) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
442 |
dragSource.DoDragDrop() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
443 |
event.Skip() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
444 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
445 |
[ID_CONFIGEDITOR, ID_CONFIGEDITORADDSLAVEBUTTON, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
446 |
ID_CONFIGEDITORDELETESLAVEBUTTON, ID_CONFIGEDITORSLAVENODES, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
447 |
] = [wx.NewId() for _init_ctrls in range(4)] |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
448 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
449 |
class ConfigEditor(EditorPanel): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
450 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
451 |
ID = ID_CONFIGEDITOR |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
452 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
453 |
def _init_coll_MainSizer_Items(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
454 |
parent.AddSizer(self.ButtonSizer, 0, border=5, flag=wx.ALIGN_RIGHT|wx.TOP|wx.LEFT|wx.RIGHT) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
455 |
parent.AddWindow(self.SlaveNodes, 0, border=5, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
456 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
457 |
def _init_coll_MainSizer_Growables(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
458 |
parent.AddGrowableCol(0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
459 |
parent.AddGrowableRow(1) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
460 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
461 |
def _init_coll_ButtonSizer_Items(self, parent): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
462 |
parent.AddWindow(self.AddSlaveButton, 0, border=5, flag=wx.RIGHT) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
463 |
parent.AddWindow(self.DeleteSlaveButton, 0, border=5, flag=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
464 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
465 |
def _init_sizers(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
466 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
467 |
self.ButtonSizer = wx.BoxSizer(wx.HORIZONTAL) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
468 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
469 |
self._init_coll_MainSizer_Items(self.MainSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
470 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
471 |
self._init_coll_ButtonSizer_Items(self.ButtonSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
472 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
473 |
self.Editor.SetSizer(self.MainSizer) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
474 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
475 |
def _init_Editor(self, prnt): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
476 |
self.Editor = wx.Panel(id=-1, parent=prnt, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
477 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
478 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
479 |
self.AddSlaveButton = wx.Button(id=ID_CONFIGEDITORADDSLAVEBUTTON, label=_('Add slave'), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
480 |
name='AddSlaveButton', parent=self.Editor, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
481 |
size=wx.DefaultSize, style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
482 |
self.Bind(wx.EVT_BUTTON, self.OnAddSlaveButtonClick, id=ID_CONFIGEDITORADDSLAVEBUTTON) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
483 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
484 |
self.DeleteSlaveButton = wx.Button(id=ID_CONFIGEDITORDELETESLAVEBUTTON, label=_('Delete slave'), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
485 |
name='DeleteSlaveButton', parent=self.Editor, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
486 |
size=wx.DefaultSize, style=0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
487 |
self.Bind(wx.EVT_BUTTON, self.OnDeleteSlaveButtonClick, id=ID_CONFIGEDITORDELETESLAVEBUTTON) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
488 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
489 |
self.SlaveNodes = wx.Notebook(id=ID_CONFIGEDITORSLAVENODES, |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
490 |
name='SlaveNodes', parent=self.Editor, pos=wx.Point(0, 0), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
491 |
size=wx.Size(0, 0), style=wx.NB_LEFT) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
492 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
493 |
self._init_sizers() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
494 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
495 |
def __init__(self, parent, controler, window): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
496 |
EditorPanel.__init__(self, parent, "", window, controler) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
497 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
498 |
img = wx.Bitmap(self.Controler.GetIconPath("Cfile.png"), wx.BITMAP_TYPE_PNG).ConvertToImage() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
499 |
self.SetIcon(wx.BitmapFromImage(img.Rescale(16, 16))) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
500 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
501 |
def GetTitle(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
502 |
filename = self.Controler.GetFilename() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
503 |
if not self.Controler.ConfigIsSaved(): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
504 |
return "~%s~" % filename |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
505 |
return filename |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
506 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
507 |
def GetBufferState(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
508 |
return self.Controler.GetBufferState() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
509 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
510 |
def Undo(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
511 |
self.Controler.LoadPrevious() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
512 |
self.RefreshView() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
513 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
514 |
def Redo(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
515 |
self.Controler.LoadNext() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
516 |
self.RefreshView() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
517 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
518 |
def RefreshView(self, slave_pos=None): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
519 |
slaves = self.Controler.GetSlaves() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
520 |
for i, slave in enumerate(slaves): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
521 |
if i < self.SlaveNodes.GetPageCount(): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
522 |
panel = self.SlaveNodes.GetPage(i) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
523 |
panel.SetSlave(slave) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
524 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
525 |
panel = SlavePanel(self.SlaveNodes, self.Controler, self, slave) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
526 |
self.SlaveNodes.AddPage(panel, "") |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
527 |
while self.SlaveNodes.GetPageCount() > len(slaves): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
528 |
self.SlaveNodes.RemovePage(len(slaves)) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
529 |
self.RefreshSlaveNodesTitles() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
530 |
self.RefreshButtons() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
531 |
if slave_pos is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
532 |
self.SelectSlave(slave_pos) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
533 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
534 |
def RefreshParentWindow(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
535 |
self.ParentWindow.RefreshTitle() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
536 |
self.ParentWindow.RefreshFileMenu() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
537 |
self.ParentWindow.RefreshEditMenu() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
538 |
self.ParentWindow.RefreshPageTitles() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
539 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
540 |
def RefreshSlaveNodesTitles(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
541 |
for idx in xrange(self.SlaveNodes.GetPageCount()): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
542 |
panel = self.SlaveNodes.GetPage(idx) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
543 |
self.SlaveNodes.SetPageText(idx, panel.GetSlaveTitle()) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
544 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
545 |
def RefreshButtons(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
546 |
self.DeleteSlaveButton.Enable(self.SlaveNodes.GetPageCount() > 0) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
547 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
548 |
def SelectSlave(self, slave): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
549 |
for idx in xrange(self.SlaveNodes.GetPageCount()): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
550 |
panel = self.SlaveNodes.GetPage(idx) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
551 |
if panel.GetSlave() == slave: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
552 |
self.SlaveNodes.SetSelection(idx) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
553 |
return |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
554 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
555 |
def OnAddSlaveButtonClick(self, event): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
556 |
slave = self.Controler.AddSlave() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
557 |
self.RefreshParentWindow() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
558 |
wx.CallAfter(self.RefreshView, slave) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
559 |
event.Skip() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
560 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
561 |
def OnDeleteSlaveButtonClick(self, event): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
562 |
selected = self.SlaveNodes.GetSelection() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
563 |
if selected != -1: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
564 |
panel = self.SlaveNodes.GetPage(selected) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
565 |
if self.Controler.RemoveSlave(panel.GetSlave()[:2]): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
566 |
self.RefreshParentWindow() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
567 |
wx.CallAfter(self.RefreshView) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
568 |