Skip to content

Commit

Permalink
[qt-js] accepting trees flagged with no status/graph change (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
stonier authored Nov 27, 2019
1 parent 227ed7f commit 2215c8c
Show file tree
Hide file tree
Showing 7 changed files with 25,194 additions and 25,176 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog

Forthcoming
-----------
* ...
* [js] accepting trees flagged with no status/graph change, `#122 <https://github.com/splintered-reality/py_trees_js/pull/122>`_

0.5.1 (2019-10-26)
------------------
Expand Down
42 changes: 22 additions & 20 deletions js/py_trees-0.5.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ joint.shapes.trees.EventMarker = joint.shapes.standard.Rectangle.define(
position: { x: 0, y: 0 },
size: { width: 4, height: 30 },
default_width: 4,
significant: true, // denotes a significant tree status/graph change or otherwise
attrs: {
body: {
refWidth: '100%',
Expand Down Expand Up @@ -1250,18 +1251,17 @@ var py_trees = (function() {
var _timeline_highlight_event = function({event, highlight}) {
if ( highlight ) {
event.toFront()
event.attr({
body: {
fill: 'red'
}
})
colour = 'red'
} else if ( event.get('significant') ) {
colour = 'white'
} else {
event.attr({
body: {
fill: 'white'
}
})
colour = 'grey'
}
event.attr({
body: {
fill: colour
}
})
}

/**
Expand Down Expand Up @@ -1330,6 +1330,9 @@ var py_trees = (function() {
trees.shift() // pop first element
cache.set('selected_index', cache.get('selected_index') - 1)
}
// ugly hack since I can't pass in a boolean except as a string
// mayhap there is some way...load the json object into javascript?
tree['changed'] = tree['changed'] == 'true' ? true : false
trees.push(tree)
_timeline_rebuild_cache_event_markers({graph: timeline_graph})

Expand Down Expand Up @@ -1369,23 +1372,22 @@ var py_trees = (function() {
// normalise between 0.05 and 0.95
normalised_x = 0.05 + 0.9 * (tree['timestamp'] - min_timestamp) / delta
var event_marker = new joint.shapes.trees.EventMarker()
event_marker.set('significant', tree['changed'])
event_marker.translate(
dimensions.x + normalised_x * dimensions.width - event_marker.get('default_width') / 2.0,
0
)
event_marker.resize(event_marker.get('default_width'), dimensions.height)
event_marker.set('tree', tree)
if ( graph.get('streaming') ) {
if (index == trees.length - 1) {
_timeline_highlight_event({event: event_marker, highlight: true})
cache.set('selected', event_marker)
cache.set('selected_index', index)
}
if ( !graph.get('streaming') && (index == cache.get('selected_index')) ) {
cache.set('selected', event_marker)
_timeline_highlight_event({event: event_marker, highlight: true})
} else if ( graph.get('streaming') && (index == trees.length - 1) ) {
_timeline_highlight_event({event: event_marker, highlight: true})
cache.set('selected', event_marker)
cache.set('selected_index', index)
} else {
if (index == cache.get('selected_index')) {
cache.set('selected', event_marker)
_timeline_highlight_event({event: event_marker, highlight: true})
}
_timeline_highlight_event({event: event_marker, highlight: false})
}
cache.embed(event_marker)
events.push(event_marker)
Expand Down
50,289 changes: 25,150 additions & 25,139 deletions py_trees_js/resources.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion py_trees_js/viewer/images_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x6e\x12\x8c\x06\xd8\
\x00\x00\x01\x6d\xc5\xcb\x71\x27\
"

qt_version = QtCore.qVersion().split('.')
Expand Down
30 changes: 17 additions & 13 deletions py_trees_js/viewer/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

def create_demo_tree_definition():
tree = {
'changed': "true",
'timestamp': 1563938995,
'visited_path': ['1', '2', '7'],
'behaviours': {
Expand Down Expand Up @@ -150,21 +151,24 @@ def create_demo_tree_list():
trees = []
tree = create_demo_tree_definition()
trees.append(copy.deepcopy(tree))
# sequence progressed, but running
tree['visited_path'] = ['1', '2', '7', '8']
tree['behaviours']['7']['status'] = 'SUCCESS'
tree['behaviours']['8']['status'] = 'RUNNING'
tree['behaviours']['7']['status'] = 'SUCCESS' # first worker
tree['behaviours']['8']['status'] = 'RUNNING' # middle worker
trees.append(copy.deepcopy(tree))
# sequence
# not changed
tree['changed'] = 'false'
trees.append(copy.deepcopy(tree))
# sequence failed
tree['changed'] = 'true'
tree['visited_path'] = ['1', '2', '3', '4', '5', '8', '9', '10', '11']
tree['behaviours']['2']['status'] = 'FAILURE'
tree['behaviours']['8']['status'] = 'SUCCESS'
tree['behaviours']['9']['status'] = 'FAILURE'
# parallel
tree['behaviours']['3']['status'] = 'SUCCESS'
tree['behaviours']['10']['status'] = 'SUCCESS'
tree['behaviours']['11']['status'] = 'RUNNING'
# decorated
tree['behaviours']['4']['status'] = 'RUNNING'
tree['behaviours']['5']['status'] = 'RUNNING'
tree['behaviours']['2']['status'] = 'FAILURE' # sequence
tree['behaviours']['8']['status'] = 'SUCCESS' # middle worker
tree['behaviours']['9']['status'] = 'FAILURE' # final worker
tree['behaviours']['3']['status'] = 'SUCCESS' # parallel
tree['behaviours']['10']['status'] = 'SUCCESS' # first parallelised
tree['behaviours']['11']['status'] = 'RUNNING' # second parallelised
tree['behaviours']['4']['status'] = 'RUNNING' # decorator
tree['behaviours']['5']['status'] = 'RUNNING' # decorator child
trees.append(copy.deepcopy(tree))
return trees
3 changes: 2 additions & 1 deletion py_trees_js/viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def send_tree_response(reply):

@qt_core.pyqtSlot()
def send_tree(web_view_page, demo_trees, unused_checked):
number_of_trees = len(demo_trees)
demo_trees[send_tree.index]['timestamp'] = time.time()
# demo_trees[send_tree.index]['timestamp'] = time.time()
console.logdebug("[{}] send: tree '{}' [{}][viewer]".format(
Expand All @@ -49,7 +50,7 @@ def send_tree(web_view_page, demo_trees, unused_checked):
)
javascript_command = "render_tree({{tree: {}}})".format(demo_trees[send_tree.index])
web_view_page.runJavaScript(javascript_command, send_tree_response)
send_tree.index = 0 if send_tree.index == 2 else send_tree.index + 1
send_tree.index = 0 if send_tree.index == (number_of_trees - 1) else send_tree.index + 1


send_tree.index = 0
Expand Down
2 changes: 1 addition & 1 deletion py_trees_js/viewer/web_app_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x6e\x18\x1d\xed\xf0\
\x00\x00\x01\x6e\x1a\x73\xcc\xfc\
"

qt_version = QtCore.qVersion().split('.')
Expand Down

0 comments on commit 2215c8c

Please sign in to comment.