[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10403 - in gnuradio/trunk/grc/src: gui platforms/base
From: |
jblum |
Subject: |
[Commit-gnuradio] r10403 - in gnuradio/trunk/grc/src: gui platforms/base platforms/python |
Date: |
Fri, 6 Feb 2009 12:01:11 -0700 (MST) |
Author: jblum
Date: 2009-02-06 12:01:10 -0700 (Fri, 06 Feb 2009)
New Revision: 10403
Modified:
gnuradio/trunk/grc/src/gui/Messages.py
gnuradio/trunk/grc/src/platforms/base/Block.py
gnuradio/trunk/grc/src/platforms/base/Connection.py
gnuradio/trunk/grc/src/platforms/base/Element.py
gnuradio/trunk/grc/src/platforms/base/Port.py
gnuradio/trunk/grc/src/platforms/python/Block.py
gnuradio/trunk/grc/src/platforms/python/Port.py
Log:
grc: better handling of disabled elements
Modified: gnuradio/trunk/grc/src/gui/Messages.py
===================================================================
--- gnuradio/trunk/grc/src/gui/Messages.py 2009-02-06 00:37:41 UTC (rev
10402)
+++ gnuradio/trunk/grc/src/gui/Messages.py 2009-02-06 19:01:10 UTC (rev
10403)
@@ -91,7 +91,7 @@
################# functions for connections
########################################
def send_fail_connection():
- send('>>> Warning: A connection can only be created between a source
and an unconnected sink.\n')
+ send('>>> Error: Cannot create connection.\n')
################# functions for preferences
########################################
def send_fail_load_preferences(prefs_file_path):
Modified: gnuradio/trunk/grc/src/platforms/base/Block.py
===================================================================
--- gnuradio/trunk/grc/src/platforms/base/Block.py 2009-02-06 00:37:41 UTC
(rev 10402)
+++ gnuradio/trunk/grc/src/platforms/base/Block.py 2009-02-06 19:01:10 UTC
(rev 10403)
@@ -142,8 +142,7 @@
All ports and params must be valid.
All checks must evaluate to true.
"""
- if not self.get_enabled(): return
- for c in self.get_params() + self.get_sinks() +
self.get_sources() + self.get_connections():
+ for c in self.get_params() + self.get_ports() +
self.get_connections():
try: assert(c.is_valid())
except AssertionError:
for msg in c.get_error_messages():
Modified: gnuradio/trunk/grc/src/platforms/base/Connection.py
===================================================================
--- gnuradio/trunk/grc/src/platforms/base/Connection.py 2009-02-06 00:37:41 UTC
(rev 10402)
+++ gnuradio/trunk/grc/src/platforms/base/Connection.py 2009-02-06 19:01:10 UTC
(rev 10403)
@@ -37,10 +37,10 @@
for port in (porta, portb):
if port.is_source(): source = port
if port.is_sink(): sink = port
- #verify the source and sink
assert(source and sink)
- assert(not source.is_full())
- assert(not sink.is_full())
+ #ensure that this connection (source -> sink) is unique
+ for connection in self.get_parent().get_connections():
+ assert not (connection.get_source() is source and
connection.get_sink() is sink)
self._source = source
self._sink = sink
Modified: gnuradio/trunk/grc/src/platforms/base/Element.py
===================================================================
--- gnuradio/trunk/grc/src/platforms/base/Element.py 2009-02-06 00:37:41 UTC
(rev 10402)
+++ gnuradio/trunk/grc/src/platforms/base/Element.py 2009-02-06 19:01:10 UTC
(rev 10403)
@@ -41,10 +41,13 @@
def is_valid(self):
self._error_messages = []#reset err msgs
- try: self.validate()
- except: pass
+ if self.get_enabled():
+ try: self.validate()
+ except: pass
return not self.get_error_messages()
+ def get_enabled(self): return True
+
def _add_error_message(self, msg):
self._error_messages.append(msg)
Modified: gnuradio/trunk/grc/src/platforms/base/Port.py
===================================================================
--- gnuradio/trunk/grc/src/platforms/base/Port.py 2009-02-06 00:37:41 UTC
(rev 10402)
+++ gnuradio/trunk/grc/src/platforms/base/Port.py 2009-02-06 19:01:10 UTC
(rev 10403)
@@ -47,8 +47,6 @@
Validate the port.
The port must be non-empty and type must a possible type.
"""
- try: assert(not self.is_empty())
- except AssertionError: self._add_error_message('Port is not
connected.')
try: assert(self.get_type() in self.TYPES)
except AssertionError: self._add_error_message('Type "%s" is
not a possible type.'%self.get_type())
@@ -59,17 +57,11 @@
return 'Sink - %s(%s)'%(self.get_name(), self.get_key())
def is_port(self): return True
-
def get_color(self): return '#FFFFFF'
-
def get_name(self): return self._name
-
def get_key(self): return self._key
-
def is_sink(self): return self in self.get_parent().get_sinks()
-
def is_source(self): return self in self.get_parent().get_sources()
-
def get_type(self): return
self.get_parent().resolve_dependencies(self._type)
def get_connections(self):
@@ -81,26 +73,9 @@
connections = filter(lambda c: c.get_source() is self or
c.get_sink() is self, connections)
return connections
- def is_connected(self):
+ def get_enabled_connections(self):
"""
- Is this port connected?
- @return true if at least one connection
+ Get all enabled connections that use this port.
+ @return a list of connection objects
"""
- return bool(self.get_connections())
-
- def is_full(self):
- """
- Is this port full of connections?
- Generally a sink can handle one connection and a source can
handle many.
- @return true if the port is full
- """
- if self.is_source(): return False
- if self.is_sink(): return bool(self.get_connections())
-
- def is_empty(self):
- """
- Is this port empty?
- An empty port has no connections.
- @return true if empty
- """
- return not self.get_connections()
+ return filter(lambda c: c.get_enabled(), self.get_connections())
Modified: gnuradio/trunk/grc/src/platforms/python/Block.py
===================================================================
--- gnuradio/trunk/grc/src/platforms/python/Block.py 2009-02-06 00:37:41 UTC
(rev 10402)
+++ gnuradio/trunk/grc/src/platforms/python/Block.py 2009-02-06 19:01:10 UTC
(rev 10403)
@@ -69,6 +69,7 @@
try: assert check_eval
except AssertionError:
self._add_error_message('Check "%s" failed.'%check)
except: self._add_error_message('Check "%s" did not
evaluate.'%check)
+ #adjust nports
for ports, Port in (
(self._sources, self.get_parent().get_parent().Source),
(self._sinks, self.get_parent().get_parent().Sink),
Modified: gnuradio/trunk/grc/src/platforms/python/Port.py
===================================================================
--- gnuradio/trunk/grc/src/platforms/python/Port.py 2009-02-06 00:37:41 UTC
(rev 10402)
+++ gnuradio/trunk/grc/src/platforms/python/Port.py 2009-02-06 19:01:10 UTC
(rev 10403)
@@ -46,6 +46,13 @@
self._vlen = vlen
self._optional = bool(optional)
+ def validate(self):
+ _Port.validate(self)
+ try: assert(self.get_enabled_connections() or
self.get_optional())
+ 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.')
+
def get_vlen(self):
"""
Get the vector length.
@@ -98,15 +105,6 @@
}[self.get_type()]
except: return _Port.get_color(self)
- def is_empty(self):
- """
- Is this port empty?
- An empty port has no connections.
- Not empty of optional is set.
- @return true if empty
- """
- return not self.get_optional() and not self.get_connections()
-
class Source(Port):
def __init__(self, block, n):
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10403 - in gnuradio/trunk/grc/src: gui platforms/base platforms/python,
jblum <=