This is an example of how to use Robot Web Services in a web application using JavaScript.
- Create a folder named docs under the HOME folder on the controller.
- Copy the html file to the HOME/docs folder
- Enter the URL {controller ipaddr}/docs/HelloControllerHtml.html in a web browser. (Depending on your network; you migth need to disable the proxy in your web browser)
- For a VC type the URL http://127.0.0.1/docs/HelloControllerHtml.html in the browser
The output will look like:
service=RW6_1014
version=6.00.1014.00
OS RobotWare OS and English
Options 613-1 Collision Detection
Options 614-1 FTP and NFS client
Options 616-1 PC Interface
Options 628-1 Sensor Interface
Manipulators ABB standard manipulator
...
Program:
<!DOCTYPE html>
<html>
<head>
<script>
function getRWServiceResource()
{
var rwServiceResource = new XMLHttpRequest();
// function is called when data has been received
rwServiceResource.onreadystatechange = function()
{
if (rwServiceResource.readyState == 4 && rwServiceResource.status == 200)
{
var obj = JSON.parse(rwServiceResource.responseText);
var service = obj._embedded._state[0];
document.getElementById("name").innerHTML = "service=" + service.name;
document.getElementById("version").innerHTML = "version=" + service.rwversion;
document.getElementById("versionname").innerHTML = "versionname=" + service.rwversionname;
var index;
for(index = 0; index < obj._embedded._state[1].options.length; index++)
{
var option = obj._embedded._state[1].options[index];
var liNode = document.createElement("li");
var optNode = document.createTextNode("option=" + option.option);
liNode.appendChild(optNode);
document.getElementById("options").appendChild(liNode);
}
}
}
// get the resource
rwServiceResource.open("GET","/rw/system?json=1",true);
rwServiceResource.send();
}
</script>
</head>
<body>
<button type="button" onclick="getRWServiceResource()">Get RW Service</button>
<div id="name"></div>
<div id="version"></div>
<div id="versionname"></div>
<div id="options"></div>
</body>
</html>