{"id":18647642,"url":"https://github.com/artcom/virtuscope-sensor-server","last_synced_at":"2025-11-05T07:30:28.265Z","repository":{"id":4356670,"uuid":"5492901","full_name":"artcom/virtuscope-sensor-server","owner":"artcom","description":"a small ruby/sinatra application that serves rotary encoder and button values from a virtuscope","archived":false,"fork":false,"pushed_at":"2012-08-22T12:33:16.000Z","size":284,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-12-27T12:21:48.610Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/artcom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-21T09:25:29.000Z","updated_at":"2013-11-04T11:00:06.000Z","dependencies_parsed_at":"2022-09-03T05:51:28.503Z","dependency_job_id":null,"html_url":"https://github.com/artcom/virtuscope-sensor-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artcom%2Fvirtuscope-sensor-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artcom%2Fvirtuscope-sensor-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artcom%2Fvirtuscope-sensor-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artcom%2Fvirtuscope-sensor-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artcom","download_url":"https://codeload.github.com/artcom/virtuscope-sensor-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239449649,"owners_count":19640555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T06:27:16.142Z","updated_at":"2025-11-05T07:30:28.219Z","avatar_url":"https://github.com/artcom.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Ruby Sensor Server\n==================\n\nThe Ruby Sensor Server is a web service that enables developers to access the user interface data of the VirtuScope via Server Sent Events. Values (so far) are:\n\n* horizontal rotary encoder value\n* vertical rotary encoder value\n* all four buttons\n* IO-board temperature\n\nTo run the Server you need the following programs and packages and what comes along with it.\n\n`ruby 1.8.7\n\ngems:\neventmachine (0.12.10)\nruby-serialport (0.7.0)\nsinatra (1.3.2) - git head version recommended, because there is a bug in 1.3.2 [[https://github.com/sinatra/sinatra/issues/446]]\nthin (1.3.1)`\n\nRun the server\n=============\n\nGo into the directory where you checked out the code and execute the following commandline to start the server. You can add the commandline argument \"dummy\" to use dummy data, which is useful to develop and test the server on a machine without serialport or IO-Board attached. The \"dummy\" dummy version replays the data from \"sensordump.txt\".\n\n`$ ruby bin/sensorserver.rb [dummy]`\n\nWatching Status and Demo Page\n=============================\n\nGo into a browser and open http://\u003chostname/ip\u003e:4567 to view the status page. This can be done from any device which is in the network as the VirtuScope. You should then see a page which looks a lot like this:\n\nTo start the status page on the VirtuScope you have to do the following in a terminal:\n\nUsing the Eventstream\n=====================\n\nThe server provides an event stream which can be used by the EventSource Object in any html5 capable web browser.\n\n`\n// this function is executed if the page has been loaded - (uses jQuery)\n$(document).ready(function() {\n        // create event source for virtuscope events\n        var eventsource = new EventSource(\"/event_stream\");\n\n        // connect event listeners for the buttons and orientation\n        eventsource.addEventListener('h', function(msg) { \n            // output rotary encoder data to javascript console.\n            console.log(\"horizontal angle: \" + msg.data); \n            }); \n        };\n`\n\nAvailable events are:\n* \"h\" - horizontal rotary encoder value\n* \"v\" - vertical rotary encoder value\n* \"q\" and \"a\" - left buttons front and back\n* \"p\" and \"l\" - right buttons front and back\n* \"t\" - IO Board temperature, divide by 100 to get degrees (celsius)\n\nThe rotary encoders have a resolution of 12bit, i.e. 360° are split into 4096 steps. \n\nConversion to degrees:\n`\nfunction toDeg(value) {\n    return (Number(x)/4096) * 360;\n}\n`\n\nConversion to radians:\n`\nfunction toDeg(value) {\n    return (Number(x)/4096) * 2 * Math.PI;\n}\n`\n\nOther datasources\n=================\n\nIn addition to the event streams the server send provides xml and json output. \nHere comes the json: http://localhost:4567/sensors.json\n\n`\n{ \n    \"horizontal\" : 1345, \n        \"vertical\" : 52, \n        \"button1\" : 0, \n        \"button2\" : 1, \n        \"button3\" : 0, \n        \"button4\" : 0, \n        \"temperature\" : 3827\n}\n`\n\nHere come the xml: http://localhost:4567/sensors.xml\n\n`\n\u003csensors\u003e\n\u003csensor id=\"h\" name=\"horizontal\"\u003e1345\u003c/sensor\u003e\n\u003csensor id=\"v\" name=\"vertical\"\u003e52\u003c/sensor\u003e\n\u003csensor id=\"q\" name=\"button1\"\u003e0\u003c/sensor\u003e\n\u003csensor id=\"a\" name=\"button2\"\u003e1\u003c/sensor\u003e\n\u003csensor id=\"p\" name=\"button3\"\u003e0\u003c/sensor\u003e\n\u003csensor id=\"l\" name=\"button4\"\u003e0\u003c/sensor\u003e\n\u003csensor id=\"t\" name=\"temperature\"\u003e3827\u003c/sensor\u003e\n\u003c/sensors\u003e\n`\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartcom%2Fvirtuscope-sensor-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartcom%2Fvirtuscope-sensor-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartcom%2Fvirtuscope-sensor-server/lists"}