Tweaks to the base validation routines.
Validate twice in the update until rewrite functions are implemented.
Validate the block.
All ports and params must be valid.
All checks must evaluate to true.
+ Validate the params, ports, and the connections to this block.
"""
Element.validate(self)
for c in self.get_params() + self.get_ports() + self.get_connections():
- try:
- c.validate()
- assert c.is_valid()
- except AssertionError:
+ c.validate()
+ if not c.is_valid():
for msg in c.get_error_messages():
self.add_error_message('>>> %s:\n\t%s'%(c, msg))
def validate(self):
"""
Validate the flow graph.
- All connections and blocks must be valid.
+ Validate only the blocks.
+ Connections will be validated within the blocks.
"""
Element.validate(self)
- for c in self.get_elements():
- try:
- c.validate()
- assert c.is_valid()
- except AssertionError: self.add_error_message('Element "%s" is not valid.'%c)
+ for c in self.get_blocks():
+ c.validate()
+ if not c.is_valid():
+ self.add_error_message('Element "%s" is not valid.'%c)
##############################################
## Import/Export Methods
variable_slider.xml \
variable_static_text.xml \
variable_text_box.xml \
+ virtual_sink.xml \
wxgui_constellationsink2.xml \
wxgui_fftsink2.xml \
wxgui_histosink2.xml \
<block>gr_wavfile_sink</block>
<block>gr_message_sink</block>
<block>pad_sink</block>
+ <block>virtual_sink</block>
</cat>
<cat>
<name>Graphical Sinks</name>
--- /dev/null
+<?xml version="1.0"?>
+<!--
+###################################################
+##Virtual Sink
+###################################################
+ -->
+<block>
+ <name>Virtual Sink</name>
+ <key>virtual_sink</key>
+ <make></make>
+ <sink>
+ <name>in</name>
+ <type></type>
+ </sink>
+</block>
elif state == Actions.PORT_CONTROLLER_INC:
if self.get_flow_graph().port_controller_modify_selected(1):
self.get_flow_graph().update()
- self.get_flow_graph().update() #2 times
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
elif state == Actions.PORT_CONTROLLER_DEC:
if self.get_flow_graph().port_controller_modify_selected(-1):
self.get_flow_graph().update()
- self.get_flow_graph().update() #2 times
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
##################################################
def update(self):
"""
Call update on all elements.
+ Validate twice:
+ 1) elements call special rewrite rules that may break validation
+ 2) elements should come up with the same results, validation can pass
"""
self.validate()
+ self.validate()
for element in self.get_elements(): element.update()
##########################################################################
except AssertionError: self.add_error_message('Port is not connected.')
try: assert self.is_source() or len(self.get_enabled_connections()) <= 1
except AssertionError: self.add_error_message('Port has too many connections.')
+ ################################################################
+ # message port logic
+ ################################################################
if self.get_type() == 'msg':
try: assert not self.get_nports()
except AssertionError: self.add_error_message('A port of type "msg" cannot have "nports" set.')
try: assert self.get_vlen() == 1
except AssertionError: self.add_error_message('A port of type "msg" must have a "vlen" of 1.')
+ ################################################################
+ # virtual sink logic
+ ################################################################
+ if self.get_parent().get_key() == 'virtual_sink':
+ if self.get_enabled_connections(): #clone type and vlen
+ source = self.get_enabled_connections()[0].get_source()
+ self._type = str(source.get_type())
+ self._vlen = str(source.get_vlen())
+ else: #reset type and vlen
+ self._type = ''
+ self._vlen = ''
def get_vlen(self):
"""