vrpn-webapp
A vrpn server and http server for webapp controlers (smartphones, tablets, computers.)
This material is based upon work supported by the National Science Foundation under Grant No. 1133590. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.
Usage
After setting up your config file to contain the control you require, save the file and run vrpn-webapp.exe. Using the ports defined in the config file, the vrpn server and web server will start hosting. By navigating to ip address of the hosting machine with a web browser, you will view the controls as defined in your config file. You can also now connect to the vrpn server from you application. NOTE: vrpn does not send the current state of devices upon connection. So your application needs to assume the default values as defined in your config file, and you need to refresh the webpage whenever you restart your application.
Config
Two files in the config folder are used for configuration of the devices you want to use. Config.json contains the configuration for the devices and the ports to use for the vrpn and html servers. Style.css is available to use if you want to change the look of your interface. Each element has it's set ID based on the vrpn name of the device. I recomend using Chrome's inspect capability to view the final html given by config.json.
Config.json must be a well formated json file. The vrpnPort parameter defines which port vrpn should use to create it's server, likewise with the httpPort. The parameter "devices" is an array of devices to display on screen. The order of devices does NOT define the order of devices on the page. Use css if you want to edit the positions of the devices on the page. The parameters of each device is as follows:
Any Device
- name - Defines the name of the vrpn device, and the id of the html dom element.
- class - Which type of device it is. This defines both of what type of control to use on the webpage, and also what kind of vrpn device it is.
- displayName - The name or label to display on the webpage.
Class "button"
A vrpn_button with one channel. Displays as an html button, activating when pressed.
No additional parameters
Example:
{
"name":"Button0",
"class":"button",
"displayName":"Clickable Button"
}
Class "toggle"
A vrpn_button with one channel. Displays as a checkbox, activating when the checkbox is checked.
- initial - Whether to start checked or not.
Example:
{
"name":"Button0",
"class":"toggle",
"displayName":"Checkbox",
"initial":true
}
Class "slider"
A vrpn_analog with one channel. Displays as a range slider, returning the value of the slider.
- range - An array of the minumum and maximum values.
- initial - The initial value of the slider. Must be an integer value.
- step - How much the value changes by moving slider one tick.
Example:
{
"name":"Analog0",
"class":"slider",
"displayName":"Example SLider",
"range":[0,100],
"initial":50,
"step": 1
}
Class "spinner"
A vrpn_analog with one channel. Displays as a textbox with a number in it with up and down buttons on the side, returning the value of the textbox.
- range - An array of the minumum and maximum values. NOTE: Users can enter values outside this range, but using the up and down arrows is limited by this range.
- initial - The initial value of the textbox.
- step - How much the value changes by one click.
Example:
{
"name":"Analog1",
"class":"spinner",
"displayName":"A textbox with number controls",
"range":[0,100],
"initial":50,
"step": 1
}
Building
To build the shared library (DLL) you'll need vrpn. The main vrpn static library needs to be linked along with adding the top level vrpn folder to the include path. I also linked/included the quat directory in vrpn, but I'm unsure if that's required.
The go build command is used to build the final executable.
The only files/folders needed in realese should be the executable, the dll, the static folder and the config folder.