W&T connects
Interfaces for TCP/IP, Ethernet, RS-232, RS-485, USB, 20mA, glass and plastic fiber optic cable, http, SNMP, OPC, Modbus TCP, I/O digital, I/O analog, ISA, PCI

Application for the Web-IO Digital:

Counter


Counter

The inputs, counter and outputs of the Web-IO Digital can be simply Visualized on a Web page using JavaScript and a few images. Incorporation of the Web-IO applet provides for continuous updating of the display.

Using the following copy&paste example you can represent a current value measured by your Web-IO Digital on a Web page.



Preparations

You have already provided your Web-IO Digital

  • 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>Counter</title>
	<script language="JavaScript" type="text/javascript">
	<!--
		var ypositopn = 223;
		var xposition = 100;
		var xdifferenc = 14;
		var maxdigits = 6;
		document.write("<img border='0' src='cmeter.gif' style='position:absolute; top:190px; left:36px'>");
		counterdigit = new Array(maxdigits);
		for (i=0; i<maxdigits; i++)
		{ counterdigit[i] = new multipic(100+i,"digit_","gif",9,ypositopn,xposition + i*xdifferenc,'nolink');
		}
		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 (ii=0; ii<img_count; ii++)
		{	this.multipics[ii] = new Image();
			this.multipics[ii].src = img_name+ii+'.'+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 picSet(iCount)
		{	for (ii=0; ii<this.multipic_count; ii++)
			{	if(iCount==ii)
				{	document.getElementById(this.multipic_id).src = this.multipics[ii].src;
				}
			}
		}
		function counterChanged( iDevice, iNr, iVal )
		{	if (iNr==0)
			{
			var i=maxdigits;
			var digitvalue;
			window.status=iVal;
			do
			{
			i--
			digitvalue = parseInt(iVal/Math.pow(10,i));
			counterdigit[maxdigits-1-i].Set(digitvalue);
			iVal=iVal-digitvalue*Math.pow(10,i);
			}
			while(i> 0)
			}
			else
			{	iVal = 0;
		}
		}
		function setPassword()
		{
		document.applets["dio"].setPassword( document.forms[0].tfPassword.value );
		document.forms[0].tfPassword.value = '';
		}
	</script>
</head>
...
2. Incorporate applet into Web page
  • Copy the applet data (in blue) to the <body> area of your Web page.
  • Insert the IP address of your Web-IO Analog.
...
<body style="font-family: Arial, Helvetica, sans-serif;">
	<applet name="dio" archive="dio.jar" code="dio.class" codebase="http://10.40.50.5" height="0" width="0" mayscript>
			<param name="device" value="0">
			<param name="showerrors" value="off">
			<param name="inputpolling" value="off">
			<param name="outputpolling" value="off">
			<param name="counterpolling" value="on">
			<param name="pollingrate" value="1000">
			Java ist nicht aktiviert oder wird nicht unterstützt
	</applet>
...
3. Password form

If your Web-IO is password protected, also copy the password form (shown in blue) to the <body> area of your Web page. In this case the Web page can only communicate with the Web-IO after the password has been sent.

...
	<form>
		<p>Passwort:
			<input type="password" name="tfPassword" maxlength="31" size="20">
			<input type="button" value="senden" onclick="setPassword()">
		</p>
	</form>
</body>
</html>
4. Download and save images

Now all you need is the images associated with the display object, which we have provided here for downloading: .zip (approx. 11 kB). Please place the images in the directory in which the Web page with the JavaScript and applet data are located.

Download program example

You don’t have a Web-IO yet but would like to try the example out sometime?

No problem: We will be glad to send you the Web-IO Digital 2xInput, 2xOutput PoE at no charge for 30 days. Simply fill out a sample ordering form, and we will ship the Web-IO for testing on an open invoice. If you return the unit within 30 days, we will simply mark the invoice as paid.

To sample orders