Permalink
Browse files

Add simulation of traffic in time table and after including delay

  • Loading branch information...
1 parent 46cc26f commit 579e9c22559c4e1afffa47cb4b1b8c88edace0d0 @snktagarwal committed Apr 4, 2012
View
20 delay_simulation/README
@@ -0,0 +1,20 @@
+How to run this application
+==========================
+
+The ideal way is to have a apache.conf file (as in this folder) and link it
+with you main apache2.conf file. In your /etc/apache2/apache.conf file
+put this line:
+* Include "/home/sanket/irn-hacku/apache.conf" -- this is for me
+
+Next you need to configure the local apache.conf file, there is a directory location. Just change it to wherever your source is, ex:
+* Alias "/home/sanket/irn-hacku/src/"
+
+To set the config right, just do this:
+
+* sudo service apache2 restart
+
+Your code should be available at:
+
+* http://localhost/irn/
+
+Just make sure your browser has proxy disabled
View
9 delay_simulation/apache.conf
@@ -0,0 +1,9 @@
+# Install this file in apache2.conf file
+
+Alias /irn_delay "/home/sanket/src/IRN/delay_simulation/"
+
+<Directory "/home/sanket/src/IRN/delay_simulation/">
+ Options FollowSymLinks
+ Order allow,deny
+ Allow from all
+</Directory>
View
428,478 delay_simulation/data/NewTrainStationDetailWDelayWSegments.json
428,478 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
50,757 delay_simulation/data/NewTrainStationWSegmentsWDays.min.json
50,757 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
59 delay_simulation/data/segments.js
@@ -0,0 +1,59 @@
+{"segments": [
+ {"segment":{
+ "seg_name": "mgs_gaya",
+ "seg_list": [{"lat": "25.2814947", "lng": "83.1198203"},{"lat": "24.900207", "lng": "84.181077"},{"lat": "24.7800113", "lng": "84.9818234"}]}},
+ {"segment":{"seg_name": "bsl_kalyan", "seg_list": [{"lat": "21.0473709", "lng": "75.787659"},{"lat": "20.249901", "lng": "74.43586"},{"lat": "19.25", "lng": "73.13"}]}},
+ {"segment":{"seg_name": "cnb_ald", "seg_list": [{"lat": "26.4546472", "lng": "80.3510491"},{"lat": "25.4358011", "lng": "81.846311"}]}},
+ {"segment":{"seg_name": "dhanbad_kolkata", "seg_list": [{"lat": "23.7956531", "lng": "86.4303859"},{"lat": "23.68721", "lng": "86.973343"},{"lat": "23.496531", "lng": "87.324203"},{"lat": "22.5957689", "lng": "88.2636394"}]}},
+ {"segment":{"seg_name": "mao_maq", "seg_list": [{"lat": "15.2719444", "lng": "73.9583333"},{"lat": "12.9141417", "lng": "74.8559568"}]}},
+ {"segment":{"seg_name": "bza_chennai", "seg_list": [{"lat": "16.5061743", "lng": "80.6480153"},{"lat": "16.3066525", "lng": "80.4365402"},{"lat": "13.0820617", "lng": "80.2755868"}]}},
+ {"segment":{"seg_name": "pune_hydbad", "seg_list": [{"lat": "18.5204303", "lng": "73.8567437"},{"lat": "17.6599188", "lng": "75.9063906"},{"lat": "17.05397", "lng": "76.993767"},{"lat": "17.453333", "lng": "78.4625"}]}},
+ {"segment":{"seg_name": "kota_brc", "seg_list": [{"lat": "25.1695114", "lng": "75.8539898"},{"lat": "23.330412", "lng": "75.044315"},{"lat": "22.3073095", "lng": "73.1810976"}]}},
+ {"segment":{"seg_name": "lko_bsb", "seg_list": [{"lat": "26.8465108", "lng": "80.9466832"},{"lat": "26.2647757", "lng": "82.0727061"},{"lat": "25.3176452", "lng": "82.9739144"}]}},
+ {"segment":{"seg_name": "st_mumbai", "seg_list": [{"lat": "21.195", "lng": "72.819444"},{"lat": "18.9709308", "lng": "72.8188191"}]}},
+ {"segment":{"seg_name": "maq_ers", "seg_list": [{"lat": "12.9141417", "lng": "74.8559568"},{"lat": "11.8688889", "lng": "75.3555556"},{"lat": "11.2587531", "lng": "75.78041"},{"lat": "10.01486", "lng": "76.303467"}]}},
+ {"segment":{"seg_name": "mgs_pnbe", "seg_list": [{"lat": "25.2814947", "lng": "83.1198203"},{"lat": "25.5587969", "lng": "84.667097"},{"lat": "25.6125", "lng": "85.1283333"}]}},
+ {"segment":{"seg_name": "kte_r", "seg_list": [{"lat": "23.836081", "lng": "80.39547"},{"lat": "22.0796251", "lng": "82.1391412"},{"lat": "21.2513844", "lng": "81.6296413"}]}},
+ {"segment":{"seg_name": "gtl_chennai", "seg_list": [{"lat": "15.16782", "lng": "77.37117"},{"lat": "14.4673541", "lng": "78.8241339"},{"lat": "13.6373112", "lng": "79.5035957"},{"lat": "13.0820617", "lng": "80.2755868"}]}},
+ {"segment":{"seg_name": "ujn_et", "seg_list": [{"lat": "23.1793013", "lng": "75.7849097"},{"lat": "23.2599333", "lng": "77.412615"},{"lat": "22.609801", "lng": "77.769424"}]}},
+ {"segment":{"seg_name": "cnb_lko", "seg_list": [{"lat": "26.4546472", "lng": "80.3510491"},{"lat": "26.8465108", "lng": "80.9466832"}]}},
+ {"segment":{"seg_name": "kolkata_mldt", "seg_list": [{"lat": "22.5957689", "lng": "88.2636394"},{"lat": "25.0108408", "lng": "88.1410967"}]}},
+ {"segment":{"seg_name": "bbs_vskp", "seg_list": [{"lat": "20.2960587", "lng": "85.8245398"},{"lat": "18.1066576", "lng": "83.3955506"},{"lat": "17.6868159", "lng": "83.2184815"}]}},
+ {"segment":{"seg_name": "wardha_hydbad", "seg_list": [{"lat": "20.745319", "lng": "78.6021946"},{"lat": "17.972366", "lng": "79.5034501"},{"lat": "17.453333", "lng": "78.4625"}]}},
+ {"segment":{"seg_name": "delhi_agc", "seg_list": [{"lat": "28.635308", "lng": "77.22496"},{"lat": "27.4924134", "lng": "77.673673"},{"lat": "27.1766701", "lng": "78.0080745"}]}},
+ {"segment":{"seg_name": "agc_jhs", "seg_list": [{"lat": "27.1766701", "lng": "78.0080745"},{"lat": "26.2182871", "lng": "78.1828308"},{"lat": "25.444121", "lng": "78.567604"}]}},
+ {"segment":{"seg_name": "bilaspur_rourkela", "seg_list": [{"lat": "22.0796251", "lng": "82.1391412"},{"lat": "22.249444", "lng": "84.882988"}]}},
+ {"segment":{"seg_name": "umb_delhi", "seg_list": [{"lat": "30.3781788", "lng": "76.7766974"},{"lat": "29.39", "lng": "76.97"},{"lat": "28.635308", "lng": "77.22496"}]}},
+ {"segment":{"seg_name": "umb_mb", "seg_list": [{"lat": "30.3781788", "lng": "76.7766974"},{"lat": "28.8315925", "lng": "78.7782764"}]}},
+ {"segment":{"seg_name": "ers_tvc", "seg_list": [{"lat": "10.01486", "lng": "76.303467"},{"lat": "9.4980667", "lng": "76.3388484"},{"lat": "8.4874949", "lng": "76.948623"}]}},
+ {"segment":{"seg_name": "gaya_dhn", "seg_list": [{"lat": "24.7800113", "lng": "84.9818234"},{"lat": "23.874821", "lng": "86.159767"},{"lat": "23.7956531", "lng": "86.4303859"}]}},
+ {"segment":{"seg_name": "bsb_see", "seg_list": [{"lat": "25.3176452", "lng": "82.9739144"},{"lat": "25.70774360", "lng": "85.18900180"}]}},
+ {"segment":{"seg_name": "jhs_bpl", "seg_list": [{"lat": "25.444121", "lng": "78.567604"},{"lat": "24.169331", "lng": "78.187897"},{"lat": "23.2599333", "lng": "77.412615"}]}},
+ {"segment":{"seg_name": "kte_et", "seg_list": [{"lat": "23.836081", "lng": "80.39547"},{"lat": "23.165586", "lng": "79.9430299"},{"lat": "22.609801", "lng": "77.769424"}]}},
+ {"segment":{"seg_name": "ald_mgs", "seg_list": [{"lat": "25.4358011", "lng": "81.846311"},{"lat": "25.2814947", "lng": "83.1198203"}]}},
+ {"segment":{"seg_name": "njp_guwahati", "seg_list": [{"lat": "26.6824333", "lng": "88.4438898"},{"lat": "26.3490445", "lng": "89.4659462"},{"lat": "26.4757382", "lng": "90.5359743"},{"lat": "26.147129", "lng": "91.7355511"}]}},
+ {"segment":{"seg_name": "see_kir", "seg_list": [{"lat": "25.70774360", "lng": "85.18900180"},{"lat": "25.68", "lng": "85.22"},{"lat": "25.469312", "lng": "85.987525"},{"lat": "25.53754", "lng": "87.566093"}]}},
+ {"segment":{"seg_name": "mumbai_mao", "seg_list": [{"lat": "18.9709308", "lng": "72.8188191"},{"lat": "16.99202", "lng": "73.2923129"},{"lat": "15.2719444", "lng": "73.9583333"}]}},
+ {"segment":{"seg_name": "garwa_gomoh", "seg_list": [{"lat": "24.2146681", "lng": "83.8870563"},{"lat": "23.6199939", "lng": "85.4558069"},{"lat": "23.874821", "lng": "86.159767"}]}},
+ {"segment":{"seg_name": "asr_umb", "seg_list": [{"lat": "31.6339793", "lng": "74.8722642"},{"lat": "31.3260152", "lng": "75.5761829"},{"lat": "31.3260152", "lng": "75.5761829"},{"lat": "30.900965", "lng": "75.8572758"},{"lat": "30.3781788", "lng": "76.7766974"}]}},
+ {"segment":{"seg_name": "mumbai_pune", "seg_list": [{"lat": "18.9709308", "lng": "72.8188191"},{"lat": "18.5204303", "lng": "73.8567437"}]}},
+ {"segment":{"seg_name": "vskp_bza", "seg_list": [{"lat": "17.6868159", "lng": "83.2184815"},{"lat": "17.4268845", "lng": "82.6896447"},{"lat": "16.5061743", "lng": "80.6480153"}]}},
+ {"segment":{"seg_name": "delhi_cnb", "seg_list": [{"lat": "28.635308", "lng": "77.22496"},{"lat": "27.89381", "lng": "78.068138"},{"lat": "27.210246", "lng": "78.23297"},{"lat": "26.7793556", "lng": "79.0185723"},{"lat": "26.4546472", "lng": "80.3510491"}]}},
+ {"segment":{"seg_name": "bina_kte", "seg_list": [{"lat": "24.169331", "lng": "78.187897"},{"lat": "23.836081", "lng": "80.39547"}]}},
+ {"segment":{"seg_name": "wadi_blore", "seg_list": [{"lat": "17.05397", "lng": "76.993767"},{"lat": "15.16782", "lng": "77.37117"},{"lat": "12.9715987", "lng": "77.5945627"}]}},
+ {"segment":{"seg_name": "et_bsl", "seg_list": [{"lat": "22.609801", "lng": "77.769424"},{"lat": "21.0473709", "lng": "75.787659"}]}},
+ {"segment":{"seg_name": "adi_surat", "seg_list": [{"lat": "23.0395677", "lng": "72.5660045"},{"lat": "22.3073095", "lng": "73.1810976"},{"lat": "21.195", "lng": "72.819444"}]}},
+ {"segment":{"seg_name": "bsl_ngp", "seg_list": [{"lat": "21.0473709", "lng": "75.787659"},{"lat": "20.745319", "lng": "78.6021946"},{"lat": "21.1458004", "lng": "79.0881546"}]}},
+ {"segment":{"seg_name": "coimbatore_chennai", "seg_list": [{"lat": "11.0168445", "lng": "76.9558321"},{"lat": "11.664325", "lng": "78.1460142"},{"lat": "13.0820617", "lng": "80.2755868"}]}},
+ {"segment":{"seg_name": "mj_adi", "seg_list": [{"lat": "25.735571", "lng": "73.610893"},{"lat": "24.479394", "lng": "72.7838699"},{"lat": "23.0395677", "lng": "72.5660045"}]}},
+ {"segment":{"seg_name": "r_vskp", "seg_list": [{"lat": "21.2513844", "lng": "81.6296413"},{"lat": "20.2885278", "lng": "83.1511111"},{"lat": "18.1066576", "lng": "83.3955506"},{"lat": "17.6868159", "lng": "83.2184815"}]}},
+ {"segment":{"seg_name": "mb_lko", "seg_list": [{"lat": "28.8315925", "lng": "78.7782764"},{"lat": "26.8465108", "lng": "80.9466832"}]}},
+ {"segment":{"seg_name": "et_ngp", "seg_list": [{"lat": "22.609801", "lng": "77.769424"},{"lat": "21.9192675", "lng": "78.1279359"},{"lat": "21.1458004", "lng": "79.0881546"}]}},
+ {"segment":{"seg_name": "delhi_jp", "seg_list": [{"lat": "28.635308", "lng": "77.22496"},{"lat": "28.18811", "lng": "76.611542"},{"lat": "27.5609324", "lng": "76.6250168"},{"lat": "26.9124165", "lng": "75.7872879"}]}},
+ {"segment":{"seg_name": "jp_mj", "seg_list": [{"lat": "26.9124165", "lng": "75.7872879"},{"lat": "26.45", "lng": "74.64"},{"lat": "25.735571", "lng": "73.610893"}]}},
+ {"segment":{"seg_name": "kolkata_kgp", "seg_list": [{"lat": "22.5957689", "lng": "88.2636394"},{"lat": "22.3304", "lng": "87.318108"}]}},
+ {"segment":{"seg_name": "delhi_mb", "seg_list": [{"lat": "28.635308", "lng": "77.22496"},{"lat": "28.8315925", "lng": "78.7782764"}]}},
+ {"segment":{"seg_name": "pnbe_asn", "seg_list": [{"lat": "25.6125", "lng": "85.1283333"},{"lat": "23.68721", "lng": "86.973343"}]}},
+ {"segment":{"seg_name": "kgp_bbs", "seg_list": [{"lat": "22.3304", "lng": "87.318108"},{"lat": "20.2960587", "lng": "85.8245398"}]}}
+ ]
+ }
View
84 delay_simulation/index.html
@@ -0,0 +1,84 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCu6j3hJiFtxsHfFXt5qCXK-kL81Vxvqj4&sensor=false" type="text/javascript"></script>
+ <script src="http://code.jquery.com/jquery-latest.js"></script>
+ <script src="js/epoly_v3.js" type="text/javascript"></script>
+ <script src="js/jstat.js" type="text/javascript"></script>
+ <!--script src="../NewTrainStationWSegmentsWDays.min.json" type="text/javascript"></script-->
+ </head>
+ <body onunload="GUnload()" style="bgcolor: #ff0000; width: 1200px">
+ <table>
+
+ <tr> <!-- Information row -->
+ <td style="verticle-align: top; width: 6000px">
+
+ <button onclick="reset();" value="Reset" >Reset</button>
+ <button onclick="start();" id="anim" >Start</button>
+ <div id="time"><b>Time</b>(day:hr::min): 0 :: 0 :: 0</div>
+ Speed:&nbsp &nbsp <input id="range" type="range" min="1" max="40" value="6" step="1" onkeyup="showValue(this.value)" /><span id="timeScale" >6</span>
+ <br/>
+ <br/>
+
+ </td>
+ <td>
+
+ <button onCLick="setTime();" id="setTime" >Set</button>
+ <button onCLick="viewAsyncTraffic();" id="viewAsyncTraffic" >View</button>
+ <br/>
+ Set Time:<input id="Trange" type="range" min="1" max="48" value="0" step="1" width="300px" onkeyup="showValueTime(this.value)" /> <span id="time-line" > 00::00 </span>
+ <div id="SegTot_normal">Total running trains(MAP_NORMAL): </div>
+ <div id="SegTot_delay">Total running trains(MAP_DELAY) : </div>
+ </tr>
+
+ <!---
+ Enter Segment No.<input type=text onchange="search_seg(this.value);"/>
+ <div id="segName">Segment Name: </div>
+ <div id="segInfo">Number of Running Trains: </div>
+ --->
+
+ <!---
+ <div>
+ <h5>Graphical Visualisation:</h5>
+ <div id="placeholder" style="width:600px;height:250px"></div>
+ </div>
+ Enter Segment No.<input type=text onchange="search(this.value);"/>
+ <div id="segInfo" style="border-style:solid;border-width:5px;height:150px;width:400px"/>
+ --->
+ <tr>
+ </td>
+
+ <td>
+ <div id="map_normal" style="width: 700px;height: 700px;position: absolute"></div>
+ <div id="overlay_normal"style="width: 700px;height: 700px; background-color: #000; opacity: 0.6"/>
+ </td>
+ <td>
+ <div id="map_delay" style="width: 700px;height: 700px;position: absolute"></div>
+ <div id="overlay_delay"style="width: 700px;height: 700px; background-color: #000; opacity: 0.6"/>
+ </td>
+ </tr> <!-- Map table row ends -->
+
+ <tr> <!-- Bussiest segments row -->
+ <td>
+ <h5>Three Bussiest Segments(MAP_NORMAL)</h5>
+ <div id="busy1_normal"></div>
+ <div id="busy2_normal"></div>
+ <div id="busy3_normal"></div>
+ </td>
+ <td>
+ <h5>Three Bussiest Segments(MAP_DELAY)</h5>
+ <div id="busy1_delay"></div>
+ <div id="busy2_delay"></div>
+ <div id="busy3_delay"></div>
+ </td>
+ </tr> <!-- Bussiest segments row ends -->
+
+ </table>
+ <script src="js/helper.js" type="text/javascript"></script>
+ <!--div onclick="MoveMarker()";> This is the place </div>
+ <div id="encodedPolyline" onclick="setMarker()"><hr/>This is the encoded place<br/></div><hr/>
+ <div id="distance">Distance <br/></div-->
+ <script language="javascript" type="text/javascript" src="js/flot/jquery.js"></script>
+ <script language="javascript" type="text/javascript" src="js/flot/jquery.flot.js"></script>
+ </body>
+</html>
View
324 delay_simulation/js/epoly_v3.js
@@ -0,0 +1,324 @@
+/*********************************************************************\
+* *
+* epolys.js by Mike Williams *
+* updated to API v3 by Larry Ross *
+* *
+* A Google Maps API Extension *
+* *
+* Adds various Methods to google.maps.Polygon and google.maps.Polyline *
+* *
+* .Contains(latlng) returns true is the poly contains the specified *
+* GLatLng *
+* *
+* .Area() returns the approximate area of a poly that is *
+* not self-intersecting *
+* *
+* .Distance() returns the length of the poly path *
+* *
+* .Bounds() returns a GLatLngBounds that bounds the poly *
+* *
+* .GetPointAtDistance() returns a GLatLng at the specified distance *
+* along the path. *
+* The distance is specified in metres *
+* Reurns null if the path is shorter than that *
+* *
+* .GetPointsAtDistance() returns an array of GLatLngs at the *
+* specified interval along the path. *
+* The distance is specified in metres *
+* *
+* .GetIndexAtDistance() returns the vertex number at the specified *
+* distance along the path. *
+* The distance is specified in metres *
+* Reurns null if the path is shorter than that *
+* *
+* .Bearing(v1?,v2?) returns the bearing between two vertices *
+* if v1 is null, returns bearing from first to last *
+* if v2 is null, returns bearing from v1 to next *
+* *
+* *
+***********************************************************************
+* *
+* This Javascript is provided by Mike Williams *
+* Blackpool Community Church Javascript Team *
+* http://www.blackpoolchurch.org/ *
+* http://econym.org.uk/gmap/ *
+* *
+* This work is licenced under a Creative Commons Licence *
+* http://creativecommons.org/licenses/by/2.0/uk/ *
+* *
+***********************************************************************
+* *
+* Version 1.1 6-Jun-2007 *
+* Version 1.2 1-Jul-2007 - fix: Bounds was omitting vertex zero *
+* add: Bearing *
+* Version 1.3 28-Nov-2008 add: GetPointsAtDistance() *
+* Version 1.4 12-Jan-2009 fix: GetPointsAtDistance() *
+* Version 3.0 11-Aug-2010 update to v3 *
+* *
+\*********************************************************************/
+
+// === first support methods that don't (yet) exist in v3
+google.maps.LatLng.prototype.distanceFrom = function(newLatLng) {
+ //var R = 6371; // km (change this constant to get miles)
+ var R = 6378100; // meters
+ var lat1 = this.lat();
+ var lon1 = this.lng();
+ var lat2 = newLatLng.lat();
+ var lon2 = newLatLng.lng();
+ var dLat = (lat2-lat1) * Math.PI / 180;
+ var dLon = (lon2-lon1) * Math.PI / 180;
+ var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
+ Math.cos(lat1 * Math.PI / 180 ) * Math.cos(lat2 * Math.PI / 180 ) *
+ Math.sin(dLon/2) * Math.sin(dLon/2);
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
+ var d = R * c;
+ return d;
+}
+
+google.maps.LatLng.prototype.latRadians = function() {
+ return this.lat() * Math.PI/180;
+}
+
+google.maps.LatLng.prototype.lngRadians = function() {
+ return this.lng() * Math.PI/180;
+}
+
+google.maps.LatLng.prototype.equals = function(otherLatLng) {
+ var EQUALS_THRESHOLD = 0.001;
+ return (this.distanceFrom(otherLatLng) < EQUALS_THRESHOLD);
+}
+
+// === A method for testing if a point is inside a polygon
+// === Returns true if poly contains point
+// === Algorithm shamelessly stolen from http://alienryderflex.com/polygon/
+google.maps.Polygon.prototype.Contains = function(point) {
+ var j=0;
+ var oddNodes = false;
+ var x = point.lng();
+ var y = point.lat();
+ for (var i=0; i < this.getPath().getLength(); i++) {
+ j++;
+ if (j == this.getPath().getLength()) {j = 0;}
+ if (((this.getPath().getAt(i).lat() < y) && (this.getPath().getAt(j).lat() >= y))
+ || ((this.getPath().getAt(j).lat() < y) && (this.getPath().getAt(i).lat() >= y))) {
+ if ( this.getPath().getAt(i).lng() + (y - this.getPath().getAt(i).lat())
+ / (this.getPath().getAt(j).lat()-this.getPath().getAt(i).lat())
+ * (this.getPath().getAt(j).lng() - this.getPath().getAt(i).lng())<x ) {
+ oddNodes = !oddNodes
+ }
+ }
+ }
+ return oddNodes;
+}
+
+// === A method which returns the approximate area of a non-intersecting polygon in square metres ===
+// === It doesn't fully account for spherical geometry, so will be inaccurate for large polygons ===
+// === The polygon must not intersect itself ===
+//
+// only calculates the area of the first path
+//
+google.maps.Polygon.prototype.Area = function() {
+ var a = 0;
+ var j = 0;
+ var b = this.Bounds();
+ var x0 = b.getSouthWest().lng();
+ var y0 = b.getSouthWest().lat();
+ for (var i=0; i < this.getPath().getLength(); i++) {
+ j++;
+ if (j == this.getPath().getLength()) {j = 0;}
+ var x1 = this.getPath().getAt(i).distanceFrom(new google.maps.LatLng(this.getPath().getAt(i).lat(),x0));
+ var x2 = this.getPath().getAt(j).distanceFrom(new google.maps.LatLng(this.getPath().getAt(j).lat(),x0));
+ var y1 = this.getPath().getAt(i).distanceFrom(new google.maps.LatLng(y0,this.getPath().getAt(i).lng()));
+ var y2 = this.getPath().getAt(j).distanceFrom(new google.maps.LatLng(y0,this.getPath().getAt(j).lng()));
+ a += x1*y2 - x2*y1;
+ }
+ return Math.abs(a * 0.5);
+}
+
+// == spherical area from
+// http://forum.worldwindcentral.com/showthread.php?t=20724
+/// <summary>
+/// Haversine function : hav(x) = (1-cos(x))/2
+/// </summary>
+/// <param name="x"></param>
+/// <returns>Returns the value of Haversine function</returns>
+function Haversine( x ) {
+ return ( 1.0 - Math.cos( x ) ) / 2.0;
+}
+
+/// <summary>
+/// Compute the Area of a Spherical Polygon
+/// </summary>
+/// <param name="paths">latlng array of all vertices</param>
+/// <param name="r">spherical radius</param>
+/// <returns>Returns the area of a spherical polygon</returns>
+//
+// only calculates the area of the first path
+//
+google.maps.Polygon.prototype.SphericalPolygonArea = function ( ) {
+ var r= 6378100; // meters
+
+ var lam1 = 0, lam2 = 0, beta1 =0, beta2 = 0, cosB1 = 0, cosB2 = 0;
+ var hav = 0;
+ var sum = 0;
+ var paths = this.getPath();
+ if (paths.getLength() < 2) return 0;
+ for( var j = 0 ; j < paths.getLength() ; j++ ) {
+ var k = j + 1;
+ if( j == 0 ) {
+ lam1 = paths.getAt(j).lngRadians();
+ beta1 = paths.getAt(j).latRadians();
+ lam2 = paths.getAt(j + 1).lngRadians();
+ beta2 = paths.getAt(j + 1).latRadians();
+ cosB1 = Math.cos( beta1 );
+ cosB2 = Math.cos( beta2 );
+ }
+ else
+ {
+ k = ( j + 1 ) % paths.getLength();
+ lam1 = lam2;
+ beta1 = beta2;
+ lam2 = paths.getAt(k).lngRadians();
+ beta2 = paths.getAt(k).latRadians();
+ cosB1 = cosB2;
+ cosB2 = Math.cos( beta2 );
+ }
+ if( lam1 != lam2 ) {
+ var hav = Haversine( beta2 - beta1 ) +
+ cosB1 * cosB2 * Haversine( lam2 - lam1 );
+ var a = 2 * Math.asin( Math.sqrt( hav ) );
+ var b = Math.PI / 2 - beta2;
+ var c = Math.PI / 2 - beta1;
+ var s = 0.5 * ( a + b + c );
+ var t = Math.tan( s / 2 ) * Math.tan( ( s - a ) / 2 ) *
+ Math.tan( ( s - b ) / 2 ) * Math.tan( ( s - c ) / 2 );
+
+ var excess = Math.abs( 4 * Math.atan( Math.sqrt(
+ Math.abs( t ) ) ) );
+
+ if( lam2 < lam1 ) {
+ excess = -excess;
+ }
+
+ sum += excess;
+ }
+ }
+ return Math.abs( sum ) * r * r;
+}
+
+// === A method which returns the length of a path in metres ===
+google.maps.Polygon.prototype.Distance = function() {
+ var dist = 0;
+ for (var i=1; i < this.getPath().getLength(); i++) {
+ dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));
+ }
+ return dist;
+}
+
+// === A method which returns the bounds as a GLatLngBounds ===
+google.maps.Polygon.prototype.Bounds = function() {
+ var bounds = new google.maps.LatLngBounds();
+ for (var i=0; i < this.getPath().getLength(); i++) {
+ bounds.extend(this.getPath().getAt(i));
+ }
+ return bounds;
+}
+
+// === A method which returns a GLatLng of a point a given distance along the path ===
+// === Returns null if the path is shorter than the specified distance ===
+google.maps.Polygon.prototype.GetPointAtDistance = function(metres) {
+ // some awkward special cases
+ if (metres == 0) return this.getPath().getAt(0);
+ if (metres < 0) return null;
+ var dist=0;
+ var olddist=0;
+ for (var i=1; (i < this.getPath().getLength() && dist < metres); i++) {
+ olddist = dist;
+ dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));
+ }
+ if (dist < metres) {return null;}
+ var p1= this.getPath().getAt(i-2);
+ var p2= this.getPath().getAt(i-1);
+ var m = (metres-olddist)/(dist-olddist);
+ return new google.maps.LatLng( p1.lat() + (p2.lat()-p1.lat())*m, p1.lng() + (p2.lng()-p1.lng())*m);
+}
+
+// === A method which returns an array of GLatLngs of points a given interval along the path ===
+google.maps.Polygon.prototype.GetPointsAtDistance = function(metres) {
+ var next = metres;
+ var points = [];
+ // some awkward special cases
+ if (metres <= 0) return points;
+ var dist=0;
+ var olddist=0;
+ for (var i=1; (i < this.getPath().getLength()); i++) {
+ olddist = dist;
+ dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));
+ while (dist > next) {
+ var p1= this.getPath().getAt(i-1);
+ var p2= this.getPath().getAt(i);
+ var m = (next-olddist)/(dist-olddist);
+ points.push(new google.maps.LatLng( p1.lat() + (p2.lat()-p1.lat())*m, p1.lng() + (p2.lng()-p1.lng())*m));
+ next += metres;
+ }
+ }
+ return points;
+}
+
+// === A method which returns the Vertex number at a given distance along the path ===
+// === Returns null if the path is shorter than the specified distance ===
+google.maps.Polygon.prototype.GetIndexAtDistance = function(metres) {
+ // some awkward special cases
+ if (metres == 0) return this.getPath().getAt(0);
+ if (metres < 0) return null;
+ var dist=0;
+ var olddist=0;
+ for (var i=1; (i < this.getPath().getLength() && dist < metres); i++) {
+ olddist = dist;
+ dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));
+ }
+ if (dist < metres) {return null;}
+ return i;
+}
+
+// === A function which returns the bearing between two vertices in decgrees from 0 to 360===
+// === If v1 is null, it returns the bearing between the first and last vertex ===
+// === If v1 is present but v2 is null, returns the bearing from v1 to the next vertex ===
+// === If either vertex is out of range, returns void ===
+google.maps.Polygon.prototype.Bearing = function(v1,v2) {
+ if (v1 == null) {
+ v1 = 0;
+ v2 = this.getPath().getLength()-1;
+ } else if (v2 == null) {
+ v2 = v1+1;
+ }
+ if ((v1 < 0) || (v1 >= this.getPath().getLength()) || (v2 < 0) || (v2 >= this.getPath().getLength())) {
+ return;
+ }
+ var from = this.getPath().getAt(v1);
+ var to = this.getPath().getAt(v2);
+ if (from.equals(to)) {
+ return 0;
+ }
+ var lat1 = from.latRadians();
+ var lon1 = from.lngRadians();
+ var lat2 = to.latRadians();
+ var lon2 = to.lngRadians();
+ var angle = - Math.atan2( Math.sin( lon1 - lon2 ) * Math.cos( lat2 ), Math.cos( lat1 ) * Math.sin( lat2 ) - Math.sin( lat1 ) * Math.cos( lat2 ) * Math.cos( lon1 - lon2 ) );
+ if ( angle < 0.0 ) angle += Math.PI * 2.0;
+ angle = angle * 180.0 / Math.PI;
+ return parseFloat(angle.toFixed(1));
+}
+
+// === Copy all the above functions to GPolyline ===
+google.maps.Polyline.prototype.Contains = google.maps.Polygon.prototype.Contains;
+google.maps.Polyline.prototype.Area = google.maps.Polygon.prototype.Area;
+google.maps.Polyline.prototype.Distance = google.maps.Polygon.prototype.Distance;
+google.maps.Polyline.prototype.Bounds = google.maps.Polygon.prototype.Bounds;
+google.maps.Polyline.prototype.GetPointAtDistance = google.maps.Polygon.prototype.GetPointAtDistance;
+google.maps.Polyline.prototype.GetPointsAtDistance = google.maps.Polygon.prototype.GetPointsAtDistance;
+google.maps.Polyline.prototype.GetIndexAtDistance = google.maps.Polygon.prototype.GetIndexAtDistance;
+google.maps.Polyline.prototype.Bearing = google.maps.Polygon.prototype.Bearing;
+google.maps.Polyline.prototype.SphericalPolygonArea = google.maps.Polygon.prototype.SphericalPolygonArea
+
+
View
519 delay_simulation/js/helper.js
@@ -0,0 +1,519 @@
+segments_normal = [];
+segments_delay = [];
+//for(var i=0;i<Segments.length;i++)
+ //Segments[i]=0;
+SegTrainList_normal = [];
+SegTrainList_delay = [];
+function updateSegments_normal(seg, tr_id){
+ var tmp;
+ if (seg){
+ for(i in seg){
+ //if(tr_id == "18110" && seg[0]!=[]) alert(i + " : " + seg[i].seg_no + " : " + seg[i].seg_label);
+ if(seg[i].seg_label==0){
+ if( SegTrainList_normal[seg[i].seg_no].indexOf(tr_id)==-1){
+ segments_normal[seg[i].seg_no]++;Ccolor_normal(seg[i].seg_no);
+ SegTrainList_normal[seg[i].seg_no].push(tr_id);
+ }else alert(tr_id+"Train already present. "+SegTrainList_normal[seg[i].seg_no]);
+ }
+
+ if(seg[i].seg_label==2){
+ if((tmp=SegTrainList_normal[seg[i].seg_no].indexOf(tr_id))>-1){
+ SegTrainList_normal[seg[i].seg_no].splice(tmp, 1);
+ segments_normal[seg[i].seg_no]--;
+ Ccolor_normal(seg[i].seg_no);
+ }else alert(tr_id +"Train is not Found. " + SegTrainList_normal[seg[i].seg_no]+" " + tmp);
+ }
+ }
+ }
+}
+
+function updateSegments_delay(seg, tr_id){
+ var tmp;
+ if (seg){
+ for(i in seg){
+ //if(tr_id == "18110" && seg[0]!=[]) alert(i + " : " + seg[i].seg_no + " : " + seg[i].seg_label);
+ if(seg[i].seg_label==0){
+ if( SegTrainList_delay[seg[i].seg_no].indexOf(tr_id)==-1){
+ segments_delay[seg[i].seg_no]++;Ccolor_delay(seg[i].seg_no);
+ SegTrainList_delay[seg[i].seg_no].push(tr_id);
+ }else alert(tr_id+"Train already present. "+SegTrainList_delay[seg[i].seg_no]);
+ }
+
+ if(seg[i].seg_label==2){
+ if((tmp=SegTrainList_delay[seg[i].seg_no].indexOf(tr_id))>-1){
+ SegTrainList_delay[seg[i].seg_no].splice(tmp, 1);
+ segments_delay[seg[i].seg_no]--;
+ Ccolor_delay(seg[i].seg_no);
+ }else alert(tr_id +"Train is not Found. " + SegTrainList_delay[seg[i].seg_no]+" " + tmp);
+ }
+ }
+ }
+}
+
+function async_update_normal(seg, tr_id){
+ var tmp;
+ var i;
+ if (seg){
+ for(i in seg){
+ //if(tr_id == "18110" && seg[0]!=[]) alert(i + " : " + seg[i].seg_no + " : " + seg[i].seg_label);
+ if(seg[i].seg_label!=2)
+ {
+ if( SegTrainList_normal[seg[i].seg_no].indexOf(tr_id)==-1)
+ {
+ segments_normal[seg[i].seg_no]++;Ccolor_normal(seg[i].seg_no);
+ SegTrainList_normal[seg[i].seg_no].push(tr_id);
+ }
+ }
+ }
+ }
+}
+
+function async_update_delay(seg, tr_id){
+ var tmp;
+ var i;
+ if (seg){
+ for(i in seg){
+ //if(tr_id == "18110" && seg[0]!=[]) alert(i + " : " + seg[i].seg_no + " : " + seg[i].seg_label);
+ if(seg[i].seg_label!=2){
+ if( SegTrainList_delay[seg[i].seg_no].indexOf(tr_id)==-1){
+ segments_delay[seg[i].seg_no]++;Ccolor_delay(seg[i].seg_no);
+ SegTrainList_delay[seg[i].seg_no].push(tr_id);
+ }
+ }
+ }
+ }
+}
+
+var WeekDays = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
+function Train(train, mode){
+ this.reInitialize = function(){
+ this.finished = 1;
+ this.cur_stn = 0;
+ this.startedAt=0;
+ this.day=0;
+ }
+
+ this.Initialize = function(mode){
+ this.mode = mode;
+ this.id = train.tr_id;
+ this.stn_list = train.stn_list;
+ var l = this.stn_list.length;
+ this.stn_list[l-1].sch_dep = this.stn_list[l-1].sch_arr;
+ /*
+ this.daysRun = [];
+ for(i in WeekDays){
+ if(train.days.indexOf(WeekDays[i]) != 1)
+ this.daysRun[i] = 1;
+ else this.daysRun[i] = 0;
+ }
+ */
+ this.reInitialize();
+ }
+ this.Initialize(mode);
+
+ this.start = function(c){
+
+ //if(this.daysRun[Math.floor(c/1440)%7] == 1){
+ if(c%1440 > this.stn_list[0].sch_dep){
+ this.day=0;
+ this.startedAt = c;
+ if(this.mode == 1)
+ updateSegments_normal(this.stn_list[0].seg_list, this.id);
+ else if(this.mode == 2)
+ updateSegments_delay(this.stn_list[0].seg_list, this.id);
+ this.cur_stn++;
+ //if(this.id=="18110") alert("Starting again" + c/1440);
+ // this. move(c);
+ }
+ //}
+
+ }
+
+ this.move = function(c){
+ if(this.cur_stn==0 && this.finished==1) {
+ this.start(c); return;
+ }
+ var s = this.cur_stn;
+ t = this.day*1440 + this.stn_list[s].sch_dep - this.stn_list[0].sch_dep
+ if(t < c-this.startedAt){
+ if (s==this.stn_list.length-1){
+ this.finished = 1;
+ }
+ if(this.mode == 1)
+ updateSegments_normal(this.stn_list[s].seg_list, this.id);
+ else if(this.mode == 2)
+ updateSegments_delay(this.stn_list[s].seg_list, this.id);
+ if(this.cur_stn<this.stn_list-1 && this.stn_list[this.cur_stn+1].sch_dep < this.stn_list[this.cur_stn].sch_dep){
+ this.day++;
+ if(this.id=="18110") alert("Day: "+ this.day);
+ }
+ this.cur_stn = (this.cur_stn+1)%this.stn_list.length;
+ // this.move(c);
+ }
+ }
+ this.move_async = function(c){
+ var s = 0;
+ var g = 0;
+ for(s = 0; s < this.stn_list.length; s++)
+ {
+ var t = this.stn_list[s].sch_dep - c;
+ if(t>0)
+ {
+ if(s!=0)
+ {
+ if(this.mode == 1)
+ async_update_normal(this.stn_list[s-1].seg_list, this.id);
+ else if(this.mode == 2)
+ async_update_delay(this.stn_list[s-1].seg_list, this.id);
+ break;
+ }
+ }
+ }
+ }
+};
+
+var Segments, Trains_normal=[], Trains_delay = [];
+$.getJSON("data/NewTrainStationWSegmentsWDays.min.json", function(json) {
+ T = eval(json);
+ for( i in T.trains){
+ Trains_normal[i] = new Train(T.trains[i].train, 1);
+ }
+ });
+$.getJSON("data/NewTrainStationDetailWDelayWSegments.json", function(json) {
+ T = eval(json);
+ for( i in T){
+ Trains_delay[i] = new Train(T[i].train, 2)
+ }
+ });
+$.getJSON("data/segments.js", function(json) {
+ T = eval(json);
+ Segments = T.segments;
+ Initialize();
+ });
+var segNames = [];
+$.getJSON("data/segmentName.js", function(json) {
+ T = eval(json);
+ segNames = T.segNames;
+ });
+
+function viewAsyncTraffic()
+{
+ Initialize();
+ var i;
+ for(i=0;i<Trains_normal.length;i++)
+ {
+ Trains_normal[i].move_async(clock);
+ }
+ for(i=0;i<Trains_normal.length;i++)
+ {
+ Trains_delay[i].move_async(clock);
+ }
+ var s = 0;
+ for( i in segments_normal) s+= segments_normal[i];
+ $("#SegTot_normal").html("Total running trains(MAP_NORMAL): " + s);
+
+ s = 0;
+ for( i in segments_delay) s+= segments_delay[i];
+ $("#SegTot_delay").html("Total running trains(MAP_DELAY) : " + s);
+
+ busy3high_normal();
+ busy3high_delay();
+}
+
+function Ccolor_normal(i){
+ c = segments_normal[i];
+ if (i in poly_seg_normal)
+ //poly_seg[i].setOptions({strokeColor: 'blue'});
+ poly_seg_normal[i].setOptions({strokeWeight: (c/3) });
+}
+
+function Ccolor_delay(i){
+ c = segments_delay[i];
+ if (i in poly_seg_delay)
+ //poly_seg[i].setOptions({strokeColor: 'blue'});
+ poly_seg_delay[i].setOptions({strokeWeight: (c/3) });
+}
+
+poly_seg_normal = [];
+poly_seg_delay = [];
+function Initialize() {
+ stop = 1;
+ var myOptions = {
+ center: new google.maps.LatLng(22.5, 82),
+ zoom: 5,
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ };
+ map_normal = new google.maps.Map(document.getElementById("map_normal"), myOptions);
+ map_delay = new google.maps.Map(document.getElementById("map_delay"), myOptions);
+ var c = [23,34,12];
+ for(i=0;i<Segments.length;i++){
+ segments_normal[i] = 0;
+ SegTrainList_normal[i] = [];
+ segments_delay[i] = 0;
+ SegTrainList_delay[i] = [];
+ var tmp = [];
+ for(j in Segments[i].segment.seg_list)
+ tmp[j] = new google.maps.LatLng(
+ Segments[i].segment.seg_list[j].lat,
+ Segments[i].segment.seg_list[j].lng
+ );
+ //alert(tmp);
+ var color = '#' + c[0].toString(16)+c[1].toString(16)+c[2].toString(16);
+ c[i%3] = 100 + (c[i%3]*2) % 100;
+ poly_seg_normal[i] = new google.maps.Polyline({
+ path: tmp,
+ strokeColor: color,
+ strokeOpacity: 1.0,
+ strokeWeight: 2,
+ map: map_normal
+ });
+
+ poly_seg_delay[i] = new google.maps.Polyline({
+ path: tmp,
+ strokeColor: color,
+ strokeOpacity: 1.0,
+ strokeWeight: 2,
+ map: map_delay
+ });
+ }
+}
+last = 0;clock=0;
+
+/*
+function Update(t,c){
+ for(i=0;i<Trains_normal.length;i++){
+ Trains_normal[i].move(clock);
+ }
+ for(i=0;i<Trains_delay.length;i++){
+ Trains_delay[i].move(clock);
+ }
+ clock+=20;c+=20;
+ //setTimeout("animate(0)",0);
+ updateClock();
+ setTimeout("Update("+t+","+c+")", 5)
+}
+
+function setStartPoint1(t){
+ $("#time-line").html(Math.floor(t/60) + "::" + t%60);
+ var c = clock%1440;
+ if(t<c) {t+=1440;}
+ for(i=0;i<Trains.length;i++)
+ Trains[i].move(clock);
+ clock+=20;c+=20;
+ //setTimeout("animate(0)",0);
+ updateClock();
+}
+function setStartPoint(t){
+ $("#time-line").html(Math.floor(t/60) + "::" + t%60);
+ var c = clock%1440;
+ if(t<c) {t+=1440;}
+ while(t<c){
+ for(i=0;i<Trains.length/100;i++)
+ Trains[i].move(clock);
+ clock+=20;c+=20;
+ }
+ updateClock();
+}
+*/
+
+function showValue(value){
+ $("#timeScale").html(value);
+ t_incr = parseInt(value);
+ // alert(t_incr);
+}
+
+function showValueTime(value){
+ $("#time-line").html(value);
+}
+
+function setTime(){
+ var str = $("#time-line").html();
+ var t = str.split("::");
+ clock = parseInt(t[0])*60 + parseInt(t[1]) - t_incr;
+ updateClock();
+}
+
+function setOpacity(value) {
+ var t = $("#overlay_normal");
+ t.css("opacity", value);
+ t = $("#overlay_delay");
+ t.css("opacity", value);
+ // t.style.filter = 'alpha(opacity=' + value*10 + ')';
+}
+
+function reset(){
+ Initialize();
+ $("#SegTot_normal").html("Total running trains(MAP_NORMAL): 0");
+ $("#SegTot_delay").html("Total running trains(MAP_DELAY) : 0");
+ stop=1;
+ document.getElementById("range").value = 6;
+ showValue(6);
+ clock=-t_incr;
+ updateClock();
+ var i;
+ for(i=0;i<Segments.length;i++){
+ segments_normal[i] = 0;
+ segments_delay[i] = 0;
+ SegTrainList_normal[i] = [];
+ SegTrainList_delay[i] = [];
+ }
+ for(i=0;i<Trains_normal.length;i++){
+ Trains_normal[i].reInitialize();
+ //marker[i].setPosition(Trains[i].ptset[Trains[i].cur_stn]);
+ }
+ for(i=0;i<Trains_delay.length;i++){
+ Trains_delay[i].reInitialize();
+ //marker[i].setPosition(Trains[i].ptset[Trains[i].cur_stn]);
+ }
+}
+
+function updateClock(){
+ clock+=t_incr;
+ var d = Math.floor(clock/1440);
+ var h = Math.floor((clock%1440)/60);
+ var m = clock%60;
+ document.getElementById("time").innerHTML = "<b>Time</b>(day:hr::min)&nbsp " + d + " :: " + h + " :: " + m;
+ var value;
+ value = 0.3 + 0.3 * Math.cos(h*3.141/12);
+ setOpacity(value);
+}
+
+var incr = 10;
+var tick = 50;
+var t_incr = 6;
+var stop=1;
+function animate(d) {
+ if(stop==1) {return;}
+ var i;
+ for(i=0;i<Trains_normal.length;i++){
+ Trains_normal[i].move(clock);
+ }
+ for(i=0;i<Trains_delay.length;i++){
+ Trains_delay[i].move(clock);
+ }
+ updateClock();
+ setTimeout("animate("+(d+incr)+")", tick);
+ //setTimeout("showGraph()", tick*30);
+ var s = 0;
+ for( i in segments_normal) s+= segments_normal[i];
+ $("#SegTot_normal").html("Total running trains(MAP_NORMAL): " + s);
+ s = 0; for( i in segments_delay) s+= segments_delay[i];
+ $("#SegTot_delay").html("Total running trains(MAP_DELAY) : " + s);
+}
+//marker = [];
+function start() {
+ s = $("#anim").html();
+ if(s=="Pause"){
+ stop=1;
+ //showGraph();
+ $("#anim").html("Start");
+ }
+ else if(s=="Start"){
+ $("#anim").html("Pause");
+ stop=0;
+ setTimeout("animate(0)",0);
+ }
+}
+
+function showGraph(){
+ $(function ()
+ {
+ var d1 = [];
+ for (i in segments )
+ d1.push([i, segments[i]]);
+ $.plot($("#placeholder"),
+ [{ data: d1, bars: { show: true }}]);
+ });
+}
+
+function search(v){
+ v = parseInt(v);
+ if(v in segments){
+ var s = Segments[v].segment;
+ t = "<b>Name</b>: "+ s.seg_name + "<br/>";
+ t+=segNames[v].list.join("->")+"<br/>";
+ t+= "<b>Number of Trains</b>: " + segments[v];
+ $("#segInfo").html(t);
+ }
+}
+
+function search_seg(v){
+ v = parseInt(v);
+ if(v in segments){
+ var s = Segments[v].segment;
+ $("#segName").html("Segment Name: " + s.seg_name);
+ $("#segInfo").html("Number of Running Trains: " + segments[v]);
+ }
+}
+
+function busy3high_normal(){
+ var busy1_name, busy2_name, busy3_name;
+ var busy1_info = 0, busy2_info = 0, busy3_info = 0;
+ var i;
+ for(i in segments_normal)
+ {
+ if(segments_normal[i] > busy1_info)
+ {
+ busy1_info = segments_normal[i];
+ var s = Segments[i].segment;
+ busy1_name = s.seg_name;
+ }
+ }
+ for(i in segments_normal)
+ {
+ if(segments_normal[i] > busy2_info && segments_normal[i] < busy1_info)
+ {
+ busy2_info = segments_normal[i];
+ var s = Segments[i].segment;
+ busy2_name = s.seg_name;
+ }
+ }
+ for(i in segments_normal)
+ {
+ if(segments_normal[i] > busy3_info && segments_normal[i] < busy2_info)
+ {
+ busy3_info = segments_normal[i];
+ var s = Segments[i].segment;
+ busy3_name = s.seg_name;
+ }
+ }
+ $("#busy1_normal").html("1. " + busy1_name + "\t" + busy1_info);
+ $("#busy2_normal").html("2. " + busy2_name + "\t" + busy2_info);
+ $("#busy3_normal").html("3. " + busy3_name + "\t" + busy3_info);
+}
+
+function busy3high_delay(){
+ var busy1_name, busy2_name, busy3_name;
+ var busy1_info = 0, busy2_info = 0, busy3_info = 0;
+ var i;
+ for(i in segments_delay)
+ {
+ if(segments_delay[i] > busy1_info)
+ {
+ busy1_info = segments_delay[i];
+ var s = Segments[i].segment;
+ busy1_name = s.seg_name;
+ }
+ }
+ for(i in segments_delay)
+ {
+ if(segments_delay[i] > busy2_info && segments_delay[i] < busy1_info)
+ {
+ busy2_info = segments_delay[i];
+ var s = Segments[i].segment;
+ busy2_name = s.seg_name;
+ }
+ }
+ for(i in segments_delay)
+ {
+ if(segments_delay[i] > busy3_info && segments_delay[i] < busy2_info)
+ {
+ busy3_info = segments_delay[i];
+ var s = Segments[i].segment;
+ busy3_name = s.seg_name;
+ }
+ }
+ $("#busy1_delay").html("1. " + busy1_name + "\t" + busy1_info);
+ $("#busy2_delay").html("2. " + busy2_name + "\t" + busy2_info);
+ $("#busy3_delay").html("3. " + busy3_name + "\t" + busy3_info);
+}

0 comments on commit 579e9c2

Please sign in to comment.