You are on page 1of 97

APPENDICES Appendix A Gantt Chart

Appendix B Bill of Materials

Items
3-axis ADXL345 GSM/GPRS Shield GPS Shield Gizduino+ ATmega644 12V/3A DC Adaptor Spray Paint Toy Truck Pre-synthesized PCB Mighty Bond Hook & Loop Fastener Dupont Wires Printer Ink Sliding Folder and Clips Copier Paper Shipping & Delivery Fuel (For Testing) Bolts and Screws Fuse 2.5A and Holder Resistors LEDs Switch Soldering Lead Cable Wire Headers Electrical Wires

Price (Php)
299 1995 1385 760 360 95 130 50 50 50 32 150 40 190

Quantity
1 1 1 1 1 1 1 1 1 1 2 4 6 1

Total Cost
299 1995 1385 760 360 95 130 50 50 50 64 600 240 190 446 500

miscellaneous miscellaneous

miscellaneous

250

Total Amount:

Php7,964

Appendix C Client Module Hardware Connections

Appendix D Module Schematics


The following schematics were taken from E-Gizmo module manuals provided upon purchase of the modules.

E-Gizmo Gizduino+ ATmega644

E-Gizmo GSM/GPRS Shield

E-Gizmo GPS Shield

Appendix E Datasheets

Appendix F Microcontroller Unit Code


#include <SPI.h> //LED indicators int led_1 = 12; //Data active int led_2 = 13; //Connected int led_3 = 14; //Sensor start int led_4 = 15; //Sensor alarm int led_5 = 2; //GPRS sent int led_6 = 3; //SMS sent //ADXL345 declarations int CS=4; //Chip Select signal double vg, rg, xg, yg, zg; char accel[6]; char POWER_CTL = 0x2D; char DATA_FORMAT = 0x31; char DATAX0 = 0x32; //X-Axis Data 0 char DATAX1 = 0x33; //X-Axis Data 1 char DATAY0 = 0x34; //Y-Axis Data 0 char DATAY1 = 0x35; //Y-Axis Data 1 char DATAZ0 = 0x36; //Z-Axis Data 0 char DATAZ1 = 0x37; //Z-Axis Data 1 char values[10]; int x,y,z; //GPS declarations int rx = 10; //GPSRX int tx = 11; //GPSTX char rawdata[200]={'\0'}; int i=0,j=0,length; char *ptr = '\0'; char gpgga_data[65]={'\0'}; char longitude_d[4]={'\0'}; char longitude[5]={'\0'}; double lngitude =0; //longitude value char lng[9]; //longitude string char lng2[2]={'\0'}; //N or S

char latitude_d[4]={'\0'}; char latitude[5]={'\0'}; double ltitude =0; //latitude value char lat[9]; //latitude string char lat2[2]={'\0'}; //E or W char time_h[3]={'\0'}; //UTC hour char time_m[3]={'\0'}; char time_s[3]={'\0'}; double time_hx = 0; //local hour value char hour[3] = {'\0'}; //local hour string char time[12] = {'\0'}; //local time //GPRS declarations char Rx_data[1000]; int k=0; char at_cmd[160]={'\0'}; char string[160]={'\0'}; char msg[100]={'\0'}; //GPRS message char msg2[80]="Host: sirena1234.vacau.com"; char msg3[80]="Connection: Keep-Alive"; char msgl[500]={'\0'}; char ctl_z = 0x1A; //SMS declarations unsigned char Rx_index = 0; char mensahe[100]={'\0'}; //SMS message char msgx[160]; void setup() { pinMode(led_1, OUTPUT); pinMode(led_2, OUTPUT); pinMode(led_3, OUTPUT); pinMode(led_4, OUTPUT); pinMode(led_5, OUTPUT); pinMode(led_6, OUTPUT); Serial.begin(57600); //GSM module communication initGPRS(); //Initialize for GPRS SPI.begin(); //sensor communication digitalWrite(led_3, HIGH); //LED indicator

pinMode(CS, OUTPUT); digitalWrite(CS, HIGH); //start communication writeRegister(DATA_FORMAT, 0x01); //set sensor to +/- 4G range writeRegister(POWER_CTL, 0x08); //Measurement mode //read sensor output until resultant acceleration exceeds threshold value while(1) { readRegister(DATAX0, 6, values); x = ((int)values[1]<<8)|(int)values[0]; y = ((int)values[3]<<8)|(int)values[2]; z = ((int)values[5]<<8)|(int)values[4]; delay(3000); xg = x * 0.0039; //x-axis acceleration in G yg = y * 0.0039; //y-axis acceleration in G zg = z * 0.0039; //z-axis acceleration in G vg = (xg * xg)+(yg * yg)+(zg * zg); rg = sqrt(vg); //resultant acceleration in G if (rg>=0.4) //sensor threshold value { warshock(); break; } } delay(3000); digitalWrite(led_1, LOW); digitalWrite(led_2, LOW); digitalWrite(led_3, LOW); digitalWrite(led_4, LOW); digitalWrite(led_5, LOW); digitalWrite(led_6, LOW); } //write to sensor registers void writeRegister(char registerAddress, char value) { digitalWrite(CS, LOW); SPI.transfer(registerAddress); SPI.transfer(value); digitalWrite(CS, HIGH); }

//read sensor registers void readRegister(char registerAddress, int numBytes, char * values) { char address = 0x80 | registerAddress; if(numBytes > 1)address = address | 0x40; digitalWrite(CS, LOW); SPI.transfer(address); for(int i=0; i<numBytes; i++) { values[i] = SPI.transfer(0x00); } digitalWrite(CS, HIGH); } // void warshock() { digitalWrite(led_4, HIGH); //LED indicator Serial1.begin(9600); //GPS module communication pinMode(tx, OUTPUT); digitalWrite(tx,HIGH); //start communication Serial1.write(Serial1.read()); while(!ptr) { while(Serial1.available()) { rawdata[i]=Serial1.read(); //GPS output i++; j=0; delay(10); } ptr = strstr(rawdata,"$GPGGA"); //search GPGGA String } if(j==0) { strncpy(latitude_d,ptr+18,2); strncpy(latitude,ptr+20,7); //latitude value ltitude=stringtoInt(latitude_d,2) + stringtoInt(latitude,7)/60; //convert to string dtostrf(ltitude,7,4,lat); strncpy(lat2,ptr+28,1); //E or W

strncpy(longitude_d,ptr+30,3); strncpy(longitude,ptr+33,7); //longitude value lngitude=stringtoInt(longitude_d,3) + stringtoInt(longitude,7)/60.0; //convert to string dtostrf(lngitude,7,4,lng); strncpy(lng2,ptr+41,1); //N or S //UTC time strncpy(time_h,ptr+7,2); strncpy(time_m,ptr+9,2); strncpy(time_s,ptr+11,2); //convert to local (Pacific) time time_hx=stringtoInt(time_h,2)+8; if(time_hx>23) { time_hx=time_hx-24; } dtostrf(time_hx,2,0,hour); strcat(time,hour); strcat(time,":"); strcat(time,time_m); strcat(time,":"); strcat(time,time_s); dtostrf(rg,5,3,accel); j=1; } i=0; ptr='\0'; delay(10); //GPRS message strcat(msg,"GET /receive.php?acceleration="); strcat(msg,accel); //acceleration strcat(msg,"G"); strcat(msg,"&coorX="); strcat(msg,lat); //latitude strcat(msg,lat2); strcat(msg,"&coorY="); strcat(msg,lng); //longitude strcat(msg,lng2); strcat(msg,"&plate=DFK625");

strcat(msg,"&time2="); strcat(msg,time); //local time strcat(msg,"&send=ok HTTP/1.0"); send_gprs(); //send GPRS data digitalWrite(led_5, HIGH); //LED indicator //SMS message strcat(mensahe,"Geographic Coordinates: "); strcat(mensahe,lat); strcat(mensahe,lat2); strcat(mensahe," "); strcat(mensahe,lng); strcat(mensahe,lng2); strcat(mensahe,"\n\nTime (UTC): "); strcat(mensahe,time); strcat(mensahe,"\nAcceleration: "); strcat(mensahe,accel); strcat(mensahe,"G"); initGSM(); //initialize for SMS send_msg("09339952872", mensahe); //send SMS digitalWrite(led_6, HIGH); //LED indicator } //string to float converter double stringtoInt(char *string, int length) { float ans=0,n=0; i=0; while(i<length) { switch(string[i]) { case '0': ans=ans*10;break; case '1': ans=ans*10+1;break; case '2': ans=ans*10+2;break; case '3': ans=ans*10+3;break; case '4': ans=ans*10+4;break; case '5': ans=ans*10+5;break; case '6': ans=ans*10+6;break; case '7': ans=ans*10+7;break; case '8': ans=ans*10+8;break; case '9': ans=ans*10+9;break; case '.': while(i<length) {

switch(string[i+1]) { case '0': n=n+1;break; case '1': n=n+1;ans=ans+pow(0.1,n)*1;break; case '2': n=n+1;ans=ans+pow(0.1,n)*2;break; case '3': n=n+1;ans=ans+pow(0.1,n)*3;break; case '4': n=n+1;ans=ans+pow(0.1,n)*4;break; case '5': n=n+1;ans=ans+pow(0.1,n)*5;break; case '6': n=n+1;ans=ans+pow(0.1,n)*6;break; case '7': n=n+1;ans=ans+pow(0.1,n)*7;break; case '8': n=n+1;ans=ans+pow(0.1,n)*8;break; case '9': n=n+1;ans=ans+pow(0.1,n)*9;break; } i++; }break; default: break; } i++; } return ans; } //GPRS subfuctions void initGPRS() { send_cmd("AT\r\n"); //check communication delay(200); send_cmd("AT+CGATT=1\r\n"); //attach GPRS service delay(500); digitalWrite(led_1, HIGH); //LED indicator send_cmd("AT+CIPCSGP=1,\"internet\"\r\n"); //connection mode delay(200); send_cmd("AT+CLPORT=\"TCP\",\"80\"\r\n"); //set local port delay(200); send_cmd("AT+CIPMUX=0\r\n"); //single IP connection delay(200); send_cmd("AT+CSTT=\"internet\",\"\",\"\"\r\n"); //start task delay(200); send_cmd("AT+CIICR\r\n"); //bring up connection delay(1000); digitalWrite(led_2, HIGH); //LED indicator send_cmd2("AT+CIFSR\r\n"); //get local IP address delay(200); send_cmd("AT+CIPHEAD=0\r\n"); //IP head delay(200);

//configure domain name server send_cmd("AT+CDNSCFG=\"208.67.222.222\",\"208.67.220.220\"\r\n"); } //send command to GSM module and wait for OK reply void send_cmd(char *at_cmd) { char *stat='\0'; while(!stat) { sendGSM(at_cmd); delay(200); readSerialString(Rx_data); stat=strstr(Rx_data, "OK"); } clearString(Rx_data); delay(200); Rx_data[0]='\0'; stat='\0'; } //send command to GSM module and wait for IP reply void send_cmd2(char *at_cmd) { char *stat='\0'; while(!stat) { sendGSM(at_cmd); delay(200); readSerialString(Rx_data); stat=strstr(Rx_data, "10"); } clearString(Rx_data); delay(200); Rx_data[0]='\0'; stat='\0'; } void sendGSM(char *string) { Serial.write(string); } //read reply from GSM module void readSerialString(char *strArray) {

k=0; if(!Serial.available()) { return; } while(Serial.available()) { strArray[k]=Serial.read(); k++; if(k==1000){k=0;}; } } //clear reply from GSM module void clearString(char *strArray) { int l; for (l = 1000; l > 0; l--) strArray[l] = 0x00; strArray = '\0'; } void send_gprs() { //set domain name and port send_cmd3("AT+CIPSTART=\"TCP\",\"sirena1234.vacau.com\",\"80\"\r\n"); //data to be sent sprintf(msgl, "%s\r\n%s\r\n%s\r\n\r\n%c", msg,msg2,msg3,ctl_z); //send data send_cmd4("AT+CIPSEND\r\n"); Serial.write(msgl); delay(10000); } //send command to GSM module and wait for CONNECT OK reply void send_cmd3(char *at_cmd) { char *stat='\0'; sendGSM(at_cmd); while(!stat) { delay(90); readSerialString(Rx_data); stat=strstr(Rx_data, "CONNECT"); if(stat=="ERROR")

{ sendGSM(at_cmd); } } clearString(Rx_data); delay(50); Rx_data[0]='\0'; stat='\0'; } //send command to GSM module and wait for > reply void send_cmd4(char *at_cmd) { sendGSM(at_cmd); delay(1000); readSerialString(Rx_data); clearString(Rx_data); delay(45); Rx_data[0]='\0'; } //SMS subfunctions void initGSM() { send_cmd("AT\r\n"); send_cmd("AT+CMGF=1\r\n"); delay(1000); } void send_msg(char *number, char *msgx) { char at_cmgs_cmd[30] = {'\0'}; char msgG[160] = {'\0'}; sprintf(msgG, "%s%c", msgx, ctl_z); sprintf(at_cmgs_cmd, "AT+CMGS=\"%s\"\r\n",number); sendGSM(at_cmgs_cmd); delay(500); sendGSM(msgG); delay(100); } void loop() {}

Appendix G Default.php Page Code


<html> <head> //title of the page <title>Design of A Vehicular Collision Automatic Advisory and Data Management System</title> <link rel="shortcut icon" href="symbol.ico" /> <link rel="stylesheet" type="text/css" media="screen and (min-width: 240px) and (max-width:800px)" href="small.css" /> <link rel="stylesheet" type="text/css" href="greys.css" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> //Java Script for embedding google maps starts here <!-- NOTE: this Map api is using the google "API key" of adrianvill aka "Technoblaze"--> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDyhStQGK2_09jn8o1kauHv 8qo3F3YJYfk&sensor=false"> </script> <!-######################################################################## #####--> <script type="text/javascript"> //sets the center of the map to Cebu City var mapcenter = new google.maps.LatLng(10.315,123.885); var map; var infowindow = new google.maps.InfoWindow(); var time = new Array(); var myimage = 'http://www.skyscrapercity.com/images/smilies/sad.gif'; var coorX = new Array(); var coorY = new Array(); var acceleration = new Array(); var myfunc = {}; var marker = [],circles = [], mapinfo = {},lid=2,i; var myCircle; function initialize() { var mapOptions = { zoom: 11, mapTypeId: google.maps.MapTypeId.ROADMAP, center: mapcenter }; //sets the ID name to be recognized by the html document or PHP page

map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); display(-1); } function warshock(lid) { //Acquire data from HTML document with variables set by the PHP Page time.push(document.getElementById('mytime'+lid).innerHTML); coorX.push(document.getElementById('coorX'+lid).innerHTML); coorY.push(document.getElementById('coorY'+lid).innerHTML); acceleration.push(document.getElementById('myacceleration'+lid).innerHTML); //Create Map Markers.. var myobject = new google.maps.Marker({ map:map, draggable:false, animation: google.maps.Animation.DROP, // icon: myimage, position: new google.maps.LatLng(coorX[coorX.length1],coorY[coorY.length-1]) }); marker.push(myobject); var cid=time.length-1; var did=acceleration.length-1; c="infowindow.setContent('<b><i> '+time["+cid+"]+'</i></b><br>Peak Acceleration:<b> '+acceleration["+did+"]+'</b>');infowindow.open(map, this);"; google.maps.event.addListener(myobject, 'click', new Function(c)); //Create intensity Circles var intensity = parseFloat(acceleration[acceleration.length-1]); //sets the value/threshold and settings of markers for very severe accidents if(intensity>=8){ var Severity = {strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 1, fillColor: '#000FFF', fillOpacity: 0.75, map: map, center: new google.maps.LatLng(coorX[coorX.length1],coorY[coorY.length-1]), radius: intensity*60 }; } //sets the value/threshold and settings of markers for light accidents else if(intensity<3){ var Severity = {strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 1, fillColor: '#FFFF00', fillOpacity: 0.35,

map: map, center: new google.maps.LatLng(coorX[coorX.length1],coorY[coorY.length-1]), radius: intensity*60 }; } //sets the value/threshold and settings of markers for very moderate accidents else { var Severity = {strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 1, fillColor: '#660000', fillOpacity: 0.65, map: map, center: new google.maps.LatLng(coorX[coorX.length1],coorY[coorY.length-1]), radius: intensity*60 }; } myCircle = new google.maps.Circle(Severity); circles.push(myCircle); } //function display/not display function display(parameter){ i = parseInt(document.getElementById('numberofitems').value); if( parameter>-1){ if(document.getElementById('action'+parameter).checked==false){ circles[parameter].setMap(null); marker[parameter].setMap(null);} else { circles[parameter].setMap(map); marker[parameter].setMap(map);

} } //displays the markers for x=0 where x stands as the identifier for data in each row if( parameter == -1){ j=0 while(j<i){warshock(j); if(document.getElementById('action'+(j)).checked==false){ circles[j].setMap(null); marker[j].setMap(null);} j++;} //continuously display marker } return 'ok'; //signals that the script is working }

//Refresh page every 300 seconds setTimeout('location.reload()', 300000); //refreshes the page every five minutes </script> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.simplePagination.js"></script> </head> <body onload="initialize()">//initializes all the scripts loaded into the page <td> <div align="center"><img src="headersmall.jpg"></div>//embeds the header image <div class="white"> <div align="center" id="navigation"><nav>//embeds the navigation links //navigation links <ul> <li><a class="head" href="default.php">Home</a></li> <li><a class="head" href="faq.php">Faq</a></li> <li><a class="head" href="documentation.php">documentation</a></li> <li><a class="head" href="owners.php">owners</a></li> <li><a class="head" href="credits.php">credits</a></li> <li><a class="head" href="contact.php">contact</a></li> </ul> </nav><br></div> //puts a horizontal border for separating the main content and header area <div id="horizon"></div> <div align="center" id="map_canvas"><br><br> //embeds the map in the page </div> <div id="accident"> //embeds the content of the page <center><img align="left" src="icon2.jpg"><p align="justify">Welcome to our website! This website was made in the fulfillment of our undergraduate thesis. In this page you can see all the logged data from our database. The table below includes all the important details of the accident - time, location (with coordinates) and severity of the accident. Click on the checkbox 'View Accident' in order to see the location of the accident in the map provided on the right side. To view the details of a specific accident, just click on the of the accident and it will redirect you to its details page. You can explore the different pages of this site using the navigation links above. If you have any questions, you may contact us in the Contacts page.<br> Note:</p> <li class="note" align="justify">All accidents are classified into three types: Very Severe (for accidents having a peak acceleration of more than 8g); Moderate (for accidents having a peak

acceleration in between 3g to 8g); and Light (for accidents having a peak acceleration of less than or equal to 3g).</li> <li class="note" align="justify">All peak accelearations are measured in terms of <i>g</i> where 1g = acceleration on earth due to gravity = 9.81 meters per second squared.</li> <li class="note" align="justify">All displayed time in the table below are of GMT+8 Standards while the time logged onto the database is on GMT-5</li> <li class="note" align="justify">Collision Time is in 24-hour format and is in GMT+8 settings.</li> <li class="note" align="justify">All positive X-Coordinates are coordinates in the northern hemisphere of the earth, while all negative X-coordinates are coordinates of the southern hemisphere of the earth. (e.g. 123.221N = 123.221; 112.331S = -112.331) </li> <li class="note" align="justify">All positive Y-Coordinates are coordinates in the eastern hemisphere of the earth, while all negative Y-coordinates are coordinates of the western hemisphere of the earth. (e.g. 123.221E = 123.221; 112.331W = -112.331)</li> <li class="note" align="justify">You can sort the list of accidents by <a href="default.php">Date of Accident</a> or by <a href="acceleration.php">Severity</a></li> <li class="note" align="justify">This site is best viewed with 1280x800 resolution and up.</li><br></center> //embeds the table with the information from the database <center> <div class="separate"> </div> <table> <h2>ACCIDENTS LIST</h2> <tr> <td><b>Date and Time</b></td> <td><b>Severity</b></td> <td><b>Peak Acceleration (in g)</b></td> <td><b>Plate No.</b></td> <td><b>X - Coordinate</b></td> <td><b>Y - Coordinate</b></td> <td><b>Collision Time</b></td> <td><b>Location</b></td> </tr> <!-- PHP CODE HERE START--> //connects the PHP page into the database <?php $db_table = 'arduino'; //selects the table from the database which contains the data to be displayed $dbname = 'a6705968_oink'; //connects to the database with username $conn = mysql_connect('mysql15.000webhost.com', 'a6705968_oink', 'arduino555') or die ('Error connecting to mysql'); //connects to the database through username and password and database host mysql_select_db($dbname);

//function that converts the GMT-5 timezone of the database to GMT+8 function revertTimeStamp($timestamp) { $year=substr($timestamp,0,4); $month=substr($timestamp,5,2); $day=substr($timestamp,8,2); $hour=substr($timestamp,11,2); $minute=substr($timestamp,14,2); $second=substr($timestamp,17,2); $newdate=mktime($hour,$minute,$second,$month,$day, $year); return($newdate); } //pagination of tables starts here if (!isset($_GET['pn'])) { $pn = 1; } else $pn = $_GET['pn']; $itemsPerPage = 5; //sets the number of rows to be displayed on the table per page $query="SELECT * FROM $db_table ORDER BY Date DESC"; //a query that selects the information from the table and sorts it according to date in a descending order $result=mysql_query($query); //executes the query above $maxentries = mysql_num_rows($result); //gets the total number of rows for pagination $lastPage = ceil($maxentries / $itemsPerPage); // calculates the number of pages for pagination //sets the variables to be used in linking or displaying page numbers $centerPages = ""; $sub1 = $pn - 1; $sub2 = $pn - 2; $add1 = $pn + 1; $add2 = $pn + 2; //sets the condition of the links displayed when the user or viewer is at a certain page if ($pn == 1) { $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;'; $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> &nbsp;'; } else if ($pn == $lastPage) { $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> &nbsp;'; $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;'; } else if ($pn > 2 && $pn < ($lastPage - 1)) { $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '">' . $sub2 . '</a> &nbsp;';

$centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> &nbsp;'; $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;'; $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> &nbsp;'; $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '">' . $add2 . '</a> &nbsp;'; } else if ($pn > 1 && $pn < $lastPage) { $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> &nbsp;'; $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;'; $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> &nbsp;'; } // sets the limit range for pagination $limit =($pn - 1)*$itemsPerPage; $query2 = "SELECT * FROM $db_table ORDER BY Date DESC LIMIT $limit,$itemsPerPage"; $sql2 = mysql_query($query2) or die ('Error in request');; ?><input type="hidden" value="<? echo mysql_num_rows($result); ?>" id="numberofitems"><? $x=0; // $sql2 is used to fuel our while loop statement below while($rows=mysql_fetch_array($sql2)){ $utc_ts = revertTimeStamp($rows['Date']); $local_ts = $utc_ts+46800; $mytime = date("M. d, Y, h:i:s A",$local_ts); $str = $rows['time2']; //formats the collision time to 24hr //Get last 6 chars $end = substr($str, -6); //Split strint into an array. Each element is 2 chars $chop = str_split($end, 2); //Convert array to string. Each element separated by the given separator. $fg = implode(':', $chop);

$id = $rows['identity']; //settings for displaying the severity of the accident if ($rows['acceleration']>=8) { $intensity ="Very Severe";

$intense="vsevere"; } if ($rows['acceleration']<3) { $intensity ="Light"; $intense="light"; } if ($rows['acceleration']>=3 && $rows['acceleration']<8) { $intensity ="Moderate"; $intense ="moderate"; } ?> <tr> <td id="mytime<? echo $x; ?>"><a href="/details.php?identity=<? echo $id; ?>&x=<? echo $x; ?>&send=ok"><? echo $mytime;?></a></td> <td class="<? echo $intense; ?>" style="width:80px;" id="intensity<? echo $x; ?>"><? echo $intensity;?> </td> <td id="myacceleration<? echo $x; ?>"><? echo (float) $rows['acceleration']; ?> </td> <td id="plate<? echo $x; ?>"><? echo $rows['plate']; ?> </td> <td id="coorX<? echo $x; ?>"><? echo (float) $rows['coorX']; ?> </td> <td id="coorY<? echo $x; ?>"><? echo (float) $rows['coorY']; ?> </td> <td id="time<? echo $x; ?>"><? echo $fg; ?></td> <td><input type="checkbox" value="View Accident" id="action<? echo $x; ?>" onclick="display(<? echo $x; ?>)">View Accident</td> </tr> <?php $x=$x+1; //identifier for the information displayed $f=$x+1; } mysql_close($conn); //displays the pagination links $paginationDisplay = ""; // Initialize the pagination output variable // This code runs only if the last page variable is ot equal to 1, if it is only 1 page we require no paginated links to display if ($lastPage != "1"){ // This shows the user what page they are on, and the total number of pages $paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' . $lastPage. '&nbsp; &nbsp; &nbsp; '; // If we are not on page 1 we can place the Back button if ($pn != 1) {

$previous = $pn - 1; $paginationDisplay .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> Back</a> '; } // Lay in the clickable numbers display here between the Back and Next links $paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>'; // If we are not on the very last page we can place the Next button if ($pn != $lastPage) { $nextPage = $pn + 1; $paginationDisplay .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '"> Next</a> '; } } ?> </table> <?php echo $paginationDisplay; ?></center><br><br> </div> </table></div><br><br> </body> </html>

Appendix H Acceleration.php Page Code


<html> <head> //title of the page <title>Design of A Vehicular Collision Automatic Advisory and Data Management System</title> <link rel="shortcut icon" href="symbol.ico" /> <link rel="stylesheet" type="text/css" media="screen and (min-width: 240px) and (max-width:800px)" href="small.css" /> <link rel="stylesheet" type="text/css" href="greys.css" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> //Java Script for embedding google maps starts here <!-- NOTE: this Map api is using the google "API key" of adrianvill aka "Technoblaze"--> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDyhStQGK2_09jn8o1kauHv 8qo3F3YJYfk&sensor=false"> </script> <!-######################################################################## #####--> <script type="text/javascript"> //sets the center of the map to Cebu City var mapcenter = new google.maps.LatLng(10.315,123.885); var map; var infowindow = new google.maps.InfoWindow(); var time = new Array(); var myimage = 'http://www.skyscrapercity.com/images/smilies/sad.gif'; var coorX = new Array(); var coorY = new Array(); var acceleration = new Array(); var myfunc = {}; var marker = [],circles = [], mapinfo = {},lid=2,i; var myCircle; function initialize() { var mapOptions = { zoom: 11, mapTypeId: google.maps.MapTypeId.ROADMAP,

center: mapcenter }; //sets the ID name to be recognized by the html document or PHP page map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); display(-1); } function warshock(lid) { //Acquire data from HTML document with variables set by the PHP Page time.push(document.getElementById('mytime'+lid).innerHTML); coorX.push(document.getElementById('coorX'+lid).innerHTML); coorY.push(document.getElementById('coorY'+lid).innerHTML); acceleration.push(document.getElementById('myacceleration'+lid).innerHTML); //Create Map Markers.. var myobject = new google.maps.Marker({ map:map, draggable:false, animation: google.maps.Animation.DROP, // icon: myimage, position: new google.maps.LatLng(coorX[coorX.length1],coorY[coorY.length-1]) }); marker.push(myobject); var cid=time.length-1; var did=acceleration.length-1; c="infowindow.setContent('<b><i> '+time["+cid+"]+'</i></b><br>Peak Acceleration:<b> '+acceleration["+did+"]+'</b>');infowindow.open(map, this);"; google.maps.event.addListener(myobject, 'click', new Function(c)); //Create intensity Circles var intensity = parseFloat(acceleration[acceleration.length-1]); //sets the value/threshold and settings of markers for very severe accidents if(intensity>=8){ var Severity = {strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 1, fillColor: '#000FFF', fillOpacity: 0.75, map: map, center: new google.maps.LatLng(coorX[coorX.length1],coorY[coorY.length-1]), radius: intensity*60 }; } //sets the value/threshold and settings of markers for light accidents else if(intensity<3){

var Severity = {strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 1, fillColor: '#FFFF00', fillOpacity: 0.35, map: map, center: new google.maps.LatLng(coorX[coorX.length1],coorY[coorY.length-1]), radius: intensity*60 }; } //sets the value/threshold and settings of markers for very moderate accidents else { var Severity = {strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 1, fillColor: '#660000', fillOpacity: 0.65, map: map, center: new google.maps.LatLng(coorX[coorX.length1],coorY[coorY.length-1]), radius: intensity*60 }; } myCircle = new google.maps.Circle(Severity); circles.push(myCircle); } //function display/not display function display(parameter){ i = parseInt(document.getElementById('numberofitems').value); if( parameter>-1){ if(document.getElementById('action'+parameter).checked==false){ circles[parameter].setMap(null); marker[parameter].setMap(null);} else { circles[parameter].setMap(map); marker[parameter].setMap(map);

} } //displays the markers for x=0 where x stands as the identifier for data in each row if( parameter == -1){ j=0 while(j<i){warshock(j); if(document.getElementById('action'+(j)).checked==false){ circles[j].setMap(null); marker[j].setMap(null);} j++;} //continuously display marker

} return 'ok'; //signals that the script is working } //Refresh page every 300 seconds setTimeout('location.reload()', 300000); //refreshes the page every five minutes </script> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.simplePagination.js"></script> </head> <body onload="initialize()">//initializes all the scripts loaded into the page <td> <div align="center"><img src="headersmall.jpg"></div>//embeds the header image <div class="white"> <div align="center" id="navigation"><nav>//embeds the navigation links //navigation links <ul> <li><a class="head" href="default.php">Home</a></li> <li><a class="head" href="faq.php">Faq</a></li> <li><a class="head" href="documentation.php">documentation</a></li> <li><a class="head" href="owners.php">owners</a></li> <li><a class="head" href="credits.php">credits</a></li> <li><a class="head" href="contact.php">contact</a></li> </ul> </nav><br></div> //puts a horizontal border for separating the main content and header area <div id="horizon"></div> <div align="center" id="map_canvas"><br><br> //embeds the map in the page </div> <div id="accident"> //embeds the content of the page <center><img align="left" src="icon2.jpg"><p align="justify">Welcome to our website! This website was made in the fulfillment of our undergraduate thesis. In this page you can see all the logged data from our database. The table below includes all the important details of the accident - time, location (with coordinates) and severity of the accident. Click on the checkbox 'View Accident' in order to see the location of the accident in the map provided on the right side. To view the details of a specific accident, just click on the of the accident and it will redirect you to its details page. You can explore the different pages of this site using the navigation links above. If you have any questions, you may contact us in the Contacts page.<br> Note:</p>

<li class="note" align="justify">All accidents are classified into three types: Very Severe (for accidents having a peak acceleration of more than 8g); Moderate (for accidents having a peak acceleration in between 3g to 8g); and Light (for accidents having a peak acceleration of less than or equal to 3g).</li> <li class="note" align="justify">All peak accelearations are measured in terms of <i>g</i> where 1g = acceleration on earth due to gravity = 9.81 meters per second squared.</li> <li class="note" align="justify">All displayed time in the table below are of GMT+8 Standards while the time logged onto the database is on GMT-5</li> <li class="note" align="justify">Collision Time is in 24-hour format and is in GMT+8 settings</li> <li class="note" align="justify">All positive X-Coordinates are coordinates in the northern hemisphere of the earth, while all negative X-coordinates are coordinates of the southern hemisphere of the earth. (e.g. 123.221N = 123.221; 112.331S = -112.331) </li> <li class="note" align="justify">All positive Y-Coordinates are coordinates in the eastern hemisphere of the earth, while all negative Y-coordinates are coordinates of the western hemisphere of the earth. (e.g. 123.221E = 123.221; 112.331W = -112.331)</li> <li class="note" align="justify">You can sort the list of accidents by <a href="default.php">Date of Accident</a> or by <a href="acceleration.php">Severity</a></li> <li class="note" align="justify">This site is best viewed with 1280x800 resolution and up.</li><br></center> //embeds the table with the information from the database <center> <div class="separate"> </div> <table> <h2>ACCIDENTS LIST</h2> <tr> <td><b>Date and Time</b></td> <td><b>Severity</b></td> <td><b>Peak Acceleration (in g)</b></td> <td><b>Plate No.</b></td> <td><b>X - Coordinate</b></td> <td><b>Y - Coordinate</b></td> <td><b>Collision Time</b></td> <td><b>Location</b></td> </tr> <!-- PHP CODE HERE START--> //connects the PHP page into the database <?php $db_table = 'arduino'; //selects the table from the database which contains the data to be displayed $dbname = 'a6705968_oink'; //connects to the database with username $conn = mysql_connect('mysql15.000webhost.com', 'a6705968_oink', 'arduino555')

or die ('Error connecting to mysql'); //connects to the database through username and password and database host mysql_select_db($dbname); //function that converts the GMT-5 timezone of the database to GMT+8 function revertTimeStamp($timestamp) { $year=substr($timestamp,0,4); $month=substr($timestamp,5,2); $day=substr($timestamp,8,2); $hour=substr($timestamp,11,2); $minute=substr($timestamp,14,2); $second=substr($timestamp,17,2); $newdate=mktime($hour,$minute,$second,$month,$day, $year); return($newdate); } //pagination of tables starts here if (!isset($_GET['pn'])) { $pn = 1; } else $pn = $_GET['pn']; $itemsPerPage = 5; //sets the number of rows to be displayed on the table per page $query="SELECT * FROM $db_table ORDER BY acceleration DESC"; //a query that selects the information from the table and sorts it according to date in a descending order $result=mysql_query($query); //executes the query above $maxentries = mysql_num_rows($result); //gets the total number of rows for pagination $lastPage = ceil($maxentries / $itemsPerPage); // calculates the number of pages for pagination //sets the variables to be used in linking or displaying page numbers $centerPages = ""; $sub1 = $pn - 1; $sub2 = $pn - 2; $add1 = $pn + 1; $add2 = $pn + 2; //sets the condition of the links displayed when the user or viewer is at a certain page if ($pn == 1) { $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;'; $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> &nbsp;'; } else if ($pn == $lastPage) { $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> &nbsp;'; $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;'; } else if ($pn > 2 && $pn < ($lastPage - 1)) {

$centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '">' . $sub2 . '</a> &nbsp;'; $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> &nbsp;'; $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;'; $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> &nbsp;'; $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '">' . $add2 . '</a> &nbsp;'; } else if ($pn > 1 && $pn < $lastPage) { $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> &nbsp;'; $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;'; $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> &nbsp;'; } // sets the limit range for pagination $limit =($pn - 1)*$itemsPerPage; $query2 = "SELECT * FROM $db_table ORDER BY acceleration DESC LIMIT $limit,$itemsPerPage"; $sql2 = mysql_query($query2) or die ('Error in request');; ?><input type="hidden" value="<? echo mysql_num_rows($result); ?>" id="numberofitems"><? $x=0; // $sql2 is used to fuel our while loop statement below while($rows=mysql_fetch_array($sql2)){ $utc_ts = revertTimeStamp($rows['Date']); $local_ts = $utc_ts+46800; $mytime = date("M. d, Y, h:i:s A",$local_ts); $str = $rows['time2']; //formats the collision time to 24hr //Get last 6 chars $end = substr($str, -6); //Split strint into an array. Each element is 2 chars $chop = str_split($end, 2); //Convert array to string. Each element separated by the given separator. $fg = implode(':', $chop);

$id = $rows['identity']; //settings for displaying the severity of the accident if ($rows['acceleration']>=8)

{ $intensity ="Very Severe"; $intense="vsevere"; } if ($rows['acceleration']<3) { $intensity ="Light"; $intense="light"; } if ($rows['acceleration']>=3 && $rows['acceleration']<8) { $intensity ="Moderate"; $intense ="moderate"; } ?> <tr> <td id="mytime<? echo $x; ?>"><a href="/details.php?identity=<? echo $id; ?>&x=<? echo $x; ?>&send=ok"><? echo $mytime;?></a></td> <td class="<? echo $intense; ?>" style="width:80px;" id="intensity<? echo $x; ?>"><? echo $intensity;?> </td> <td id="myacceleration<? echo $x; ?>"><? echo (float) $rows['acceleration']; ?> </td> <td id="plate<? echo $x; ?>"><? echo $rows['plate']; ?> </td> <td id="coorX<? echo $x; ?>"><? echo (float) $rows['coorX']; ?> </td> <td id="coorY<? echo $x; ?>"><? echo (float) $rows['coorY']; ?> </td> <td id="time<? echo $x; ?>"><? echo $fg; ?></td> <td><input type="checkbox" value="View Accident" id="action<? echo $x; ?>" onclick="display(<? echo $x; ?>)">View Accident</td> </tr> <?php $x=$x+1; //identifier for the information displayed $f=$x+1; } mysql_close($conn); //displays the pagination links $paginationDisplay = ""; // Initialize the pagination output variable // This code runs only if the last page variable is ot equal to 1, if it is only 1 page we require no paginated links to display if ($lastPage != "1"){ // This shows the user what page they are on, and the total number of pages $paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' . $lastPage. '&nbsp; &nbsp; &nbsp; ';

// If we are not on page 1 we can place the Back button if ($pn != 1) { $previous = $pn - 1; $paginationDisplay .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> Back</a> '; } // Lay in the clickable numbers display here between the Back and Next links $paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>'; // If we are not on the very last page we can place the Next button if ($pn != $lastPage) { $nextPage = $pn + 1; $paginationDisplay .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '"> Next</a> '; } } ?> </table> <?php echo $paginationDisplay; ?></center><br><br> </div> </table></div><br><br> </body> </html>

Appendix I Details.php Page Code


<html> <head> //title of the page <title>Design of A Vehicular Collision Automatic Advisory and Data Management System</title> <link rel="shortcut icon" href="symbol.ico" /> <link rel="stylesheet" type="text/css" media="screen and (min-width: 240px) and (max-width:800px)" href="small.css" /> <link rel="stylesheet" type="text/css" href="greys.css" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> //Java Script for embedding google maps starts here <!-- NOTE: this Map api is using the google "API key" of adrianvill aka "Technoblaze"--> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDyhStQGK2_09jn8o1kauHv 8qo3F3YJYfk&sensor=false"> </script> <!-######################################################################## #####--> <script type="text/javascript"> //sets the center of the map to Cebu City var mapcenter = new google.maps.LatLng(10.315,123.885); var map; var infowindow = new google.maps.InfoWindow(); var time = new Array(); var myimage = 'http://www.skyscrapercity.com/images/smilies/sad.gif'; var coorX = new Array(); var coorY = new Array(); var acceleration = new Array(); var myfunc = {}; var marker = [],circles = [], mapinfo = {},lid=2,i; var myCircle; function initialize() { var mapOptions = { zoom: 11, mapTypeId: google.maps.MapTypeId.ROADMAP, center: mapcenter };

//sets the ID name to be recognized by the html document or PHP page map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); display(-1); } function warshock(lid) { //Acquire data from HTML document with variables set by the PHP Page time.push(document.getElementById('mytime'+lid).innerHTML); coorX.push(document.getElementById('coorX'+lid).innerHTML); coorY.push(document.getElementById('coorY'+lid).innerHTML); acceleration.push(document.getElementById('myacceleration'+lid).innerHTML); //Create Map Markers.. var myobject = new google.maps.Marker({ map:map, draggable:false, animation: google.maps.Animation.DROP, // icon: myimage, position: new google.maps.LatLng(coorX[coorX.length1],coorY[coorY.length-1]) }); marker.push(myobject); var cid=time.length-1; var did=acceleration.length-1; c="infowindow.setContent('<b><i> '+time["+cid+"]+'</i></b><br>Peak Acceleration:<b> '+acceleration["+did+"]+'</b>');infowindow.open(map, this);"; google.maps.event.addListener(myobject, 'click', new Function(c)); //Create intensity Circles var intensity = parseFloat(acceleration[acceleration.length-1]); //sets the value/threshold and settings of markers for very severe accidents if(intensity>=8){ var Severity = {strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 1, fillColor: '#000FFF', fillOpacity: 0.75, map: map, center: new google.maps.LatLng(coorX[coorX.length1],coorY[coorY.length-1]), radius: intensity*60 }; } //sets the value/threshold and settings of markers for light accidents else if(intensity<3){ var Severity = {strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 1,

fillColor: '#FFFF00', fillOpacity: 0.35, map: map, center: new google.maps.LatLng(coorX[coorX.length1],coorY[coorY.length-1]), radius: intensity*60 }; } //sets the value/threshold and settings of markers for very moderate accidents else { var Severity = {strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 1, fillColor: '#660000', fillOpacity: 0.65, map: map, center: new google.maps.LatLng(coorX[coorX.length1],coorY[coorY.length-1]), radius: intensity*60 }; } myCircle = new google.maps.Circle(Severity); circles.push(myCircle); } //function display/not display function display(parameter){ i = parseInt(document.getElementById('numberofitems').value); if( parameter>-1){ if(document.getElementById('action'+parameter).checked==false){ circles[parameter].setMap(null); marker[parameter].setMap(null);} else { circles[parameter].setMap(map); marker[parameter].setMap(map);

} } //displays the markers for x=0 where x stands as the identifier for data in each row if( parameter == -1){ j=0 while(j<i){warshock(j); if(document.getElementById('action'+(j)).checked==false){ circles[j].setMap(null); marker[j].setMap(null);} j++;} //continuously display marker } return 'ok'; //signals that the script is working

} //Refresh page every 300 seconds setTimeout('location.reload()', 300000); //refreshes the page every five minutes </script> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.simplePagination.js"></script> </head> <body onload="initialize()">//initializes all the scripts loaded into the page <td> <div align="center"><img src="headersmall.jpg"></div>//embeds the header image <div class="white"> <div align="center" id="navigation"><nav>//embeds the navigation links //navigation links <ul> <li><a class="head" href="default.php">Home</a></li> <li><a class="head" href="faq.php">Faq</a></li> <li><a class="head" href="documentation.php">documentation</a></li> <li><a class="head" href="owners.php">owners</a></li> <li><a class="head" href="credits.php">credits</a></li> <li><a class="head" href="contact.php">contact</a></li> </ul> </nav><br></div> //puts a horizontal border for separating the main content and header area <div id="horizon"></div> <div align="center" id="map_canvas"><br><br> //embeds the map in the page </div> <div id="accident"> //embeds the content of the page <center><img align="left" src="icon2.jpg"><p align="justify">Welcome to our website! This website was made in the fulfillment of our undergraduate thesis. In this page you can see all the logged data from our database. The table below includes all the important details of the accident - time, location (with coordinates) and severity of the accident. Click on the checkbox 'View Accident' in order to see the location of the accident in the map provided on the right side. To view the details of a specific accident, just click on the of the accident and it will redirect you to its details page. You can explore the different pages of this site using the navigation links above. If you have any questions, you may contact us in the Contacts page.<br> Note:</p> <li class="note" align="justify">All accidents are classified into three types: Very Severe (for accidents having a peak acceleration of more than 8g); Moderate (for accidents having a peak

acceleration in between 3g to 8g); and Light (for accidents having a peak acceleration of less than or equal to 3g).</li> <li class="note" align="justify">All peak accelearations are measured in terms of <i>g</i> where 1g = acceleration on earth due to gravity = 9.81 meters per second squared.</li> <li class="note" align="justify">All displayed time in the table below are of GMT+8 Standards while the time logged onto the database is on GMT-5</li> <li class="note" align="justify">Collision Time is in 24-hour format and is in GMT+8 settings</li> <li class="note" align="justify">All positive X-Coordinates are coordinates in the northern hemisphere of the earth, while all negative X-coordinates are coordinates of the southern hemisphere of the earth. (e.g. 123.221N = 123.221; 112.331S = -112.331) </li> <li class="note" align="justify">All positive Y-Coordinates are coordinates in the eastern hemisphere of the earth, while all negative Y-coordinates are coordinates of the western hemisphere of the earth. (e.g. 123.221E = 123.221; 112.331W = -112.331)</li> <li class="note" align="justify">You can sort the list of accidents by <a href="default.php">Date of Accident</a> or by <a href="acceleration.php">Severity</a></li> <li class="note" align="justify">This site is best viewed with 1280x800 resolution and up.</li><br></center> //embeds the table with the information from the database <center> <div class="separate"> </div> <table> <h2>ACCIDENTS LIST</h2> <tr> <td><b>Date and Time</b></td> <td><b>Severity</b></td> <td><b>Peak Acceleration (in g)</b></td> <td><b>Plate No.</b></td> <td><b>X - Coordinate</b></td> <td><b>Y - Coordinate</b></td> <td><b>Collision Time</b></td> <td><b>Location</b></td> </tr> <!-- PHP CODE HERE START--> //connects the PHP page into the database <?php $db_table = 'arduino'; //selects the table from the database which contains the data to be displayed $dbname = 'a6705968_oink'; //connects to the database with username $conn = mysql_connect('mysql15.000webhost.com', 'a6705968_oink', 'arduino555') or die ('Error connecting to mysql'); //connects to the database through username and password and database host mysql_select_db($dbname);

//function that converts the GMT-5 timezone of the database to GMT+8 function revertTimeStamp($timestamp) { $year=substr($timestamp,0,4); $month=substr($timestamp,5,2); $day=substr($timestamp,8,2); $hour=substr($timestamp,11,2); $minute=substr($timestamp,14,2); $second=substr($timestamp,17,2); $newdate=mktime($hour,$minute,$second,$month,$day, $year); return($newdate); } //query for displaying a details of the accident $sql = "SELECT * FROM $db_table WHERE identity='$id'"; $result = mysql_query($sql) or die(mysql_error()); //executes the query } ?><input type="hidden" value="<? echo mysql_num_rows($result); ?>" id="numberofitems"><? while($rows=mysql_fetch_array($result)) { //converts the timestamp of database to GMT+8 $utc_ts = revertTimeStamp($rows['Date']); $local_ts = $utc_ts+46800; $mytime = date("M. d, Y, h:i:s A",$local_ts); $s= $rows['coorX']; $t= $rows['coorY']; //converts the collision time to 24hr $str = $rows['time2']; //Get last 6 chars $end = substr($str, -6); //Split strint into an array. Each element is 2 chars $chunks = str_split($end, 2); //Convert array to string. Each element separated by the given separator. $fg = implode(':', $chunks); //sets the settings for displaying the severity if ($rows['acceleration']>=8) { $intensity ="Very Severe"; $intense="vsevere"; } if ($rows['acceleration']<3) {

$intensity ="Light"; $intense="light"; } if ($rows['acceleration']>=3 && $rows['acceleration']<8) { $intensity ="Moderate"; $intense ="moderate"; }

?> <script defer> //script that automatically zooms the map to the location of the accident setTimeout( function(){ map.setZoom(13); map.setCenter(new google.maps.LatLng(<? echo (float) $rows['coorX']; ?>,<? echo (float) $rows['coorY']; ?>));} , 4000); </script> <tr> //table for displaying the details <td id="mytime<? echo $x; ?>"><? echo $mytime;?></a></td> <td class="<? echo $intense; ?>" style="width:80px;" id="intensity<? echo $x; ?>"><? echo $intensity;?> </td> <td id="myacceleration<? echo $x; ?>"><? echo (float) $rows['acceleration']; ?> </td> <td id="plate<? echo $x; ?>"><? echo $rows['plate']; ?> </td> <td id="coorX<? echo $x; ?>"><? echo (float) $rows['coorX']; ?> </td> <td id="coorY<? echo $x; ?>"><? echo (float) $rows['coorY']; ?> </td> <td id="time2<? echo $x; ?>"><? echo $fg; ?> </td> <td><input type="checkbox" value="View Accident" id="action<? echo $x; ?>" onclick="display(<? echo $x; ?>)" checked>View Accident</td> </tr> <?php $x=$x+1; $f=$x+1; } mysql_close($conn); $paginationDisplay = ""; // Initialize the pagination output variable // This code runs only if the last page variable is ot equal to 1, if it is only 1 page we require no paginated links to display if ($lastPage != "1"){

// This shows the user what page they are on, and the total number of pages $paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' . $lastPage. '&nbsp; &nbsp; &nbsp; '; // If we are not on page 1 we can place the Back button if ($pn != 1) { $previous = $pn - 1; $paginationDisplay .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> Back</a> '; } // Lay in the clickable numbers display here between the Back and Next links $paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>'; // If we are not on the very last page we can place the Next button if ($pn != $lastPage) { $nextPage = $pn + 1; $paginationDisplay .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '"> Next</a> '; } } ?> </table> <p align="justify" class="note">Note:</p> <li class="note" align="justify">All accidents are classified into three types: Very Severe (for accidents having a peak acceleration of more than 8g); Moderate (for accidents having a peak acceleration in between 3g to 8g); and Light (for accidents having a peak acceleration of less than or equal to 3g).</li> <li class="note" align="justify">All peak accelearations are measured in terms of <i>g</i> where 1g = acceleration on earth due to gravity = 9.81 meters per second squared.</li> <li class="note" align="justify">All displayed time in the table below are of GMT+8 Standards while the time logged onto the database is on UTC Standards</li> <li class="note" align="justify">Collision Time is in 24-hour format and is in GMT+8 settings.</li> <li class="note" align="justify">All positive X-Coordinates are coordinates in the northern hemisphere of the earth, while all negative X-coordinates are coordinates of the southern hemisphere of the earth. (e.g. 123.221N = 123.221; 112.331S = -112.331) </li> <li class="note" align="justify">All positive Y-Coordinates are coordinates in the eastern hemisphere of the earth, while all negative Y-coordinates are coordinates of the western hemisphere of the earth. (e.g. 123.221E = 123.221; 112.331W = -112.331)</li> <li class="note" align="justify">This site is best viewed with 1280x800 resolution and up.</li><BR> </center><br><br> </div> </table><br><br>

<div align="center" id="footer">&copy; All PAGES CODED BY TEAM WARSHOCK 2013</div><BR> </body> </html>

Appendix J Receive.php Page Code

//trims the data from the url <?php if(isset($_GET['send'])) { $A = trim($_GET['acceleration']); $B = trim($_GET['coorX']); $C = trim($_GET['coorY']); $D = trim($_GET['plate']); $E = trim($_GET['time2']); //convert the collision time to Philippine time zone $F=$E+80000; if ($F>=240000) { $F=$F-240000; } //exclude the unit of acceleration when acceleration is logged into the database $G = floatval($A); //connect the page to the database $dbname = 'a6705968_oink'; $conn = mysql_connect('mysql15.000webhost.com', 'a6705968_oink', 'arduino555') or die ('Error connecting to mysql'); mysql_select_db($dbname); //log the trimmed data from the url to the database $query = "INSERT INTO arduino (acceleration, coorX, coorY, plate, time2) VALUES ('$G', '$B', '$C', '$D', '$F')"; mysql_query($query) or die('Not posted'); //returns when it fails to connect to the database mysql_close($conn); } ?> //returns the text once data is logged into the database <html><body>Data Received</body></html><? ?>

Appendix K Greys.css Cascading Style Sheet


body { background-color:#ffffff; background-image: url('background.jpg'); color: #000000; font-family:Helvetica; font-size:10pt; overflow auto; } #header { height:300px; float: top; } #navigation { } #horizon { border-bottom:2px solid #888888; } #welcome { margin-left:auto; margin-right:auto; position: absolute; overflow:auto; top: 380px; max-width:800px; } #accident { margin-left:auto; margin-right:auto; overflow-x:visible; overflow-y:visible; position: absolute;

width:50%; left: 10px; top: 210px; padding:10px; max-width:800px; } #map_canvas { overflow:auto; position:absolute; top:240px; left:57%; height: 700px; width: 40%!important; border: 1px solid #000000; padding-bottom:10px; } .map { width:50%; height:60%; float: right border:1px solid #000000; } #footer { font-family: Helvetica; font-size:9pt; text-transform: uppercase; text-align:center; position: absolute; top:950px; } h1 { color:#000000; font-weight:bold; text-align:center; font-size: 9pt; } .separate {

border-bottom:2px solid #000000; } h2 { font-family: Helvetica; font-weight: bold; text-transform: uppercase; font-size: 13pt; } h3 { font-family: helvetica; font-size:11pt; text-transform:uppercase; } a:link { color:#ff0000; font-size: 9pt; text-transform:uppercase; font-family: Helvetica; border-bottom:0px; text-decoration: none; } a:visited { color:#ff0000; font-size: 9pt; text-transform:uppercase; font-family: Helvetica; border-bottom:0px; text-decoration: none; } a:hover { color:#ffffff; background-color:#000000; border-bottom:0px; text-transform:uppercase; font-family: Helvetica; font-size: 9pt; border-bottom:0px; text-decoration: none;

} a:active { color:#ff0000; text-transform:uppercase; font-family: Helvetica; font-size: 9pt; font-style: italic; border-bottom:0px; text-decoration: none; } p { font-family:Helvetica; font-size:10pt; text-align: justify; } i { font-family:Georgia; font-style:italic; } p.note { font-family: Helvetica; font-size:8.5pt; } li.note { font-family: Helvetica; font-size:8.5pt; } a.head:link { color:#757575; font-family: Helvetica; font-weight: bold; font-size: 11pt; text-transform: uppercase; } a.head:visited

{ color:#757575; font-weight: bold; font-family: Helvetica; font-size: 11pt; text-transform: uppercase; } a.head:hover { color:#ffffff; font-weight: bold; font-family: Helvetica; font-size: 11pt; background-color:#4b545f; font-weight:bold; border-bottom: 0px solid #000000; text-decoration: none; text-transform: uppercase; } a.head:active { color:#757575; font-family: Helvetica; font-size: 11pt; font-weight: bold; text-transform: uppercase; }

td { table-layout:auto; min-width:60px; width:350px; border:1px solid #000000; color: #000000; font-family:Helvetica; font-size:9pt; overflow:hidden; background-color: #ffffff; } tr { table-layout:auto; background-color: #ffffff;

} table { table-layout:auto; width:350px; color: #000000; font-family:Helvetica; font-size:9pt; overflow:hidden; border:1px solid #000000; background-color: #ffffff; } td.invi { table-layout:auto; } tr.invi { table-layout:auto; } table.invi { table-layout:auto; } th { table-layout:auto; width:350px; height:50px; overflow:hidden; background-color: #ffffff; } td { table-layout:fixed; width:350px; text-align:center; border:1px solid #000000; overflow:hidden;

background-color: #ffffff; } table, td { table-layout:auto; width:50%; height:35px; vertical-align:center; border:1px solid #000000; color: #000000; font-family:Helvetica; font-size:9pt; overflow:hidden; background-color: #ffffff; } td { table-layout:auto; width:350px; padding:5px; overflow:hidden; background-color: #ffffff; } td.vsevere { border:1px solid #000000; font-family: Helvetica; font-size:9pt; background-color:#6391b2; overflow:hidden; height:35px; color:#000000; } td.moderate { border:1px solid #000000; font-family: Helvetica; font-size:9pt; background-color:#ff8989; overflow:hidden; height:35px; color:#000000; }

td.light { border:1px solid #000000; font-family: Helvetica; font-size:9pt; background-color:#f2ff95; overflow:hidden; height:35px; color:#000000; } nav ul { background: #efefef; background: linear-gradient(top, #efefef 0%, #bbbbbb 100%); background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%); background: -webkit-linear-gradient(top, #efefef 0%,#bbbbbb 100%); box-shadow: 0px 0px 9px rgba(0,0,0,0.15); padding: 0 20px; border-radius: 7px; list-style: none; position: relative; display: inline-table; } nav ul:after { content: ""; clear: both; display: block; } nav ul li { float: left; } nav ul li:hover { background: #4b545f; background: linear-gradient(top, #4f5964 0%, #5f6975 40%); background: -moz-linear-gradient(top, #4f5964 0%, #5f6975 40%); background: -webkit-linear-gradient(top, #4f5964 0%,#5f6975 40%); } nav ul li:hover a { color: #fff; } nav ul li a { display: block; padding: 15px 20px; color: #757575; text-decoration: none; }

Appendix L Photo Documentation

Screenshots of the text messages transmitted by the Client Module

Prototype and its LED Indicator

Testing at Paseo Arcenas, Banawa, Cebu

Testing at Shell Basak, Pardo, Cebu

Testing at Jollibee North Reclamation Area

Testing at McDonalds Lapu-Lapu

You might also like