Skip to content

Commit

Permalink
ensure link type updates when important state changes happen, fixes #128
Browse files Browse the repository at this point in the history
.
  • Loading branch information
stonier committed May 19, 2014
1 parent 550bfdc commit fca9c68
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ def _set_link_string(self):
:returns: link type string
:rtype: str
'''
# if ((self.msg.status == concert_msgs.ConcertClientState.AVAILABLE) or
# (self.msg.status == concert_msgs.ConcertClientState.MISSING)
# ):
if self.msg.is_local_client:
return 'local'
elif self.msg.conn_stats.network_type == gateway_msgs.ConnectionStatistics.WIRED:
Expand Down Expand Up @@ -73,6 +70,8 @@ def get_rapp_context(self):
def get_connection_strength(self):
if self.msg.is_local_client == True:
return 'very_strong'
elif self.msg.state == concert_msgs.ConcertClientState.MISSING:
return 'missing'
else:
link_quality_percent = (float(self.msg.conn_stats.wireless_link_quality) / 70) * 100
if 80 < link_quality_percent and 100 >= link_quality_percent:
Expand All @@ -95,7 +94,13 @@ def update(self, msg):
the rapp that is running), the connection statistics and the state.
'''
# could pull the individual bits, but just easy to drop the new msg in place
old_msg = self.msg
self.msg = msg
if (
old_msg.is_local_client != msg.is_local_client or
old_msg.conn_stats.network_type != msg.conn_stats.network_type
):
self.link_type = self._set_link_string()

##############################################################################
# Conveniences
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class ConductorGraph(Plugin):
# constants
# colour definitions from http://www.w3.org/TR/SVG/types.html#ColorKeywords
# see also http://qt-project.org/doc/qt-4.8/qcolor.html#setNamedColor
link_strength_colours = {'very_strong': QColor("lime"), 'strong': QColor("chartreuse"), 'normal': QColor("yellow"), 'weak': QColor("orange"), 'very_weak': QColor("red")}
link_strength_colours = {'very_strong': QColor("lime"), 'strong': QColor("chartreuse"), 'normal': QColor("yellow"), 'weak': QColor("orange"), 'very_weak': QColor("red"), 'missing': QColor("powderblue")}

def __init__(self, context):
self._context = context
Expand All @@ -199,7 +199,6 @@ def __init__(self, context):
self._widget = QWidget()
self.cur_selected_client_name = ""
self.pre_selected_client_name = ""

# factory builds generic dotcode items
self.dotcode_factory = PydotFactory()
# self.dotcode_factory=PygraphvizFactory()
Expand Down Expand Up @@ -310,13 +309,16 @@ def _change_client_tab(self, index):
self.cur_selected_client_name = self._widget.tabWidget.tabText(self._widget.tabWidget.currentIndex())

def _set_network_statisics(self):
if self._edge_items == None:
return
else:
for edge_items in self._edge_items.itervalues():
for edge_item in edge_items:
edge_dst_name = edge_item.to_node._label.text()
edge_item.setToolTip(str(self._graph.concert_clients[edge_dst_name].msg.conn_stats))
# we currently redraw every statistics update (expensive!) so passing for now, but we should
# reenable this and drop the change callback to be more efficient
#if self._edge_items == None:
# return
#else:
# for edge_items in self._edge_items.itervalues():
# for edge_item in edge_items:
# edge_dst_name = edge_item.to_node._label.text()
# edge_item.setToolTip(str(self._graph.concert_clients[edge_dst_name].msg.conn_stats))
pass

def _redraw_graph_view(self):
print("[conductor graph]: _redraw_graph_view")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,19 @@ def _update_clients_callback(self, msg):
changes its state. This update happens rather infrequently with every
message supplied by the conductor's latched graph publisher.
'''
print("[conductor_graph_info] : update clients callback")
self._graph = msg
# sneaky way of getting all the states and the lists
visible_concert_clients_by_name = []
for state in msg.__slots__:
if state == concert_msgs.ConcertClientState.GONE:
continue
concert_clients = getattr(msg, state) # by state
for concert_client in concert_clients:
for concert_client in concert_clients: # concert_msgs.ConcertClient
visible_concert_clients_by_name.append(concert_client.name)
if concert_client.name in self.concert_clients.keys():
self.concert_clients[concert_client.name].is_new = False
self.concert_clients[concert_client.name].update(concert_client)
else:
self.concert_clients[concert_client.name] = ConcertClient(concert_client) # create extended ConcertClient class from msg
# remove any that are no longer visible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ def get_nodes_and_edges(self, conductor_graph_instance):
"""
nodes = conductor_graph_instance.concert_clients.values()
edges = []
important_states = [
concert_msgs.ConcertClientState.MISSING,
concert_msgs.ConcertClientState.AVAILABLE
]
for node in nodes:
if node.msg.conn_stats.gateway_available:
if node.msg.state in important_states: # and node.msg.conn_stats.gateway_available:
edges.append(Edge("conductor", node.concert_alias, node.link_type))
return (nodes, edges)

Expand Down

0 comments on commit fca9c68

Please sign in to comment.