added distance calculator
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 8 Dec 2010 06:35:53 +0000 (06:35 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 8 Dec 2010 06:35:53 +0000 (06:35 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@265 01035d8c-6547-0410-b346-abe4f91aad63

dilimesh/README.txt
dilimesh/dilimesh/dilimesh.html

index 622edba6ffde7f8f5a72ff869ee1a3d22d75102e..9a057bd67c7f8183f4daa3609794daa88e4afe10 100644 (file)
@@ -213,7 +213,7 @@ Tests
    $ cat /var/www/dilimesh/nodes.txt
    (empty file)
 
-7/ Test signal strength daemon:
+7/ Test signal strength daemon on each node:
 
    $ telnet 10.130.1.1 4950
    Trying 10.130.1.36...
@@ -223,6 +223,7 @@ Tests
    10.130.1.1 10.130.1.56 10.130.1.14
    -64 -90 -75
 
+
 Using Dilimesh
 --------------
 
@@ -233,14 +234,19 @@ Using Dilimesh
 3/ Dilimesh will find new nodes automatically.  Drag bouncing nodes
    to the correct position on map.
 
-4/ Mouse over or click to get node IP and packet loss.  Right click to
-   delete node. Colours:
+4/ Mouse over or click on a node to get IP and packet loss.  If nodes
+   are running signal strength daemon signal strengths of adjacent
+   nodes will also be displayed.
+
+5/ Click on links to get "Distance" stats on lower right hand side.
+
+5/ Node colours:
      * blue  - packet loss < 10%
      * red   - packet loss between 10% and 90%
      * black - packet loss > 90%
 
-5/ "Update Enable" will update packet loss and network links
-    automatically.
+5/ "Update Enable" will update packet loss, network links and signal
+    strength automatically.
 
 
 Debugging
index 9f1bcb847a0515b14313e73db69908febaef88aa..8a2d724666dedfb85fda3c815683851a602ce059 100644 (file)
   }
 
 
+  // calculate distance between two points
+
+  rad = function(x) {return x*Math.PI/180;}
+
+  distHaversine = function(p1, p2) {
+    var R = 6371; // earth's mean radius in km
+    var dLat  = rad(p2.lat() - p1.lat());
+    var dLong = rad(p2.lng() - p1.lng());
+
+    var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
+            Math.cos(rad(p1.lat())) * Math.cos(rad(p2.lat())) * Math.sin(dLong/2) * Math.sin(dLong/2);
+    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
+    var d = R * c;
+
+    return d.toFixed(3);
+  }
+
+
   // draw lines indicating links between nodes 
 
   function drawPathesBetweenNodes() {
         }    
 
        if ((router_location != undefined) && (neighbour_location != undefined)) {
-          // draw polyline between locations
+         // draw polyline between locations
 
           var coords = [
             router_location,
           var path = new google.maps.Polyline({
             path: coords,
             strokeColor: "#008000",
-            strokeOpacity: 1.0,
-            strokeWeight: 2
+            strokeOpacity: 0.5,
+            strokeWeight: 5
           });
           path.setMap(map);
 
+          // click on line to get distance and path loss estimates
+
+          google.maps.event.addListener(path, "click", function() {
+            var path = this.getPath();
+            var dist = distHaversine(path.b[0], path.b[1]) * 1000;
+            var path_loss = 100.0 + 20*Math.log(dist/1000)/Math.log(10);
+            path_loss =  Math.round(path_loss);
+
+            // est rx power: 
+            //   MP tx pwr between 15 and 20dB depending on rate
+            //   roughly 2dB antennas
+
+            var est_rx_sig = 17 + 2 + 2 - path_loss;
+
+            document.getElementById('distance').innerHTML = dist + ' m';
+            document.getElementById('path_loss').innerHTML = -path_loss + ' dBm';
+            document.getElementById('est_rx_sig').innerHTML = est_rx_sig + ' dBm';
+          });
+         
           pathes.push(path);
         }  
       }          
           <td><div id="sigstr_results"></div></td>
         </tr>
         </table>
+
+      <h3>Distance</h3>
+        <table>
+        <tr>
+         <td width="5%"></td>
+          <td valign=top>Distance</td>
+          <td><div id="distance"></div></td>
+        </tr>
+        <tr>
+         <td></td>
+          <td valign=top>Path Loss</td>
+          <td><div id="path_loss"></div></td>
+        </tr>
+        <tr>
+         <td></td>
+          <td valign=top>Est Rx Signal</td>
+          <td><div id="est_rx_sig"></div></td>
+        </tr>
+        </table>
     </div>
 
     <div id="tests" style="width: 100%;">