Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
December 2, 2007
Michael Bittle
Patrick Brandt
Andrew Facemire
Michelle Hunt
Michael Sweetman
Contact Person:
Andrew Facemire
304-290-6837
afacemire@gmail.com
-1-
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
Table of Contents
1. Requirement Achievement.............................................................................................. 3
2. Financial Report.............................................................................................................. 4
2.1 Proposed Budget ....................................................................................................... 4
2.2 Proposed Budget Justification................................................................................... 5
2.3 Actual Budget ........................................................................................................... 6
2.2 Actual Budget Justification....................................................................................... 7
3. Work Division................................................................................................................. 8
3.1 Original Work Division ............................................................................................ 8
3.2 Final Work Division ................................................................................................. 9
4. System Operation.......................................................................................................... 10
4.1 Design Level 0 ........................................................................................................ 11
4.2 Design Level 1 ........................................................................................................ 13
4.2.1 Node Network.................................................................................................. 14
4.2.2 Server ............................................................................................................... 17
4.2.3 Database........................................................................................................... 18
4.2.4 Client................................................................................................................ 19
4.3 Design Level 2 ........................................................................................................ 21
4.3.1 Wearable End Device ...................................................................................... 22
4.3.2 Routing Node ................................................................................................... 24
4.3.3 Coordinator Node............................................................................................. 27
4.3.4 Server ............................................................................................................... 29
5. Secondary Design Aspects............................................................................................ 30
5.1 Analysis Methods and Experiments........................................................................ 30
5.2 Ethical and Social Impact ....................................................................................... 30
5.3 Engineering Standards ............................................................................................ 31
5.4 Economic Analysis ................................................................................................. 31
5.5 Considered Issues.................................................................................................... 31
5.6 Team Learning ........................................................................................................ 31
5.7 Improvement in Technical Writing......................................................................... 32
6. References..................................................................................................................... 33
Appendix 1 – End Device Code........................................................................................ 34
Appendix 2 – Router Code. .............................................................................................. 36
Appendix 3 – Coordinator Code. ...................................................................................... 39
Appendix 4 – Coordinator, Router, and End Device Function Calls................................ 44
Appendix 5 – Client and Server Code .............................................................................. 56
-2-
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
1. Requirement Achievement
Engineering
Engineering Requirement Requirement
Requirement Reasoning
Description Met?
No.
The system should record, in real The node network will track
1 time, miners’ positions as they enter Yes positions as miners move
new sections in the mine. throughout the mine.
The miner data will be
The system should transmit position
transmitted via the node
2 data to an above ground database Yes network to the above
without loss of data.
ground database.
All underground equipment should be Building ruggedized
constructed to withstand the enclosures was a detail that
3 underground mining environment for
No time did not permit us to
the life of the mine. explore.
The single board computers
that pair with the modems
The system should be battery powered consume too much power to
(minimum of 6 month battery life) or operate for six months on a
4 draw power from existing supply lines
Yes single batter. However, the
(110 AC or 330 DC). nodes are capable of
drawing power from
110AC source.
New nodes can be
Mine expansions should be
seamlessly integrated into
accommodated into the system so
5 position information can be recorded
Yes the system by configuring
their settings and placing
in new sections.
them in the mine.
The database should be able to The database only inserts
recover from errors received during correct information and
6 position transmission and data loss
Yes disregards errors and data
throughout the life of the system. loss.
The client displays the
The system should display position
miner information in table
7 information using a graphical user Yes format using a graphical
interface.
user interface.
The system should require no routine The system requires no
8 maintenance other than possible Yes routine maintenance.
battery replacement.
The system operates in the
The system should not operate in
2.4 GHz frequency range,
currently used radio frequency
9 spectrums used by primary mine
Yes and does not interfere with
current mine equipment or
equipment.
communications.
Error information is
The system should transmit system
handled at a lower level and
10 error information to the above ground No does not need to be
database for correction.
transmitted to the database.
The wearable tracking
The wearable tracking device should device is less than two
11 not exceed two pounds and should be Yes pounds and could be made
small enough to clip onto a belt. into a small wearable
device.
The system should present no barriers Anyone that has access to
12 to accessing tracking information in Yes the client computer may
the event of an emergency. access miner information.
The system should cost no more than The cost of each node is
$200 per wearable tracking device, below the price limitations.
13 $500 per location node, and $1500 for Yes
the software and hardware for the
above ground database.
-3-
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
2. Financial Report
2.1 Proposed Budget
NODES
SERVER/DATABASE
CLIENT
____________________________ _________________________________
Sponsor Signature Date Chair Signature Date
_______________________________
Monitor Signature Date
-4-
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
1 Freescale 1321XDSK
2 Freescale MC13213
3 Cables, software
4 Server/Database machine
5 MySQL
6 Client machine
-5-
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
CLIENT/SERVER/DATABASE
____________________________ _________________________________
Sponsor Signature Date Chair Signature Date
_______________________________
Monitor Signature Date
-6-
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
2 X-Bee Modem
3 Workstation Computer
4 X-TCU Software
14 Terminal Strip
15 Spade Tongue
17 Miscellaneous
18 Client/Server Computer
21 MySQL Database
-7-
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
3. Work Division
3.1 Original Work Division
DDR =
Detailed Design Review, SSR = Subsystem Review, DF = Design Fair, and FPE= Final Project Evaluation
-8-
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
DDR = Detailed Design Review, FR = Final Report, DF = Design Fair, and FPE= Final Project Evaluation
-9-
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
4. System Operation
Every miner entering the mine will be equipped with a wearable tracking device.
Throughout the mine there will be stationary nodes whose primary purpose is to identify
and record the network identification numbers of the wearable tracking devices carried by
miners. The tracking devices will remain in a broadcast-hibernate pattern. The stationary
router nodes will be actively listening for broadcasts from the wearable tracking device.
When it receives a broadcast, the stationary node will append its network identification
number (Node ID) to the Miner ID.
The next step is for the stationary routing nodes to transmit the information
through the network to the coordination node at the entrance to the mine. It will do this
by transmitting the combined Node ID and Miner ID to the next router node with a
smaller Node ID. This process is repeated until the position information arrives at the
coordinator node.
Once the coordinator node has received tracking information, a socket connection
is established between the coordinator node and the server and the data is transferred to
the server. The server will take the received information and place it in a database for
future reference by the client interface. Our system will be designed so that the client may
request data at any time from the system. Upon such a request, the client interface will
direct the server to connect to the database and retrieve the queried information. Once the
information has been delivered to the client, it will display the data to the user in a
manner consistent with the client's request parameters.
- 10 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
- 11 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
Table 1: Level 0 functional design description for the Emergency Mine Rescue System
Module Mine Tracking System
Inputs Miner ID: A unique identifier associated with a miner’s wearable end
device.
Power: Battery or AC outlet to 9VDC 1.1A power supply coupled with
a 7805 voltage regulator.
SBC draws 5V @ 0.5A during normal operation
SBC draws 5V @ 0.25A during sleep mode
Modem draws 3.3V @ 0.215A during transmit
Modem draws 3.3V @ 0.055A during receive
Outputs Miner Name, Location, Time, Job Information: Information displayed
on the client that shows all data the system.
Functionality Associates a Miner ID with a location, and time.
Displays a miner's name, location, time, and job information.
- 12 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
Power
Node Miner ID
Server
Network Node ID
Miner ID
- 13 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
The node network is the underground system of wireless modems and single
board computers that will receive a Miner’s ID tag, associate it with a location, and send
the information from node to node until it reaches the coordinator node. From the
coordinator node, the position information is transferred to an outside database. Each
node consists of a Maxstream XBee Pro modem and a Technologic TS-7200 ARM
Single Board Computer that can wirelessly communicate with each other.
Every single board computer has a fully functioning version of Linux installed on
the flash card that is used as a programming environment. A 10 base 100 Ethernet port is
also included on the single board computer to transfer files. Each modem acts as a
wireless serial connection; the modem will transmit whatever is sent to it from the single
board computer. The nodes can be powered using by battery or an AC outlet. The AC
power feeds into a to 9 VDC 1.1A power supply which can directly power the modem.
To power the single board computer the output from the power supply must be directed
through a 7805 voltage regulator. Due to the large amount of heat generated by the 7805
voltage regulator must be attached to a heat sink.
After the nodes’ network ID numbers or Node IDs have been programmed, the
nodes can be placed into their respective network positions and powered on. A script on
each single board computer will compile and run the code. After the code has initialized
the system is ready to track miners as they move through the network.
- 14 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
- 15 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
- 16 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
4.2.2 Server
The server will receive miners’ identification information and node identification
numbers from the node network and store it in the database. Upon request from the client
interface, the server will perform a database query, retrieve the query results, and send
the appropriate data to be displayed to the client. See Appendix 5 for detailed
implementation.
- 17 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
4.2.3 Database
The database for the Mine Tracking System will hold job skills, Miner IDs, Node
IDs and the associated timestamps. The Miner ID with the Node ID and associated
timestamp is referred to as the miner location. The server will retrieve this information
when data is requested from the client. The database is powered by open source MySQL.
PHP scripting is used on the server to access the MySQL database when a request is
received from the client. The database has been implemented using five distinct tables
which hold the necessary information and linking of data across multiple tables. See the
section on the client interface (4.2.4) and Appendix 5 for more information on the SQL
functions used.
- 18 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
4.2.4 Client
The client will display queried tracking information that has been requested from
the server. The client will allow multiple query parameters in order to display specific
data. It also allows the addition of new miner information; miner information consists of
miner ID, name, and job skill(s).
This user interface is the primary means by which users of the system access
miner information. The client is implemented as a database-driven web interface. The
client instructs the server on what data to retrieve from the database. The web interface is
divided into two primary levels of access, users and administration. The client allows
users to view miner information such as Name, Miner ID, Location, Time, and Job
Skill(s).
Administration has a robust tool set which allows modification of system users
and related variables. The administration portion of the site is secured by user
authentication. Usernames and associated passwords are stored in a separate database
table. Administration sessions are maintained by the use of cookies stored on the client
machine.
Administration has the ability to add and remove users from the system, which
allows Miner IDs to be re-associated with a new user. Job skills can be maintained and
updated from the administration interface also. As new nodes are placed into the system,
administration can update the database to reflect these changes.
The client is powered by MySQL and PHP, using the SQL query language to add
and retrieve data from the database. PHP, a server-side scripting language is used to
connect to and query the database when the client makes requests for data stored in the
database. See Appendix 5 for implementation details of the client interface.
- 19 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
- 20 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
- 21 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
The miner’s wearable end device will be attached to a miner at all times while he
or she is inside a mine. When powered on, the end device will compile and run the end
device specific program. Each program has a unique Miner ID associated with it, and
will broadcast that ID to its surrounding area to be received by a stationary node. The
end device program transmits its information continually while powered on, allowing for
proper tracking of a miner though the system.
The end device program begins by opening COM port 2 at a baud rate of 115200
bits per second and associates the modem with the single board computer terminal
device. The “send_data” function is then utilized to broadcast the miner ID to any router
node in its vicinity by setting the destination address equal to “0xFFFF”. The send_data
function builds a buffer of acknowledgement options, frame identifier, frame size,
destination address, and the payload. This collection of data is then sent to the modem
through the serial cable using the C library command “write”. Once the information is
loaded into the buffer the information is propagated out of the modem’s antenna. See
Appendix 1 and Appendix 4 for the source code.
Table 6: Level 2 functional design description for the Wearable End Device
Module Wearable End Device
Inputs Miner ID: A unique identifier associated with a miner’s wearable end
device.
Power: Battery or AC outlet to 9VDC 1.1A power supply coupled with
a 7805 voltage regulator.
SBC draws 5V @ 0.5A during normal operation
SBC draws 5V @ 0.25A during sleep mode
Modem draws 3.3V @ 0.215A during transmit
Modem draws 3.3V @ 0.055A during receive
Outputs Miner ID: A unique identifier for a miner’s wearable tracking device.
Functionality Broadcast the Miner ID for reception by stationary nodes.
- 22 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
- 23 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
The routing node program begins by opening COM port 2 at a baud rate of
115200 bits per second and associates the modem with the single board computer
terminal device. Next, the modem address and destination address is manually set using
an assignment statement. The routing node then waits for a received signal from an end
device. The data frame is read using the “read_data” function. The Miner ID and Node
ID are found by reading the eighth through eleventh bytes of the data frame. If the Node
ID is equal to zero, this signifies that this is the first router node to see the end device,
and it should assign its network identification number into the nodeID variable.
The “send_data” function is then utilized to transmit the Miner ID and Node ID to
the next router node in sequence by setting the destination address equal to one minus its
own address. Along the main path of transmission Node IDs are numbered sequentially.
Furthermore, as nodes are placed further from the entrance of the mine their Node ID
parameter increases in number. To transfer a packet to the entrance of the mine the
router node should transmit to another router whose Node ID is one less than that of its
identifier, frame size, destination address, and the data itself. This collection of data is
then sent to the modem through the serial cable using the C library command “write”.
- 24 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
- 25 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
- 26 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
The Coordinator code is compiled and run on the node closest to the entrance of
the mine. When run it sets up an SQL connection to the database and creates a socket to
send data to the server. The coordinator node program then opens COM port 2 at a baud
rate of 115200 bits per second and associates the modem with the single board computer
terminal device. It then waits to receive miner information from a routing node. Once
received it parses out the Miner ID and Node ID from the data frame and utilizes a socket
connection to send the data to the server. The Coordinator then returns to waiting for the
- 27 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
- 28 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
4.3.4 Server
The coordinator node creates a socket connection with the server. When the
coordinator node receives new data (Miner ID and Node ID) from other nodes, the socket
is created and the coordinator node sends the data to the server via the socket connection.
The server then establishes a MySQL connection to the database and inserts the new data
into the database.
- 29 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
- 30 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
- 31 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
- 32 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
6. References
[1] Mann, Jonathan. “Dangers of Mining”. 03 May 2006.
http://transcripts.cnn.com/TRANSCRIPTS/0605/03/i_ins.01.html
[2] Nutter, Roy. “Underground Coal Mine Communications and Tracking Status, SAGO plus one
year.” 26 Jan. 2006. IEEE IAS 2007 Annual Meeting.
[3] Coal Mine Communication. 2006. National Institute for Occupational Safety and Health. 17
February 2007 <http://www.cdc.gov/niosh/mining/pubs/pdfs/cmc.pdf>
[4] MSHA – Technical Support. 13 June 2006. Mine Safety and Health Administration. 17 February
2007 <http://www.msha.gov/techsupp/mcelroyminetestreport.pdf>
- 33 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
/* Function headers */
int open_port(int port, int baud);
int disable_binary();
void send_data(int fd, char *buf, int size, int type, int frame_ID, int
dest_address);
int read_data(int fd, char *buf, int size, struct timeval
*max_timeout);
int modem_fd;
long int guard_time = 3; /* Initial setting of 1 second guard
time. */
long int extra_guard_time = 100000; /* 100 ms */
int main() {
int status, i;
int which, maxfd;
char str1[] = "0100";
//FILE *file1 = fopen("stuff.txt", "w");
struct timeval timeout;
timeout.tv_usec = 50;
timeout.tv_sec = 0;
- 34 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
if (modem_fd == -1) {
//Error in opening COM port
printf("\nError opening COM port!!\n");
exit(0);
}
timeout.tv_sec = guard_time;
timeout.tv_usec = extra_guard_time;
which = select(maxfd+1, NULL, NULL, NULL, &timeout);
//Send/receive data
send_data(modem_fd, str1, 4, TRANSMIT, 0x00, 0x2);
- 35 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
/* Function headers */
int open_port(int port, int baud);
int disable_binary();
void send_data(int fd, char *buf, int size, int type, int frame_ID, int
dest_address);
int read_data(int fd, char *buf, int size, struct timeval
*max_timeout);
int check_fd(int fd, int usec);
int enter_command_mode();
int exit_command_mode();
- 36 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
int write_params();
void send_to_modem(char *buf, char *command);
int ascii2hex(char *);
void fd_dump(int fd);
int main() {
int status, i, nbytes = 0;
char str1[MAX_PACKET_SIZE];
char str2[4];
char minerID[2];
char nodeID[2];
int which;
char tempBuffer[MAX_PACKET_SIZE+1];
char *bufptr;
char readDL[] = "ATDL";
int DL;
int MY;
char DLcommand[10];
timeout.tv_usec = 50;
timeout.tv_sec = 0;
status = isatty(modem_fd);
if (status == 1) {
char *name, tempBuffer[MAX_PACKET_SIZE];
- 37 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
while(1) {
//Get Data from modem
strncpy(str1, "", 4); //clear str2
status = 0; //clear status
while(status != DATA_READY) {
status = check_fd(modem_fd, 0);
}
if (status == DATA_READY){
read_data(modem_fd, str1, MAX_API_PACKET, &timeout);
printf("\nMODEM READ:%s:\n", &str1[8]);
strncpy(minerID, &str1[8], 2);
printf("\nMINER ID:%s:\n", &minerID[0]);
strncpy(nodeID, &str1[10], 2);
printf("\nNODE ID:%s:\n", &nodeID[0]);
}
/* Write file */
//fprintf(file1, "%s\n", str2);
close(modem_fd);
fclose(file1);
return 0;
}
- 38 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
//Socket libraries
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <netdb.h>
- 39 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
//SQL Connection
mysql_init(&mysql);
connection = mysql_real_connect(&mysql, SRVR, USER, PSWD,
DATABASE, 0, 0, 0);
//Check connection
if(connection == NULL)
{
- 40 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
printf(mysql_error(&mysql));
return 1;
}
timeout.tv_usec = 50;
timeout.tv_sec = 0;
- 41 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
status = isatty(modem_fd);
if (status == 1)
{
char *name, tempBuffer[MAX_PACKET_SIZE];
MY=0;
if ( !strcmp(nodeID, "00") ) {
printf("\nFIRST NODE\n");
- 42 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
return 0;
}
- 43 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
case 2400:
rate = B2400;
break;
case 4800:
rate = B4800;
break;
case 9600:
rate = B9600;
break;
case 19200:
rate = B19200;
break;
case 38400:
rate = B38400;
break;
- 44 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
case 57600:
rate = B57600;
break;
case 115200:
rate = B115200;
break;
case 230400:
rate = B230400;
break;
default:
perror("Illegal baud rate.");
return -1;
}
cfsetispeed(&options, rate);
cfsetospeed(&options, rate);
return (fd);
int disable_binary() {
int which;
//De-assert RTS
which = ioctl(modem_fd, TIOCMBIC, &tiocm_rts);
if (which == -1)
{
perror("disable_binary");
return -1;
}
return 1;
}
- 45 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
void send_data(int fd, char *buf, int size, int type, int frame_ID, int
dest_address)
{
int written, temp, which, checksum;
char tempBuffer[MAX_API_PACKET];
char *bufptr;
if (type != NO_API)
{
tempBuffer[0] = (char) START_DELIMITER;
}
while(size)
{
if((written=write(fd,buf,size))>=0)
{
temp = 1;
size-=written;
buf+=written;
}
else
{
if (temp == 0)
{
perror("send_data");
return;
}
}
}
break;
}
case TRANSMIT:
{
temp = size + 5; /* Add size of Frames */
tempBuffer[1] = (char) ( (temp >> 8) & MASK_UPPER );
/* MSB */
tempBuffer[2] = (char) ( temp & MASK_UPPER );
/* LSB */
/* Send Frame ID */
tempBuffer[4] = (char) frame_ID;
checksum += frame_ID;
- 46 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
/* Send Option */
/* Send Data */
/* Change size */
size += 9;
temp = 0;
bufptr = tempBuffer;
printf("%s\n", &bufptr[8]);
while(size)
{
if((written=write(fd,bufptr,size))>=0)
{
temp = 1;
printf("Written %i of %i bytes.\n",
written, size);
size-=written;
bufptr+=written;
}
else
{
if (temp == 0)
{
perror("send_data");
return;
}
}
}
break;
}
case COMMAND:
{
/* Entire command is in buf variable */
temp = size + 2; /* Size with API Frames */
- 47 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
/* Send Command */
/* Change size */
size += 6;
temp = 0;
bufptr = tempBuffer;
while(size)
{
if((written=write(fd,bufptr,size))>=0)
{
temp = 1;
printf("Written %i of %i bytes.\n",
written, size);
size-=written;
bufptr+=written;
}
else
{
if (temp == 0)
{
perror("send_data");
return;
}
}
- 48 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
break;
}
default:
{
perror("type_switch in send_data");
return;
}
}
}
int read_data(int fd, char *buf, int size, struct timeval *max_timeout)
{
int total, nbytes, nfds;
fd_set temp_set;
struct timeval small_timeout, *timeout;
int times = 0;
total = 0;
FD_ZERO( &temp_set );
FD_SET( fd, &temp_set );
if (nfds == -1)
{
perror("read_data:");
return -1;
}
else if (nfds == 1) /* Data waiting */
{
nbytes = read( fd, buf, size );
if (nbytes == -1)
- 49 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
{
perror("read_data->post-read:");
return -1;
}
else if (nbytes == 0)
{
/* Could be EOF */
return total;
}
else
{
total+=nbytes;
size-=nbytes; /* Remaining bytes to read */
buf+=nbytes;
/*printf("Read %i bytes. Total %i bytes. Buf:
%p.\n", nbytes, total, buf);*/
}
}
else
{
/* Timeout (nfds == 0) */
if (times == 1)
{
printf("Syncing...\n");
/*fsync(fd);*/ /* Put back in if
needed */
}
else
return total;
}
}
fsync(fd);
return total;
}
FD_ZERO( &read_set );
FD_SET( fd, &read_set );
timeout.tv_sec = 0;
timeout.tv_usec = usec;
if ( nfds == -1 )
{
/* Do Nothing? */
perror("SELECT Error");
}
if ( FD_ISSET( fd, &read_set ) )
- 50 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
{
if (fd == modem_fd)
printf("Ready on modem...\n");
else
printf("Ready on pipe...\n");
return DATA_READY;
}
else
{
/* Nothing on modem */
return DATA_IDLE;
}
}
int enter_command_mode()
{
int which, maxfd;
char *bufptr;
char tempBuffer[TEMP_BUF_SIZE];
fd_set tempset;
struct timeval timeout;
timeout.tv_sec = guard_time;
timeout.tv_usec = extra_guard_time;
which = select( maxfd+1, NULL, NULL, NULL, &timeout ); /*
Wait for one second */
bufptr = COM_ENTER;
send_data( modem_fd, bufptr, strlen(COM_ENTER), NO_API, 0,
BROADCAST );
timeout.tv_sec = guard_time;
timeout.tv_usec = extra_guard_time;
which = select( maxfd+1, NULL, NULL, NULL, &timeout ); /*
Wait for one second */
maxfd = modem_fd;
FD_ZERO( &tempset );
FD_SET( modem_fd, &tempset );
timeout.tv_sec = 0;
timeout.tv_usec = extra_guard_time;
which = select( maxfd+1, &tempset, NULL, NULL, &timeout ); /*
See if data waiting */
if ( which == -1 )
{
perror("Command Mode SELECT Error");
return -1;
}
if ( FD_ISSET( modem_fd, &tempset ) )
{
/* Data waiting, check for "OK" */
bufptr = tempBuffer;
- 51 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
if (strcmp(tempBuffer, "OK") == 0)
{
return OK;
}
else
{
/* Temporary? */
printf("'%s'\n", tempBuffer);
return -1;
}
}
return -1;
}
int exit_command_mode()
{
char *bufptr;
char tempBuffer[TEMP_BUF_SIZE];
bufptr = tempBuffer;
send_to_modem(bufptr, "ATCN\r");
int write_params()
{
char *bufptr;
char tempBuffer[TEMP_BUF_SIZE];
bufptr = tempBuffer;
send_to_modem(bufptr, "ATWR\r");
- 52 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
bufptr = command;
send_data( modem_fd, bufptr, strlen(command), NO_API, 0,
BROADCAST);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
if (strlen(MY) == 1)
{
temp = MY[0];
MY[0] = '0';
MY[1] = temp;
}
switch(MY[0])
{
case('0'):
int1 = 0x00;
break;
case('1'):
int1 = 0x10;
break;
case('2'):
int1 = 0x20;
break;
case('3'):
int1 = 0x30;
break;
case('4'):
int1 = 0x40;
- 53 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
break;
case('5'):
int1 = 0x50;
break;
case('6'):
int1 = 0x60;
break;
case('7'):
int1 = 0x70;
break;
case('8'):
int1 = 0x80;
break;
case('9'):
int1 = 0x90;
break;
case('A'):
int1 = 0xA0;
break;
case('B'):
int1 = 0xB0;
break;
case('C'):
int1 = 0xC0;
break;
case('D'):
int1 = 0xD0;
break;
case('E'):
int1 = 0xE0;
break;
case('F'):
int1 = 0xF0;
break;
}
switch(MY[1])
{
case('0'):
int2 = 0x00;
break;
case('1'):
int2 = 0x01;
break;
case('2'):
int2 = 0x02;
break;
case('3'):
int2 = 0x03;
break;
case('4'):
int2 = 0x04;
break;
case('5'):
int2 = 0x05;
break;
case('6'):
- 54 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
int2 = 0x06;
break;
case('7'):
int2 = 0x07;
break;
case('8'):
int2 = 0x08;
break;
case('9'):
int2 = 0x09;
break;
case('A'):
int2 = 0x0A;
break;
case('B'):
int2 = 0x0B;
break;
case('C'):
int2 = 0x0C;
break;
case('D'):
int2 = 0x0D;
break;
case('E'):
int2 = 0x0E;
break;
case('F'):
int2 = 0x0F;
break;
}
timeout.tv_sec = 0;
timeout.tv_usec = 0;
- 55 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
*/
<?php
$db_name = "miner_db";
$connection = @mysql_connect("localhost", "senior_design",
"einstein7") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or
die(mysql_error());
<div class="midcontent">
<h1><center>Search for Miners Currently in System:</center></h1>
<table>
<FORM METHOD="post" ACTION="searchname.php">
<tr>
<td><strong>Name: </strong><div
class="subtitle">(first and/or last)</div></td>
<td><INPUT TYPE="text" NAME="miner_name"
SIZE="20"></td>
<td> <INPUT TYPE="submit"
NAME="submit" VALUE="Search Name"></td>
</tr>
</FORM>
</table><br>
<table>
<FORM METHOD="post" ACTION="searchid.php">
<tr>
- 56 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
<table>
<FORM METHOD="post" ACTION="searchnode.php">
<tr>
<td><strong>Node ID: </strong><INPUT
TYPE="text" NAME="nodeID" SIZE="10"></td>
<td> <INPUT TYPE="submit"
NAME="submit" VALUE="Search Node ID"></td>
</tr>
</FORM>
</table><br>
<table>
<FORM METHOD="post" ACTION="searchjob.php">
<tr>
<td><strong>Job Title: </strong><INPUT
TYPE="text" NAME="job_title" SIZE="15"></td>
<td> <INPUT TYPE="submit"
NAME="submit" VALUE="Search Job Title"></td>
</tr>
</FORM>
</table>
<?php
$sql = "SELECT * FROM miners_id, nodes WHERE
miners_id.miner_id = nodes.miner_id ORDER BY time DESC";
echo "<table border=\"2\" bordercolor=\"#336699\"
cellpadding=\"1\" cellspacing=\"2\" width=\"100%\">";
echo "<tr><h1><center>Miners Currently In
System</center></h1></tr>";
echo "<tr><td width=\"15%\" align=\"center\">ID</td>";
echo "<td width=\"35%\" align=\"center\">Name</td>";
echo "<td width=\"15%\" align=\"center\">Node ID</td>";
echo "<td width=\"30%\"
align=\"center\">TimeStamp</td></tr>";
$result = @mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo "<tr><td>";
echo $row['miner_id'];
echo "</td><td>";
echo $row['name'];
echo "</td><td>";
echo $row['node_id'];
echo "</td><td>";
echo $row['time'];
echo "</td></tr>";
}
?>
- 57 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
<br><br><br><br><br>
</div> <!-- end mid content-->
</div> <!-- end container-->
</body>
</html>
/* searchname.php
Returns the results of searching by a user’s name.
Search can be performed by full name, first name, last name, or partial
name.
*/
<?php
$db_name = "miner_db";
$connection = @mysql_connect("localhost", "senior_design",
"einstein7") or die(mysql_error());
print_header();
print_top_nav();
print_side_nav();
?>
<div class="midcontent">
<h2><center>Results for SEARCH BY MINER NAME:</center></h2>
<?php
if($_POST[miner_name] == "" || strlen($_POST[miner_name]) > 20)
{
header("Location: index.php");
exit;
}
else {
$m_name = $_POST[miner_name];
//$sql = "SELECT * FROM miners_id WHERE LOWER(name) LIKE
LOWER('%$m_name%') ORDER BY name";
$sql = "SELECT miners_id.miner_id, miners_id.name, node_id,
time FROM miners_id INNER JOIN nodes ON miners_id.miner_id =
nodes.miner_id WHERE LOWER(miners_id.name) LIKE LOWER('%$m_name%')
ORDER BY time DESC, miner_id";
echo "<table border=\"2\" bordercolor=\"#336699\"
cellpadding=\"1\" cellspacing=\"2\" width=\"100%\">";
echo "<tr><h1><center>Miners Currently In
System</center></h1></tr>";
echo "<tr><td width=\"15%\" align=\"center\">ID</td>";
echo "<td width=\"35%\" align=\"center\">Name</td>";
echo "<td width=\"15%\" align=\"center\">Node ID</td>";
- 58 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
/* searchid.php
Returns the results int table format of searching by a user’s ID
number.
*/
<?php
$db_name = "miner_db";
$connection = @mysql_connect("localhost", "senior_design",
"einstein7") or die(mysql_error());
print_header();
print_top_nav();
print_side_nav();
?>
<div class="midcontent">
<h1><center>Results for SEARCH BY MINER ID:</center></h1>
<?php
if($_POST[minerID] == "" || strlen($_POST[minerID]) > 10)
{
header("Location: index.php");
- 59 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
exit;
}
else {
$m_id = $_POST[minerID];
//$sql = "SELECT * FROM miners_id WHERE miner_id = $m_id
ORDER BY miner_id";
$sql = "SELECT miners_id.miner_id, miners_id.name, node_id,
time FROM miners_id INNER JOIN nodes ON miners_id.miner_id =
nodes.miner_id WHERE miners_id.miner_id = '$m_id' ORDER BY time DESC,
miner_id";
echo "<table border=\"2\" bordercolor=\"#336699\"
cellpadding=\"1\" cellspacing=\"2\" width=\"100%\">";
echo "<tr><h1><center>Miners Currently In
System</center></h1></tr>";
echo "<tr><td width=\"15%\" align=\"center\">ID</td>";
echo "<td width=\"35%\" align=\"center\">Name</td>";
echo "<td width=\"15%\" align=\"center\">Node ID</td>";
echo "<td width=\"30%\"
align=\"center\">TimeStamp</td></tr>";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>";
echo $row['miner_id'];
echo "</td>";
echo "<td>";
echo $row['name'];
echo "</td>";
echo "<td>$row[node_id]</td>";
echo "<td>$row[time]</td>";
echo "<tr>";
}
}
?>
<br><br><br><br><br>
</div> <!-- end mid content-->
</div> <!-- end container -->
</body> <!-- end body -->
</html> <!-- end html -->
/* searchnode.php
Returns the results in table format of searching by a node ID.
*/
<?php
$db_name = "miner_db";
$connection = @mysql_connect("localhost", "senior_design",
"einstein7") or die(mysql_error());
- 60 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
include 'includes/functions.php';
include 'includes/searchfuncs.php';
print_header();
print_top_nav();
print_side_nav();
?>
<div class="midcontent">
<h1><center>Results for SEARCH BY MINER ID:</center></h1>
<?php
if($_POST[nodeID] == "" || strlen($_POST[nodeID]) > 10)
{
header("Location: index.php");
exit;
}
else {
$n_id = $_POST[nodeID];
$sql = "SELECT miners_id.miner_id, miners_id.name, node_id,
time FROM miners_id INNER JOIN nodes ON miners_id.miner_id =
nodes.miner_id WHERE node_id = '$n_id' ORDER BY time DESC, miner_id";
echo "<table border=\"2\" bordercolor=\"#336699\"
cellpadding=\"1\" cellspacing=\"2\" width=\"100%\">";
echo "<tr><h1><center>Miners Currently In
System</center></h1></tr>";
echo "<tr><td width=\"15%\" align=\"center\">ID</td>";
echo "<td width=\"35%\" align=\"center\">Name</td>";
echo "<td width=\"15%\" align=\"center\">Node ID</td>";
echo "<td width=\"30%\"
align=\"center\">TimeStamp</td></tr>";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>";
echo $row['miner_id'];
echo "</td>";
echo "<td>";
echo $row['name'];
echo "</td>";
echo "<td>$row[node_id]</td>";
echo "<td>$row[time]</td>";
echo "<tr>";
}
}
?>
/* admin_login.php
- 61 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
*/
<?php
print_header();
print_top_nav();
print_side_nav();
?>
<div class="midcontent">
<h1><center>Administration Login</center></h1>
<tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>
<tr>
<td> <INPUT
TYPE="submit" NAME="submit" VALUE="Login"></td>
</tr>
</FORM>
</table><br>
<br><br><br><br><br>
/* auth_user.php
Authenticates administration login. Allows options of modifying users,
removing old data from database, add job skills, and add new node in
system.
- 62 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
*/
<?php
include 'includes/functions.php';
if((!$_POST[username]) || (!$_POST[password]))
{
header( "Location: admin_login.php");
exit;
}
$db_name = "miner_db";
$connection = @mysql_connect("localhost", "senior_design",
"einstein7") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or
die(mysql_error());
$sql = "SELECT * FROM admin_users WHERE username =
'$_POST[username]' AND password = '$_POST[password]'";
$result = @mysql_query($sql, $connection) or die(mysql_error());
$num = mysql_num_rows($result);
if($num != 0)
{
// SET COOKIE
$cookie_name = "auth";
$cookie_value = "ok";
$cookie_expire = "time() +1440";
$cookie_domain = "localhost";
//setcookie($cookie_name, $cookie_value, $cookie_expire,
"/", $cookie_domain, 0);
setcookie("auth", "miner", 0);
print_header();
print_top_nav_admin();
print_side_nav_admin();
$display_block = "
<div class=\"midcontent\">
<h1><center>Administration</center></h1>
- 63 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
<tr>
<td>
<FORM METHOD=\"post\"
ACTION=\"new_user.php\">
<INPUT TYPE=\"submit\"
NAME=\"submit\" VALUE=\"Modify Users\">
</FORM>
</td>
<td></td><td></td><td></td>
<td>
<FORM METHOD=\"post\"
ACTION=\"new_job.php\">
<INPUT TYPE=\"submit\"
NAME=\"submit\" VALUE=\"Add Job Position\">
</FORM>
</td>
<td></td><td></td><td></td>
<td>
<FORM METHOD=\"post\"
ACTION=\"add_node.php\">
<INPUT TYPE=\"submit\"
NAME=\"submit\" VALUE=\"Add System Node\">
</FORM>
</td>
<td></td><td></td><td></td>
<td>
<FORM METHOD=\"post\"
ACTION=\"remove_data.php\">
<INPUT TYPE=\"submit\"
NAME=\"submit\" VALUE=\"Remove Data\">
</FORM>
</td>
</tr>
</table>
<br><br><br>
?>
<?php
echo $display_block;
?>
</body>
</html>
- 64 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
/* modify_user.php
Allows administration to add/delete users from system.
*/
<?php
if(isset($_COOKIE["auth"]))
{
/* Include the php file with functions for submitting forms
*/
include 'includes/functions.php';
print_header();
print_top_nav_admin();
print_side_nav_admin();
}
else
{
header( "Location: admin_login.php");
exit;
}
?>
<div class="midcontent">
<h1><center>Modify System Users</center></h1>
<p>To enter a new user into the System, please locate the
ID associated with
the user's ID tag that he/she will be using. Enter the
user's name and associated
ID into the form.</p><br>
<p>To remove a current user from the System, enter the
user's full name.
The ID tag associated with the user can now be
reassigned to another user.</p><br>
- 65 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
/* delete_user.php
Administration can delete users from database that are no longer users
of the system.
*/
<?php
$user = $_POST[miner_name];
if(strlen($user) == 0)
{
header("Location: modify_user.php");
exit;
}
/* Include the php file with functions for submitting forms */
include 'includes/functions.php';
$db_name = "miner_db";
$table = "miners_id";
$connection = @mysql_connect("localhost", "senior_design",
"einstein7") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or
die(mysql_error());
$sql = "SELECT name FROM $table WHERE name = '$user'";
$result = @mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$search_result = $row['name'];
}
if(strlen($search_result) == '0')
{
$msg = "<p>The user you're trying to delete cannot be
found.
Please try another name.<p><br />";
}
else{
if(strlen($search_result) != '0')
{
$delete = "DELETE FROM $table WHERE name = '$user'";
$result = @mysql_query($delete, $connection) or
die(mysql_error());
$msg1 = "<p>Removing $user from database...<p><br
/>";
- 66 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
?>
<div class="midcontent">
<h1><center>Remove A User</center></h1>
<?php
if(isset($msg))
{
echo "<p> $msg </p>";
}
else {
echo "<p> $msg1 </p>";
echo "<p> $msg2 </p>";
}
?>
<br><br>
<p>Please click the button below to return to the previous
page.</p><br>
<table>
<tr><td width="20%"> </td>
<td><button
onClick="window.location='modify_user.php'">Go Back<br>To Previous
Page</button></td>
</tr>
<table>
<br><br><br><br>
</div> <!-- end mid content-->
</div> <!-- end container -->
</body> <!-- end body -->
</html> <!-- end html -->
/* add_node.php
Administration can add a new node to the system when a new physical
node is added to the mine.
*/
<?php
if(isset($_COOKIE["auth"]))
{
/* Include the php file with functions for submitting forms
*/
include 'includes/functions.php';
print_header();
print_top_nav_admin();
print_side_nav_admin();
}
else
{
header( "Location: admin_login.php");
- 67 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
exit;
}
?>
<div class="midcontent">
<h1><center>Enter New User Into System</center></h1>
<table>
<FORM METHOD="post" ACTION="validate_node.php">
<tr>
<td><strong>Node ID: </strong></td>
<td><INPUT TYPE="text" NAME="node_id" SIZE="20"></td>
</tr>
<tr><td> <td></tr>
<tr><td> <td></tr>
<tr><td> <td></tr>
<tr>
<td></td>
<td> <INPUT TYPE="submit" NAME="submit"
VALUE="Add New Node"></td>
</tr>
</FORM>
</table><br>
<br><br><br><br><br>
<div class="footer">
<p>Copyright 2007 WVU Senior Design - Mine Tracking System</p>
</div>
/* remove_data.php
Administration can remove data from the database that is more than
three (3) days old.
*/
<?php
$db_name = "miner_db";
$table = "nodes";
$connection = @mysql_connect("localhost", "senior_design",
"einstein7") or die(mysql_error());
- 68 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
print_header();
print_top_nav_admin();
print_side_nav_admin();
?>
<div class="midcontent">
<h1><center>Remove Old Data</center></h1>
<?php
echo "<p> $msg1 </p>";
?>
<br><br>
<p>Please click the button below to return to the previous
page.</p><br>
<table>
<tr><td width="20%"> </td>
<td><button
onClick="window.location='auth_user.php'">Go Back<br>To Previous
Page</button></td>
</tr>
<table>
<br><br><br><br>
</div> <!-- end mid content-->
</div> <!-- end container -->
</body> <!-- end body -->
</html> <!-- end html -->
/* new_user.php
Administration can add a new user to the system.
*/
<?php
if((!$_POST[miner_name]) || (!$_POST[miner_id]))
{
header("Location: modify_user.php");
exit;
}
$db_name = "miner_db";
$table = "miners_id";
$name = $_POST[miner_name];
$id = $_POST[miner_id];
- 69 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
/* Search for id */
$sql3 = "SELECT miner_id FROM $table WHERE miner_id = '$id'";
$result3 = @mysql_query($sql3);
$num3 = mysql_num_rows($result3);
if($num3 != 0)
{
$error3 = "<p>Cannot add user. The ID already exists in
System.</p>
<p>Try searching on the main page to verify.</p>";
}
- 70 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
print_header();
print_top_nav_admin();
print_side_nav_admin();
?>
<div class="midcontent">
<h1><center>Add New User To System</center></h1>
<p>
<?php
if(isset($error))
echo $error;
else{
if(isset($error2))
echo $error2;
else{
if(isset($error3))
echo $error3;
else{
echo $msg1;
echo $msg2;
}
}
}
?>
</p><br><br>
<button onClick="window.location='modify_user.php'">Return
to<br>Previous Page<br></button>
<br><br><br><br><br><br><br><br><br><br><br>
</div> <!-- end mid content-->
</div> <!-- end container -->
/* new_job.php
Administration can add a new job skill to the database to be associated
with a user(s).
*/
<?php
if(isset($_COOKIE["auth"]))
{
$db_name = "miner_db";
$connection = @mysql_connect("localhost", "senior_design",
"einstein7") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or
die(mysql_error());
/* Include the php file with functions for submitting forms */
include 'includes/functions.php';
print_header();
print_top_nav_admin();
print_side_nav_admin();
}
else
- 71 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
{
header( "Location: admin_login.php");
exit;
}
?>
<div class="midcontent">
<h1><center>Add New Job Position</center></h1>
/* validate_job.php
- 72 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
Queries the database when administration tries to add a new job skil to
the database. Ensures the position does not already exists. If
position does not exist, it is added to the database.
*/
<?php
$new_job = $_POST[job_title];
if(strlen($new_job) == 0)
{
header("Location: new_job.php");
exit;
}
$db_name = "miner_db";
$table = "jobs_id";
$result = @mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$search_result = $row['job_title'];
}
if(strlen($search_result) != '0')
{
$msg = "<p>The job position you're trying to add already
exists<p><br />";
}
else{
if(strlen($search_result) == '0')
{
$insert = "INSERT INTO jobs_id (job_title) VALUES
('$new_job')";
$result = @mysql_query($insert, $connection) or
die(mysql_error());
- 73 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
print_header();
print_top_nav_admin();
print_side_nav_admin();
?>
<div class="midcontent">
<h1><center>New Job Position</center></h1>
<?php
if(isset($msg))
{
echo "<p> $msg </p>";
}
else {
echo "<p> $msg1 </p>";
echo "<p> $msg2 </p>";
}
?>
<br><br>
<p>Please click the button below to return to the previous
page. Verify that the new position is reflected in the table.</p><br>
<table>
<tr><td width="20%"> </td>
<td><button
onClick="window.location='new_job.php'">Go Back<br>To Previous
Page</button></td>
</tr>
<table>
<br><br><br><br>
</div> <!-- end mid content-->
</div> <!-- end container -->
</body> <!-- end body -->
</html> <!-- end html -->
/* validate_node.php
Verifies the new node added by administration does not already exist.
If the new node ID does not already exist, it is added to the database
and ready to be used within the system.
*/
<?php
$new_node = $_POST[node_id];
if(strlen($new_node) == 0)
- 74 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
{
header("Location: add_node.php");
exit;
}
$db_name = "miner_db";
$table = "node_ids";
$connection = @mysql_connect("localhost", "senior_design",
"einstein7") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or
die(mysql_error());
/* If node ID does not already exist, then create new node ID
Check by selecting from database table. If node is not in
DB,
then create it.
*/
print_header();
print_top_nav_admin();
print_side_nav_admin();
?>
<div class="midcontent">
<h1><center>Node Addition</center></h1>
<?php
if(isset($msg))
{
echo "<p> $msg </p>";
}
- 75 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
else {
echo "<p> $msg1 </p>";
echo "<p> $msg2 </p>";
}
?>
<br><br>
<button onClick="window.location='add_node.php'">Previous
Page</button>
<br><br><br><br><br><br><br><br><br><br><br>
</div> <!-- end mid content-->
</div> <!-- end container -->
<div class="footer">
<p>Copyright 2007 WVU Senior Design - Mine Tracking System</p>
</div>
</body> <!-- end body -->
</html> <!-- end html -->
/* help.php
A general help and instruction page for using the site as both a user
and an administrator. All functions are detailed and described.
*/
<?php
print_header();
print_top_nav();
print_side_nav();
?>
<div class="midcontent">
<h1><center>Help Using The System</center></h1>
<h3>User Interface</h3>
<p>A variety of search functionality is built-in to the
system. The following section describes each type of search
functionality.</p><br>
<h4>Search by Name</h4>
<p>To search for users by name, you can enter the user's
full name, first name, last name, or just part of the user's name. For
example, if you are wanting to find John Smith, you can enter "John
Smith", "John", "Smith", "Jo", "Sm". Searching using part of the
person's name can produce multiple results.</p><br>
- 76 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
<h3>Administration Interface</h3>
<p>The administration panel is limited to those who have
administrative priviledges. Administration users have access to modify
users, add nodes, and add job skills to the system. Access is
restricted. Please contact the system administrator if you encounter
any problems logging in to the system.</p><br>
- 77 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
<div class="footer">
<p>Copyright 2007 WVU Senior Design - Mine Tracking System</p>
</div>
</body> <!-- end body -->
</html> <!-- end html -->
/* about.php
General information page about the system, functionality, brief
overview.
*/
<?php
<div class="midcontent">
<h1><center>About The System</center></h1>
<h3>System Overview</h3>
<p>The Miner Tracking System provides accurate and up-to-date
information on
the miners currently in the system. The user interface allows
searching by name, miner ID,
node ID, or job skill. See the <a href="help.php">Help and
Instructions</a> page for more
specific information on searching.</p><br>
<h3>Tracking</h3>
<p>The system utilizes wireless nodes placed throughout the mine that
poll at specific
time intervals. Miners and other personnel are issued a wearable tag
that broadcasts
his/her associated ID. When the wireless nodes poll, any user's tag
within range is received
- 78 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
<h3>User Interface</h3>
<p>
The User interface is openly available to all users of the system to
search
the mine for current users. Because the interface has been
implemented
as a web site, users have access from virtually any location. Users
have the
ability to search using multiple criteria, such as miner ID, node ID,
name, and occupation.
See the <a href="help.php">Help and Instructions</a> page for more
specific information
on searching.</p><br>
<h3>Administration Interface</h3>
<p>The administration interface is designed to be used by
management and/or other
priviledged users. The administration portion of the site
requires user
authentication to prevent data loss or misuse of the system.
Administration has
the following options available:</p><br>
<ul>
<li>· Add Users to the System</li>
<li>· Remove Users from the System</li>
<li>· Add New Nodes to the System</li>
<li>· Add job skills to System</li>
<li>· Remove old data from database</li>
</ul>
<br>
</div> <!-- end mid content-->
</div> <!-- end container -->
<div class="footer">
<p>Copyright 2007 WVU Senior Design - Mine Tracking System</p>
</div>
</body> <!-- end body -->
</html> <!-- end html -->
/* function.php
PHP functions that are used to display headers, footers, and navigation
of the site.
*/
<?php
function print_header()
{
$head = <<<EOD
- 79 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
echo "$head";
}
function print_top_nav()
{
$top_nav= <<<EOD
<body>
<div class="header">
<div class="title">Miner Tracking System</div>
</div>
<div class="topnav">
<div class="left">
<a href="index.php">Home </a> | <a
href="admin_login.php">Administration</a> | <a href="about.php">About
the System </a> | <a href="help.php">Help & Instructions</a>
</div>
EOD;
echo "$top_nav";
echo "<div class=\"right\">";
print date('D, M d Y');
echo " <br />";
print date('H:i:s');
echo " </div></div> <!-- end topnav -->";
}
/*
Navigation for administrators
*/
function print_top_nav_admin()
{
$top_nav= <<<EOD
<body>
<div class="header">
<div class="title">Miner Tracking System</div>
</div>
<div class="topnav">
<div class="left">
<a href="index.php">Main Page </a> | <a
href="admin_login.php">Administration</a> | <a href="about.php">About
the System </a> | <a href="help.php">Help & Instructions</a>
</div>
EOD;
echo "$top_nav";
- 80 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
function print_side_nav()
{
$side_nav = <<<EOD
<div class="container">
<div class="sidenav">
<h2>Helpful Links</h2>
<ul>
<li><a href="index.php">Main Page</a></li>
<li><a href="admin_login.php">Administration</a></li>
<li><a href="help.php">Help & Instructions</a></li>
<li><a href="about.php">About The System</a></li>
</ul>
</div> <!-- end sidenav -->
EOD;
echo "$side_nav";
}
function print_side_nav_admin()
{
$side_nav = <<<EOD
<div class="container">
<div class="sidenav">
<h2>Helpful Links</h2>
<ul>
<li><a href="index.php">Main Page</a></li>
<li><a href="new_user.php">Modify Users</a></li>
<li><a href="new_job.php">Add New Job Description</a></li>
<li><a href="add_node.php">Add Node To System</a></li>
<li><a href="help.php">Help & Instructions</a></li>
<li><a href="about.php">About The System</a></li>
</ul>
</div> <!-- end sidenav -->
EOD;
echo "$side_nav";
}
function print_footer()
{
$footer = <<<EOD
<div class="footer">
<p>Copyright 2007 WVU Senior Design - Mine Tracking System</p>
</div>
- 81 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
echo "$footer";
}
?>
/* screen.css
Cascading Style Sheet used that determines the look and feel of the
site. Determines the formatting of all web pages of client interface.
*/
/* standard elements */
html {min-height: 100%;}
* {
margin: 0;
padding: 0;
}
table {
margin: 0 5px 10px 10px;
}
tr,td {
font: normal 1.2em Verdana,sans-serif;
}
body {
background: #FFF;
color: #000;
font: normal 62.8% Tahoma,sans-serif;
padding-top: 30px;
}
li {list-style: none;}
.subtitle {
color: #F00;
font: normal 60.5% Verdana,sans-serif;
}
.header {
background: #2554C7;
height: 160px;
width: 900px;
margin-left: auto;;
margin-right: auto;
margin-bottom: 15px;
text-align: center;
- 82 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
.header .title {
padding-top: 50px;
color: #BBB;
font: normal 3em sans-serif;
}
.container {
background: #DDD;
margin: 0 auto 0 auto;
width: 930px;
border: 2px solid #2554C7;
}
.sidenav {
float: left;
width: 200px;
margin: 10px 10px 0 5px;
border: 2px solid #999;
.sidenav h2 {
background: #FFF;
color: #2554C7;
line-height: 25px;
margin: 0;
border-bottom: 1px solid #BBB;
padding-left: 10px;
}
.sidenav ul {
padding: 0;
}
.sidenav li {border-bottom: 1px solid #BBB;}
.sidenav li a {
font-size: 1.2em;
color: #FFF;
background: #2554C7;
display: block;
padding: 8px 0 8px 5%;
text-decoration: none;
width: 95%;
}
.sidenav li a:hover {
background: #FFF;
color: #2554C7;
}
.topnav {
background: #949490;
color: #FFF;
font: normal 1.2em Verdana,sans-serif;
height: 25px;
margin-left: auto;;
margin-right: auto;
- 83 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007
margin-bottom: 10px;
padding: 10px 0;
width: 90%;
border: 1px solid #736AFF;
}
.topnav a {
color: #FFF;
text-decoration: none;
padding: 0px 8px 12px 10px;
}
.topnav a:hover {
color: #2554C7;
text-decoration: none;
}
.midcontent {
width: 660px;
margin: 10px auto 15px 215px;
padding: 10px;
border-left: 2px solid: #333;
}
.midcontent h1,h2 {
padding-bottom: 5px;
}
.rightform {
float: right;
width: 135px;
margin: 30px 5px 0 0;
}
.footer {
background: #666;
color: #FFF;
margin: 20px 0 30px 0;
border: 1px solid #000;
padding: 10px 10px 10px 10px;
}
- 84 -