WebServer Page Update Rate.

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times

WebServer Page Update Rate.

Post by Jay Dee »

Hi working with the basic Webserver example,
Using an ECIO40P (18F4455) and EBlocks with WIZ810MJ module.
The HTML is pretty close to the original;

Code: Select all

<html>
<head>
<title>Embedded Switch Monitor</title>

<script type="text/javascript">

function reFresh()
{
  location.reload(true)
}

window.setInterval("reFresh()",1000);

function checkSwitch()
{
  var temp = %1;

  if(temp > 100)
  {
	document.write(
'<span class=\\"style5\\"><b>Switch Value Over 100</b></span>');
  }
  else
  {
	document.write(
'<span class=\\"style4\\"><b>Switch Value Under 100</b></span>');
  }
}

</script>

<style type="text/css">
.style1 {
	font-size: xx-large;
	font-weight: bold;
	color: #0000FF;
}
.style2 {font-size: medium}
.style3 {font-size: medium; font-weight: bold; color: #0000FF; }
.style4 {color: #00FF00}
.style5 {color: #FF0000}
</style>
</head>
<body>
<p align="center" class="style1">
Embedded Switch Monitor<br>
  <br>
  <span class="style2">
System Status: <span class="style4">
Online</span></span></p>
<p align="center" class="style3">
Sensor Level Raw: %1 </p>
<p align="center" class="style3">
Sensor Level mm: %2 </p>
<p align="center" class="style3">
Sensor Temp C: %3 </p>
<p align="center" class="style3">
Switch Status: <script> checkSwitch() </script></p>
</body>
</html>
So I'm reading out a few extra variables and displaying them.
So my question is how can I make the Webpage, when viewed from an external web browser update quicker?
The FC is changing the values every ~500ms.
When I view the webpage with Chrome, the value will sometimes update around every 5 seconds and sometime stop and the page is reported unresponsive by Chrome.
I guess it to do with this simple Function, but the Value (1000ms) I think is a timeout rather than a refresh rate.

Code: Select all

function reFresh()
{
  location.reload(true)
}

window.setInterval("reFresh()",1000);
I'm a engineer not a coder so even basic HTML is a compleatly new field for me but if I can bash together some basic and reliable Input/Output from a Webserver is could be a fantastic tool for remote sensor projects.
Cheers, J.
Attachments
Apps_Internet_Ex1_Webserver_V2.fcfx
Modified WebServer FC example
(19.16 KiB) Downloaded 224 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: WebServer Page Update Rate.

Post by LeighM »

Hi J.

Code: Select all

window.setInterval("reFresh()",1000);
That code tells the browser to request the page every second. (Or more accurately to request/refresh this page after an interval of 1 second)
How quickly the application is capable of responding is a different matter.
You could try reducing, or indeed removing, the 500ms delay in your loop to give the application more chance to detect and respond to the incoming request.

Leigh

Post Reply