{"action":"created","comment":{"url":"https://api.github.com/repos/rock-core/base-scripts/pulls/comments/36837352","id":36837352,"diff_hunk":"@@ -0,0 +1,79 @@\n+#!/usr/bin/env ruby\n+\n+require 'optparse'\n+options = {}\n+\n+optparse = OptionParser.new do |opts|\n+    opts.banner = \"usage: rock-hz -t <task-name> -p <port-name>\"\n+\n+    opts.on(\"-t\",\"--task TASK\",\"task name\") do |t|\n+        options[:task_name] = t\n+    end\n+\n+    opts.on(\"-p\",\"--port PORT\",\"port name\") do |p|\n+        options[:port_name] = p\n+    end\n+\n+    opts.on_tail(\"-h\",\"--help\", \"Show this message\") do\n+        puts opts\n+        exit\n+    end\n+end\n+optparse.parse!\n+\n+if !(options[:task_name] || options[:port_name])\n+    puts optparse\n+    exit\n+end\n+\n+require 'orocos.rb'\n+Orocos.initialize\n+include Orocos\n+\n+task = TaskContext.get options[:task_name]\n+port = task.port options[:port_name]\n+port_reader = port.reader\n+\n+queue = []\n+max_queue_size = 10\n+one_s_counter = 0\n+one_s_timer = Time.now\n+progress_message = nil\n+\n+def get_key\n+    system('stty raw -echo') # => Raw mode, no echo\n+    char = (STDIN.read_nonblock(1) rescue nil)\n+    system('stty -raw echo') # => Reset terminal mode\n+    return char\n+end\n+\n+while true\n+    while port_reader.read_new && (Time.now - one_s_timer) < 1\n+        one_s_counter += 1\n+    end\n+\n+    if queue.size != max_queue_size || ! (ten_s_frequency = queue.reduce(:+)/10)\n+        ten_s_frequency = \"n/a\"\n+    end\n+\n+    # Terminal code to go up 1 line and clear the line\n+    print \"\\r\" + (\"\\e[A\\e[K\"*3) if progress_message\n+\n+    progress_message = \"message frequency (past 1 second):     #{one_s_counter}\\n\"\n+    progress_message += \"message frequency (past 10 seconds):   #{ten_s_frequency}\\n\"\n+    progress_message += \"Press 'q' to exit\"\n+    puts \"#{progress_message}\"","path":"bin/rock-hz","position":65,"original_position":65,"commit_id":"eac0cb9b072097f3b49327648467f32d2eadf254","original_commit_id":"eac0cb9b072097f3b49327648467f32d2eadf254","user":{"login":"2maz","id":5468166,"avatar_url":"https://avatars.githubusercontent.com/u/5468166?v=3","gravatar_id":"","url":"https://api.github.com/users/2maz","html_url":"https://github.com/2maz","followers_url":"https://api.github.com/users/2maz/followers","following_url":"https://api.github.com/users/2maz/following{/other_user}","gists_url":"https://api.github.com/users/2maz/gists{/gist_id}","starred_url":"https://api.github.com/users/2maz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2maz/subscriptions","organizations_url":"https://api.github.com/users/2maz/orgs","repos_url":"https://api.github.com/users/2maz/repos","events_url":"https://api.github.com/users/2maz/events{/privacy}","received_events_url":"https://api.github.com/users/2maz/received_events","type":"User","site_admin":false},"body":"Last line does not contain a line break -->\r\n$> rock-hz -t message_producer -p messages\r\nmessage frequency (past 1 second):     1\r\nmessage frequency (past 10 seconds):   1\r\nPress 'q' to exit\r\n\r\n","created_at":"2015-08-12T08:37:04Z","updated_at":"2015-08-12T08:37:04Z","html_url":"https://github.com/rock-core/base-scripts/pull/22#discussion_r36837352","pull_request_url":"https://api.github.com/repos/rock-core/base-scripts/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/rock-core/base-scripts/pulls/comments/36837352"},"html":{"href":"https://github.com/rock-core/base-scripts/pull/22#discussion_r36837352"},"pull_request":{"href":"https://api.github.com/repos/rock-core/base-scripts/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/rock-core/base-scripts/pulls/22","id":42037083,"html_url":"https://github.com/rock-core/base-scripts/pull/22","diff_url":"https://github.com/rock-core/base-scripts/pull/22.diff","patch_url":"https://github.com/rock-core/base-scripts/pull/22.patch","issue_url":"https://api.github.com/repos/rock-core/base-scripts/issues/22","number":22,"state":"open","locked":false,"title":"Add basic functionality for rock-hz","user":{"login":"2maz","id":5468166,"avatar_url":"https://avatars.githubusercontent.com/u/5468166?v=3","gravatar_id":"","url":"https://api.github.com/users/2maz","html_url":"https://github.com/2maz","followers_url":"https://api.github.com/users/2maz/followers","following_url":"https://api.github.com/users/2maz/following{/other_user}","gists_url":"https://api.github.com/users/2maz/gists{/gist_id}","starred_url":"https://api.github.com/users/2maz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2maz/subscriptions","organizations_url":"https://api.github.com/users/2maz/orgs","repos_url":"https://api.github.com/users/2maz/repos","events_url":"https://api.github.com/users/2maz/events{/privacy}","received_events_url":"https://api.github.com/users/2maz/received_events","type":"User","site_admin":false},"body":"Add simple rock counterpart for 'ros-hz'","created_at":"2015-08-10T16:10:25Z","updated_at":"2015-08-12T08:37:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b8a149931fd9ed02dfd4fdb10a29d86096bb854","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rock-core/base-scripts/pulls/22/commits","review_comments_url":"https://api.github.com/repos/rock-core/base-scripts/pulls/22/comments","review_comment_url":"https://api.github.com/repos/rock-core/base-scripts/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rock-core/base-scripts/issues/22/comments","statuses_url":"https://api.github.com/repos/rock-core/base-scripts/statuses/eac0cb9b072097f3b49327648467f32d2eadf254","head":{"label":"2maz:add_rock_hz","ref":"add_rock_hz","sha":"eac0cb9b072097f3b49327648467f32d2eadf254","user":{"login":"2maz","id":5468166,"avatar_url":"https://avatars.githubusercontent.com/u/5468166?v=3","gravatar_id":"","url":"https://api.github.com/users/2maz","html_url":"https://github.com/2maz","followers_url":"https://api.github.com/users/2maz/followers","following_url":"https://api.github.com/users/2maz/following{/other_user}","gists_url":"https://api.github.com/users/2maz/gists{/gist_id}","starred_url":"https://api.github.com/users/2maz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2maz/subscriptions","organizations_url":"https://api.github.com/users/2maz/orgs","repos_url":"https://api.github.com/users/2maz/repos","events_url":"https://api.github.com/users/2maz/events{/privacy}","received_events_url":"https://api.github.com/users/2maz/received_events","type":"User","site_admin":false},"repo":{"id":28085116,"name":"base-scripts","full_name":"2maz/base-scripts","owner":{"login":"2maz","id":5468166,"avatar_url":"https://avatars.githubusercontent.com/u/5468166?v=3","gravatar_id":"","url":"https://api.github.com/users/2maz","html_url":"https://github.com/2maz","followers_url":"https://api.github.com/users/2maz/followers","following_url":"https://api.github.com/users/2maz/following{/other_user}","gists_url":"https://api.github.com/users/2maz/gists{/gist_id}","starred_url":"https://api.github.com/users/2maz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2maz/subscriptions","organizations_url":"https://api.github.com/users/2maz/orgs","repos_url":"https://api.github.com/users/2maz/repos","events_url":"https://api.github.com/users/2maz/events{/privacy}","received_events_url":"https://api.github.com/users/2maz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/2maz/base-scripts","description":"Scripts to interact with a Rock installation","fork":true,"url":"https://api.github.com/repos/2maz/base-scripts","forks_url":"https://api.github.com/repos/2maz/base-scripts/forks","keys_url":"https://api.github.com/repos/2maz/base-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/2maz/base-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/2maz/base-scripts/teams","hooks_url":"https://api.github.com/repos/2maz/base-scripts/hooks","issue_events_url":"https://api.github.com/repos/2maz/base-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/2maz/base-scripts/events","assignees_url":"https://api.github.com/repos/2maz/base-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/2maz/base-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/2maz/base-scripts/tags","blobs_url":"https://api.github.com/repos/2maz/base-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/2maz/base-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/2maz/base-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/2maz/base-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/2maz/base-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/2maz/base-scripts/languages","stargazers_url":"https://api.github.com/repos/2maz/base-scripts/stargazers","contributors_url":"https://api.github.com/repos/2maz/base-scripts/contributors","subscribers_url":"https://api.github.com/repos/2maz/base-scripts/subscribers","subscription_url":"https://api.github.com/repos/2maz/base-scripts/subscription","commits_url":"https://api.github.com/repos/2maz/base-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/2maz/base-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/2maz/base-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/2maz/base-scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/2maz/base-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/2maz/base-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/2maz/base-scripts/merges","archive_url":"https://api.github.com/repos/2maz/base-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/2maz/base-scripts/downloads","issues_url":"https://api.github.com/repos/2maz/base-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/2maz/base-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/2maz/base-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/2maz/base-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/2maz/base-scripts/labels{/name}","releases_url":"https://api.github.com/repos/2maz/base-scripts/releases{/id}","created_at":"2014-12-16T12:01:08Z","updated_at":"2014-12-17T18:42:43Z","pushed_at":"2015-08-10T16:09:02Z","git_url":"git://github.com/2maz/base-scripts.git","ssh_url":"git@github.com:2maz/base-scripts.git","clone_url":"https://github.com/2maz/base-scripts.git","svn_url":"https://github.com/2maz/base-scripts","homepage":null,"size":377,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"rock-core:master","ref":"master","sha":"9c9fe7b5b5b637ee4df105f5ed728a7f50790b4d","user":{"login":"rock-core","id":6654878,"avatar_url":"https://avatars.githubusercontent.com/u/6654878?v=3","gravatar_id":"","url":"https://api.github.com/users/rock-core","html_url":"https://github.com/rock-core","followers_url":"https://api.github.com/users/rock-core/followers","following_url":"https://api.github.com/users/rock-core/following{/other_user}","gists_url":"https://api.github.com/users/rock-core/gists{/gist_id}","starred_url":"https://api.github.com/users/rock-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rock-core/subscriptions","organizations_url":"https://api.github.com/users/rock-core/orgs","repos_url":"https://api.github.com/users/rock-core/repos","events_url":"https://api.github.com/users/rock-core/events{/privacy}","received_events_url":"https://api.github.com/users/rock-core/received_events","type":"Organization","site_admin":false},"repo":{"id":19274613,"name":"base-scripts","full_name":"rock-core/base-scripts","owner":{"login":"rock-core","id":6654878,"avatar_url":"https://avatars.githubusercontent.com/u/6654878?v=3","gravatar_id":"","url":"https://api.github.com/users/rock-core","html_url":"https://github.com/rock-core","followers_url":"https://api.github.com/users/rock-core/followers","following_url":"https://api.github.com/users/rock-core/following{/other_user}","gists_url":"https://api.github.com/users/rock-core/gists{/gist_id}","starred_url":"https://api.github.com/users/rock-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rock-core/subscriptions","organizations_url":"https://api.github.com/users/rock-core/orgs","repos_url":"https://api.github.com/users/rock-core/repos","events_url":"https://api.github.com/users/rock-core/events{/privacy}","received_events_url":"https://api.github.com/users/rock-core/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rock-core/base-scripts","description":"Scripts to interact with a Rock installation","fork":false,"url":"https://api.github.com/repos/rock-core/base-scripts","forks_url":"https://api.github.com/repos/rock-core/base-scripts/forks","keys_url":"https://api.github.com/repos/rock-core/base-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rock-core/base-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rock-core/base-scripts/teams","hooks_url":"https://api.github.com/repos/rock-core/base-scripts/hooks","issue_events_url":"https://api.github.com/repos/rock-core/base-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/rock-core/base-scripts/events","assignees_url":"https://api.github.com/repos/rock-core/base-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/rock-core/base-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/rock-core/base-scripts/tags","blobs_url":"https://api.github.com/repos/rock-core/base-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rock-core/base-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rock-core/base-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/rock-core/base-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rock-core/base-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/rock-core/base-scripts/languages","stargazers_url":"https://api.github.com/repos/rock-core/base-scripts/stargazers","contributors_url":"https://api.github.com/repos/rock-core/base-scripts/contributors","subscribers_url":"https://api.github.com/repos/rock-core/base-scripts/subscribers","subscription_url":"https://api.github.com/repos/rock-core/base-scripts/subscription","commits_url":"https://api.github.com/repos/rock-core/base-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/rock-core/base-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/rock-core/base-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/rock-core/base-scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/rock-core/base-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/rock-core/base-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rock-core/base-scripts/merges","archive_url":"https://api.github.com/repos/rock-core/base-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rock-core/base-scripts/downloads","issues_url":"https://api.github.com/repos/rock-core/base-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/rock-core/base-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/rock-core/base-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/rock-core/base-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rock-core/base-scripts/labels{/name}","releases_url":"https://api.github.com/repos/rock-core/base-scripts/releases{/id}","created_at":"2014-04-29T11:50:14Z","updated_at":"2015-05-07T19:45:57Z","pushed_at":"2015-08-10T16:10:26Z","git_url":"git://github.com/rock-core/base-scripts.git","ssh_url":"git@github.com:rock-core/base-scripts.git","clone_url":"https://github.com/rock-core/base-scripts.git","svn_url":"https://github.com/rock-core/base-scripts","homepage":null,"size":635,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":5,"forks":5,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rock-core/base-scripts/pulls/22"},"html":{"href":"https://github.com/rock-core/base-scripts/pull/22"},"issue":{"href":"https://api.github.com/repos/rock-core/base-scripts/issues/22"},"comments":{"href":"https://api.github.com/repos/rock-core/base-scripts/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/rock-core/base-scripts/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/rock-core/base-scripts/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rock-core/base-scripts/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/rock-core/base-scripts/statuses/eac0cb9b072097f3b49327648467f32d2eadf254"}}}}