{"action":"created","comment":{"url":"https://api.github.com/repos/NSLS-II/bluesky/pulls/comments/59205673","id":59205673,"diff_hunk":"@@ -112,43 +176,86 @@ def run_wrapper(plan, md=None, **kwargs):\n     return ret\n \n \n-def event_wrapper(plan):\n+def event_wrapper(plan, name=None):\n     \"\"\"Wrap an iterator with a create and save messages\n \n     Yields\n     ------\n     Msg\n     \"\"\"\n-    yield Msg('create')\n+    yield Msg('create', name=name)\n     ret = yield from plan\n     yield Msg('save')\n \n     return ret\n \n \n-def stage_wrapper(plan, dets):\n-    dets = list(dets)\n-    yield from broadcast_msg('stage', dets)\n+def stage_wrapper(plan):\n+    \"\"\"\n+    This is a preprocessor that inserts 'stage' Messages.\n+\n+    The first time an object is read, set, triggered (or, for flyers,\n+    the first time is it told to \"kickoff\") a 'stage' Msg is inserted first.\n+    It stages the the object's ultimate parent, pointed to be its `root`\n+    property.\n+\n+    At the end, an 'unstage' Message issued for every 'stage' Message.\n+    \"\"\"\n+    COMMANDS = ['read', 'set', 'trigger', 'kickoff']\n+    devices_staged = []\n+    ret = None\n     try:\n-        ret = yield from plan\n+        while True:\n+            msg = plan.send(ret)\n+            if msg.command in COMMANDS and msg.obj not in devices_staged:\n+                root = msg.obj.root\n+                ret = yield Msg('stage', root)\n+                if ret is None:\n+                    # The generator may be being list-ified.\n+                    # This is a hack to make that possible. Is it a good idea?\n+                    ret = [root]\n+                devices_staged.extend(ret)\n+            ret = yield msg\n     finally:\n-        yield from broadcast_msg('unstage', dets[::-1])\n+        yield from broadcast_msg('unstage', reversed(devices_staged))\n     return ret\n \n \n-def subscription_wrapper(plan, subs):\n-    tokens = set()\n-    subs = normalize_subs_input(subs)\n-    for name, funcs in subs.items():\n-        for func in funcs:\n-            token = yield Msg('subscribe', None, name, func)\n-            tokens.add(token)\n+def relative_set(plan, objects):\n+    \"\"\"\n+    Interpret set messages on objects as relative to current position.\n+    \"\"\"\n+    initial_positions = {}\n+    ret = None\n+    while True:\n+        msg = plan.send(ret)\n+        if msg.command == 'set' and msg.obj in objects:\n+            if msg.obj not in initial_positions:\n+                pos = scalar_heuristic(msg.obj)","path":"bluesky/plan_tools.py","position":null,"original_position":160,"commit_id":"42d5802adf4760085d15912384ff5f3b37f8f1ba","original_commit_id":"5dd6902fff4e0a35aac877d1d2ff8f70596ca400","user":{"login":"danielballan","id":2279598,"avatar_url":"https://avatars.githubusercontent.com/u/2279598?v=3","gravatar_id":"","url":"https://api.github.com/users/danielballan","html_url":"https://github.com/danielballan","followers_url":"https://api.github.com/users/danielballan/followers","following_url":"https://api.github.com/users/danielballan/following{/other_user}","gists_url":"https://api.github.com/users/danielballan/gists{/gist_id}","starred_url":"https://api.github.com/users/danielballan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielballan/subscriptions","organizations_url":"https://api.github.com/users/danielballan/orgs","repos_url":"https://api.github.com/users/danielballan/repos","events_url":"https://api.github.com/users/danielballan/events{/privacy}","received_events_url":"https://api.github.com/users/danielballan/received_events","type":"User","site_admin":false},"body":"Done. `scalar_heuristic` has been removed everywhere is occurred.","created_at":"2016-04-11T13:44:37Z","updated_at":"2016-04-11T13:44:37Z","html_url":"https://github.com/NSLS-II/bluesky/pull/345#discussion_r59205673","pull_request_url":"https://api.github.com/repos/NSLS-II/bluesky/pulls/345","_links":{"self":{"href":"https://api.github.com/repos/NSLS-II/bluesky/pulls/comments/59205673"},"html":{"href":"https://github.com/NSLS-II/bluesky/pull/345#discussion_r59205673"},"pull_request":{"href":"https://api.github.com/repos/NSLS-II/bluesky/pulls/345"}}},"pull_request":{"url":"https://api.github.com/repos/NSLS-II/bluesky/pulls/345","id":59825019,"html_url":"https://github.com/NSLS-II/bluesky/pull/345","diff_url":"https://github.com/NSLS-II/bluesky/pull/345.diff","patch_url":"https://github.com/NSLS-II/bluesky/pull/345.patch","issue_url":"https://api.github.com/repos/NSLS-II/bluesky/issues/345","number":345,"state":"open","locked":false,"title":"REF: Implement PlanBase in terms of plan_tools generators.","user":{"login":"danielballan","id":2279598,"avatar_url":"https://avatars.githubusercontent.com/u/2279598?v=3","gravatar_id":"","url":"https://api.github.com/users/danielballan","html_url":"https://github.com/danielballan","followers_url":"https://api.github.com/users/danielballan/followers","following_url":"https://api.github.com/users/danielballan/following{/other_user}","gists_url":"https://api.github.com/users/danielballan/gists{/gist_id}","starred_url":"https://api.github.com/users/danielballan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielballan/subscriptions","organizations_url":"https://api.github.com/users/danielballan/orgs","repos_url":"https://api.github.com/users/danielballan/repos","events_url":"https://api.github.com/users/danielballan/events{/privacy}","received_events_url":"https://api.github.com/users/danielballan/received_events","type":"User","site_admin":false},"body":"- Add generators for subscribing and flying.\r\n- Start refactoring PlanBase in terms of plan_tools generators.","created_at":"2016-02-18T16:29:59Z","updated_at":"2016-04-11T13:44:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7973757d7c2277080dc85190be4032eae1a12cea","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NSLS-II/bluesky/pulls/345/commits","review_comments_url":"https://api.github.com/repos/NSLS-II/bluesky/pulls/345/comments","review_comment_url":"https://api.github.com/repos/NSLS-II/bluesky/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NSLS-II/bluesky/issues/345/comments","statuses_url":"https://api.github.com/repos/NSLS-II/bluesky/statuses/42d5802adf4760085d15912384ff5f3b37f8f1ba","head":{"label":"danielballan:planbase-gen","ref":"planbase-gen","sha":"42d5802adf4760085d15912384ff5f3b37f8f1ba","user":{"login":"danielballan","id":2279598,"avatar_url":"https://avatars.githubusercontent.com/u/2279598?v=3","gravatar_id":"","url":"https://api.github.com/users/danielballan","html_url":"https://github.com/danielballan","followers_url":"https://api.github.com/users/danielballan/followers","following_url":"https://api.github.com/users/danielballan/following{/other_user}","gists_url":"https://api.github.com/users/danielballan/gists{/gist_id}","starred_url":"https://api.github.com/users/danielballan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielballan/subscriptions","organizations_url":"https://api.github.com/users/danielballan/orgs","repos_url":"https://api.github.com/users/danielballan/repos","events_url":"https://api.github.com/users/danielballan/events{/privacy}","received_events_url":"https://api.github.com/users/danielballan/received_events","type":"User","site_admin":false},"repo":{"id":39904738,"name":"bluesky","full_name":"danielballan/bluesky","owner":{"login":"danielballan","id":2279598,"avatar_url":"https://avatars.githubusercontent.com/u/2279598?v=3","gravatar_id":"","url":"https://api.github.com/users/danielballan","html_url":"https://github.com/danielballan","followers_url":"https://api.github.com/users/danielballan/followers","following_url":"https://api.github.com/users/danielballan/following{/other_user}","gists_url":"https://api.github.com/users/danielballan/gists{/gist_id}","starred_url":"https://api.github.com/users/danielballan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielballan/subscriptions","organizations_url":"https://api.github.com/users/danielballan/orgs","repos_url":"https://api.github.com/users/danielballan/repos","events_url":"https://api.github.com/users/danielballan/events{/privacy}","received_events_url":"https://api.github.com/users/danielballan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danielballan/bluesky","description":"a data collection interface","fork":true,"url":"https://api.github.com/repos/danielballan/bluesky","forks_url":"https://api.github.com/repos/danielballan/bluesky/forks","keys_url":"https://api.github.com/repos/danielballan/bluesky/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danielballan/bluesky/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danielballan/bluesky/teams","hooks_url":"https://api.github.com/repos/danielballan/bluesky/hooks","issue_events_url":"https://api.github.com/repos/danielballan/bluesky/issues/events{/number}","events_url":"https://api.github.com/repos/danielballan/bluesky/events","assignees_url":"https://api.github.com/repos/danielballan/bluesky/assignees{/user}","branches_url":"https://api.github.com/repos/danielballan/bluesky/branches{/branch}","tags_url":"https://api.github.com/repos/danielballan/bluesky/tags","blobs_url":"https://api.github.com/repos/danielballan/bluesky/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danielballan/bluesky/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danielballan/bluesky/git/refs{/sha}","trees_url":"https://api.github.com/repos/danielballan/bluesky/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danielballan/bluesky/statuses/{sha}","languages_url":"https://api.github.com/repos/danielballan/bluesky/languages","stargazers_url":"https://api.github.com/repos/danielballan/bluesky/stargazers","contributors_url":"https://api.github.com/repos/danielballan/bluesky/contributors","subscribers_url":"https://api.github.com/repos/danielballan/bluesky/subscribers","subscription_url":"https://api.github.com/repos/danielballan/bluesky/subscription","commits_url":"https://api.github.com/repos/danielballan/bluesky/commits{/sha}","git_commits_url":"https://api.github.com/repos/danielballan/bluesky/git/commits{/sha}","comments_url":"https://api.github.com/repos/danielballan/bluesky/comments{/number}","issue_comment_url":"https://api.github.com/repos/danielballan/bluesky/issues/comments{/number}","contents_url":"https://api.github.com/repos/danielballan/bluesky/contents/{+path}","compare_url":"https://api.github.com/repos/danielballan/bluesky/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danielballan/bluesky/merges","archive_url":"https://api.github.com/repos/danielballan/bluesky/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danielballan/bluesky/downloads","issues_url":"https://api.github.com/repos/danielballan/bluesky/issues{/number}","pulls_url":"https://api.github.com/repos/danielballan/bluesky/pulls{/number}","milestones_url":"https://api.github.com/repos/danielballan/bluesky/milestones{/number}","notifications_url":"https://api.github.com/repos/danielballan/bluesky/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danielballan/bluesky/labels{/name}","releases_url":"https://api.github.com/repos/danielballan/bluesky/releases{/id}","deployments_url":"https://api.github.com/repos/danielballan/bluesky/deployments","created_at":"2015-07-29T16:42:41Z","updated_at":"2016-01-27T22:18:04Z","pushed_at":"2016-04-11T13:44:21Z","git_url":"git://github.com/danielballan/bluesky.git","ssh_url":"git@github.com:danielballan/bluesky.git","clone_url":"https://github.com/danielballan/bluesky.git","svn_url":"https://github.com/danielballan/bluesky","homepage":"http://danielballan.github.io/bluesky","size":3415,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"NSLS-II:master","ref":"master","sha":"f8d462fede262bb2a48cecb2cbff61698046b4e3","user":{"login":"NSLS-II","id":8700262,"avatar_url":"https://avatars.githubusercontent.com/u/8700262?v=3","gravatar_id":"","url":"https://api.github.com/users/NSLS-II","html_url":"https://github.com/NSLS-II","followers_url":"https://api.github.com/users/NSLS-II/followers","following_url":"https://api.github.com/users/NSLS-II/following{/other_user}","gists_url":"https://api.github.com/users/NSLS-II/gists{/gist_id}","starred_url":"https://api.github.com/users/NSLS-II/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NSLS-II/subscriptions","organizations_url":"https://api.github.com/users/NSLS-II/orgs","repos_url":"https://api.github.com/users/NSLS-II/repos","events_url":"https://api.github.com/users/NSLS-II/events{/privacy}","received_events_url":"https://api.github.com/users/NSLS-II/received_events","type":"Organization","site_admin":false},"repo":{"id":36754446,"name":"bluesky","full_name":"NSLS-II/bluesky","owner":{"login":"NSLS-II","id":8700262,"avatar_url":"https://avatars.githubusercontent.com/u/8700262?v=3","gravatar_id":"","url":"https://api.github.com/users/NSLS-II","html_url":"https://github.com/NSLS-II","followers_url":"https://api.github.com/users/NSLS-II/followers","following_url":"https://api.github.com/users/NSLS-II/following{/other_user}","gists_url":"https://api.github.com/users/NSLS-II/gists{/gist_id}","starred_url":"https://api.github.com/users/NSLS-II/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NSLS-II/subscriptions","organizations_url":"https://api.github.com/users/NSLS-II/orgs","repos_url":"https://api.github.com/users/NSLS-II/repos","events_url":"https://api.github.com/users/NSLS-II/events{/privacy}","received_events_url":"https://api.github.com/users/NSLS-II/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NSLS-II/bluesky","description":"a data collection interface","fork":false,"url":"https://api.github.com/repos/NSLS-II/bluesky","forks_url":"https://api.github.com/repos/NSLS-II/bluesky/forks","keys_url":"https://api.github.com/repos/NSLS-II/bluesky/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NSLS-II/bluesky/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NSLS-II/bluesky/teams","hooks_url":"https://api.github.com/repos/NSLS-II/bluesky/hooks","issue_events_url":"https://api.github.com/repos/NSLS-II/bluesky/issues/events{/number}","events_url":"https://api.github.com/repos/NSLS-II/bluesky/events","assignees_url":"https://api.github.com/repos/NSLS-II/bluesky/assignees{/user}","branches_url":"https://api.github.com/repos/NSLS-II/bluesky/branches{/branch}","tags_url":"https://api.github.com/repos/NSLS-II/bluesky/tags","blobs_url":"https://api.github.com/repos/NSLS-II/bluesky/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NSLS-II/bluesky/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NSLS-II/bluesky/git/refs{/sha}","trees_url":"https://api.github.com/repos/NSLS-II/bluesky/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NSLS-II/bluesky/statuses/{sha}","languages_url":"https://api.github.com/repos/NSLS-II/bluesky/languages","stargazers_url":"https://api.github.com/repos/NSLS-II/bluesky/stargazers","contributors_url":"https://api.github.com/repos/NSLS-II/bluesky/contributors","subscribers_url":"https://api.github.com/repos/NSLS-II/bluesky/subscribers","subscription_url":"https://api.github.com/repos/NSLS-II/bluesky/subscription","commits_url":"https://api.github.com/repos/NSLS-II/bluesky/commits{/sha}","git_commits_url":"https://api.github.com/repos/NSLS-II/bluesky/git/commits{/sha}","comments_url":"https://api.github.com/repos/NSLS-II/bluesky/comments{/number}","issue_comment_url":"https://api.github.com/repos/NSLS-II/bluesky/issues/comments{/number}","contents_url":"https://api.github.com/repos/NSLS-II/bluesky/contents/{+path}","compare_url":"https://api.github.com/repos/NSLS-II/bluesky/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NSLS-II/bluesky/merges","archive_url":"https://api.github.com/repos/NSLS-II/bluesky/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NSLS-II/bluesky/downloads","issues_url":"https://api.github.com/repos/NSLS-II/bluesky/issues{/number}","pulls_url":"https://api.github.com/repos/NSLS-II/bluesky/pulls{/number}","milestones_url":"https://api.github.com/repos/NSLS-II/bluesky/milestones{/number}","notifications_url":"https://api.github.com/repos/NSLS-II/bluesky/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NSLS-II/bluesky/labels{/name}","releases_url":"https://api.github.com/repos/NSLS-II/bluesky/releases{/id}","deployments_url":"https://api.github.com/repos/NSLS-II/bluesky/deployments","created_at":"2015-06-02T18:50:18Z","updated_at":"2016-01-11T17:00:50Z","pushed_at":"2016-04-11T13:44:21Z","git_url":"git://github.com/NSLS-II/bluesky.git","ssh_url":"git@github.com:NSLS-II/bluesky.git","clone_url":"https://github.com/NSLS-II/bluesky.git","svn_url":"https://github.com/NSLS-II/bluesky","homepage":"http://nsls-ii.github.io/bluesky","size":2861,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":11,"mirror_url":null,"open_issues_count":37,"forks":11,"open_issues":37,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NSLS-II/bluesky/pulls/345"},"html":{"href":"https://github.com/NSLS-II/bluesky/pull/345"},"issue":{"href":"https://api.github.com/repos/NSLS-II/bluesky/issues/345"},"comments":{"href":"https://api.github.com/repos/NSLS-II/bluesky/issues/345/comments"},"review_comments":{"href":"https://api.github.com/repos/NSLS-II/bluesky/pulls/345/comments"},"review_comment":{"href":"https://api.github.com/repos/NSLS-II/bluesky/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NSLS-II/bluesky/pulls/345/commits"},"statuses":{"href":"https://api.github.com/repos/NSLS-II/bluesky/statuses/42d5802adf4760085d15912384ff5f3b37f8f1ba"}}}}