etherlab/entries_list.ysl2
author |
Andrey Skvortsov <andrej.skvortzov@gmail.com> |
|
Mon, 13 Aug 2018 18:29:07 +0300 |
changeset 2284 |
64bb520009f3 |
parent 2165 |
02a2b5dee5e3
|
child 2641 |
c9deff128c37 |
permissions |
-rw-r--r-- |
Fix wxHMI example after upgrading wxGlade
Newer wxGlade generates code to initialize GridSizer's with empty
elements.
...
grid_sizer_1.Add(self.window_1, 1, wx.ALIGN_CENTER, 0)
sizer_2.Add((0, 0), 0, 0, 0)
sizer_2.Add((0, 0), 0, 0, 0)
sizer_2.Add((0, 0), 0, 0, 0)
sizer_2.Add((0, 0), 0, 0, 0)
...
That causes following traceback, if new buttons are added
to already full sizer.
PLCobject : Traceback (most recent call last):
File "./Beremiz_service.py", line 389, in default_evaluator
res = (tocall(*args, **kwargs), None)
File "/tmp/tmpQS8ct2/runtime_0.py", line 540, in _runtime_0_start
wx.MessageBox(_("Please stop PLC to close"))
File "/tmp/tmpQS8ct2/runtime_0.py", line 504, in Init
lambda axis:( MakeButtonFunc(self, sizer, axis+"axisMinus"),
File "/tmp/tmpQS8ct2/runtime_0.py", line 502, in <lambda>
lambda btname: MakeButtonFunc(self, sizer, btname), ActionButtons)
File "/tmp/tmpQS8ct2/runtime_0.py", line 461, in MakeButtonFunc
print sizer, btname
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk3/wx/_core.py", line 14453, in Add
return _core_.Sizer_Add(*args, **kwargs)
PyAssertionError: C++ assertion "Assert failure" failed at
../src/common/sizer.cpp(1401) in DoInsert(): too many items (11 > 2*5)
in grid sizer (maybe you should omit the number of either rows or
columns?)
Tested with wxGlade version 0.8.3
Closes #41
/*
Stylesheet used to list EtherCat dictionnary entries.
Copyright (C) 2011-2014: Laurent BESSARD
Distributed under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
See COPYING file for copyrights details.
*/
include yslt.yml2
estylesheet xmlns:ns="entries_list_ns"
extension-element-prefixes="ns"
exclude-result-prefixes="ns" {
param "min_index";
param "max_index";
template "text()";
template "Device" {
apply "Profile/Dictionary/Objects/Object";
foreach "RxPdo" {
call "pdo_entries" with "direction", "'Receive'";
}
foreach "TxPdo" {
call "pdo_entries" with "direction", "'Transmit'";
}
}
template "Object" {
variable "index" > «ns:HexDecValue(Index/text())»
variable "entry_name" > «ns:EntryName(Name)»
choose {
when "$index >= $min_index and $index <= $max_index" {
variable "datatype_name" > «Type/text()»
choose {
when "ancestor::Dictionary/child::DataTypes/DataType[Name/text()=$datatype_name][SubItem]" {
apply "ancestor::Dictionary/child::DataTypes/DataType[Name/text()=$datatype_name][SubItem]" {
with "index" > «$index»
with "entry_name" > «$entry_name»
}
}
otherwise {
variable "subindex" > 0
variable "entry" {
> «ns:AddEntry($index, $subindex, $entry_name, $datatype_name, BitSize/text(), Flags/Access/text(), Flags/PdoMapping/text())»
}
}
}
}
}
}
template "DataType" {
param "index";
param "entry_name";
foreach "SubItem" {
variable "subindex" > «ns:HexDecValue(SubIdx/text())»
variable "subentry_name" > «$entry_name» - «ns:EntryName(DisplayName, Name/text())»
variable "entry" {
> «ns:AddEntry($index, $subindex, $subentry_name, Type/text(), BitSize/text(), Flags/Access/text(), Flags/PdoMapping/text())»
}
}
}
function "pdo_entries" {
param "direction";
variable "pdo_index" > «ns:HexDecValue(Index/text())»
variable "pdo_name" > «ns:EntryName(Name)»
foreach "Entry" {
variable "index" > «ns:HexDecValue(Index/text())»
choose {
when "$index >= $min_index and $index <= $max_index" {
variable "subindex" > «ns:HexDecValue(SubIndex/text())»
variable "subentry_name" > «ns:EntryName(Name)»
variable "access" {
choose {
when "$direction='Transmit'" > ro
otherwise > wo
}
}
variable "pdo_mapping" {
choose {
when "$direction='Transmit'" > T
otherwise > R
}
}
variable "entry" {
> «ns:AddEntry($index, $subindex, $subentry_name, DataType/text(), BitLen/text(), $access, $pdo_mapping, $pdo_index, $pdo_name, $direction)»
}
}
}
}
}
}