PDA

View Full Version : Is it possible and best way to..


kevinyeandel
08-14-2007, 02:34 AM
I'm just trying to get into OL as a choice of OS independant platform and have a couple of technical questions. Might be an idea if I told you what I was up to in the process.

I need 'near' real-time updates to be displayed from electronic instruments. These instruments have an embedded web server on a microchip.

I need to request data from the microchip like so: http://192.168.1.1/peek?read=M15

and the microchip will respond with

<html>1234.5678</html>

Question 1. How close to "real-time" updates can I get my OL web page to be, are there any tricks and best practices.. I need about once or twice per second. Any more than this is a bonus. Could I set up a loop to request/respond and is there any best practice for doing this?

Question 2. If Question 1 is successful, anyone know of some code examples for electronic meters? e.g. 7 segment displays, analogue meters.
I'd prefer not to get into learning Flash and see that this product has an excellent graphic capability.

I have actually googled about for info but not been overly successful.
Any information will be very much appreciated.

Many thanks in advance for your help.


Kevin

notzippy
08-14-2007, 06:30 AM
LzTimer can be used with a delegate. It does not gurantee the interval however. And just cause Im slightly insane about electronics I whipped up a simple 7 segment control

<canvas bgcolor="blue">

<class name="meter" extends="baseformitem">
<attribute name="segments" type="number" value="7"/>
<attribute name="swidth" type="number" value="10"/>
<attribute name="height" value="20"/>
<attribute name="maxvalue" type="number" value="100"/>
<attribute name="warning" type="number" value="65"/>
<attribute name="redline" type="number" value="85"/>
<attribute name="minvalue" type="number" value="0"/>
<attribute name="_ptweigtht" type="number" value="${bgview.width/(maxvalue-minvalue)}"/>
<attribute name="bgcolor" value="black"/>

<view x="1" y="1" name="bgview" width="${parent.swidth * parent.segments - 2}"
height="${parent.height - 2 }" clip="true" bgcolor="green">
<view name="warning" x="${(classroot.warning - classroot.minvalue) * classroot._ptweigtht}" width="${parent.width}" height="${parent.height}" bgcolor="yellow"/>
<view name="redline" x="${(classroot.redline - classroot.minvalue) * classroot._ptweigtht}" width="${parent.width}" height="${parent.height}" bgcolor="red"/>
<drawview name="sgdrawer" width="${parent.width}" height="${parent.height}"
fgcolor="black">
<handler name="oninit">
<![CDATA[
var ptwt = classroot._ptweigtht;
var tw = classroot.bgview.width/(classroot.segments-1);
this.clear();
for(var x=0;x<(classroot.segments-1);x++) {
// Draw a verticle line
this.moveTo(tw * x, 0);
this.lineTo(tw * x, this.height);
}

this.strokeStyle = 0xffff00;
this.lineWidth = 5;
this.stroke();

]]>
</handler>
</drawview>
<view name="positionedview"
x="${Math.max(0,(Number(classroot.value)-classroot.minvalue)*classroot._ptweigtht)}"
width="${parent.width}" height="${parent.height}" bgcolor="black"/>
</view>
</class>

<!-- create the meter and a slider -->
<view layout="axis:y">
<meter name="testmeter" value="52"/>
<slider x="20" y="20" width="300" value="50">
<handler name="onvalue">
parent.testmeter.setValue(this.value)
</handler>
</slider>

</view>

</canvas>

kevinyeandel
08-15-2007, 05:52 AM
Wow,
Thanks so much for the heads up and the amazing effort you went to.
Really appreciate this - very useful and got me started.

Best wishes

Kevin

kmeixner
08-15-2007, 07:39 AM
My experience with using the LzTimer class with LzDelegates in OpenLaszlo on IE6+ and FireFox 2+ is that they will fire within 200milliseconds or less from when they should. They fire about 40ms sooner through FireFox than IE most of the time.

Kevin