Application for Web-Thermograph:
Mercury thermometer
More links
The value measured by the Web-Thermograph / Web-Thermo-Hygrograph can be easily visualized on a Web page using JavaScript and a few images. By incorporating the Web-Thermograph applet you ensure continuous updating of the measured value display.
Using the following copy & paste example you can display a temperature value measured by your Web-Thermograph on a Web page in the form of a mercury thermometer.
Preparations
You have already supplied your Web-Thermograph
- with power,
- connected it to your network,
- assigned it an IP address - which with WuTility is no problem.
1. Incorporate JavaScript into the Web page
Copy the JavaScript (shown in blue) from the following example into the <head> area of your Web page.
<html>
<head>
<title>Zeiger</title>
<script language="JavaScript" type="text/javascript">
<!--
document.write("<a href=’javascript:showgrad();’><img
border=’0’ src=’Thermometer.gif’ style=’position:absolute; top:10px; left:10px’>");
var thermometer = new multipic(301,"Thermometer","gif",91,100,50,"showgrad");
var grad;
function multipic(id, img_name, img_ext, img_count, ypos, xpos, link)
{
img_count++;
this.multipics = new Array( img_count );
this.multipic_count = img_count;
this.multipic_id = id; // class variables
for (i=0; i<img_count; i++)
{
this.multipics[i] = new Image();
this.multipics[i].src = img_name+i+’.’+img_ext;
}
this.Set = picSet; // class method
if (link == "nolink")
{
document.write("<img id=’"+this.multipic_id+"’
style=position:absolute;top:"+ypos+"px;left:"+xpos+"px
src="+this.multipics[0].src+" border=0>");
}
else
{
document.write("<a href=’javascript:" + link + "("
+ id + ");’><img id=’"+this.multipic_id+"’
style=position:absolute;top:"+ypos+"px;left:"+xpos+"px
src="+this.multipics[0].src+" border=0></a>");
}
}
function showgrad()
{
alert("Aktueller Wert: "+grad+"°");
}
function picSet(iCount)
{
for (i=0; i<this.multipic_count; i++)
{
if(iCount==i)
{
document.getElementById(this.multipic_id).src = this.multipics[i].src;
}
}
}
function sensorChanged( iDevice, iSensor, iVal )
{
if (iSensor==0)
{
grad = iVal;
if(iVal!=0)
{
thermometer.Set(Math.round(iVal)+20);
}
else
{
thermometer.Set(0);
}
}
}
</script>
</head>
- Copy the applet data (shown in green) into the <body> area of your Web page.
- Insert the IP address of your Web-Thermograph.
<body>
<applet name="Analog" archive="A.jar" code="A.class" codebase="http://10.40.23.16" height="0" width="0" mayscript>
<param name="device" value="0">
<param name="showerrors" value="off">
<param name="sensorpolling" value="on">
<param name="pollingrate" value="1000">
</applet>
</body>
</html>
- Now all you need is the images associated with the display object, which we have provided here for downloading: .zip (approx. 232 kB). Please place the images in the directory in which the Web page with the JavaScript and applet data are located.