Sei sulla pagina 1di 84

Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

WEST VIRGINIA UNIVERSITY

COLLEGE OF ENGINEERING AND MINERAL RESOURCES

Lane Department of Computer Science and Electrical Engineering

SENIOR DESIGN SEMINAR

Fall 2007 Semester

DETAILED DESIGN REVIEW

December 2, 2007

TEAM 2: MINE TRACKING SYSTEM

Michael Bittle
Patrick Brandt
Andrew Facemire
Michelle Hunt
Michael Sweetman

FACULTY MONITOR: Roy Nutter, Ph.D., P.E.

FACULTY REVIEWER: David Graham, Ph.D.

SPONSOR: Roy Nutter, Ph.D., P.E.

ADVISOR: Roy Nutter, Ph.D., P.E.

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

Line #: Part: Quantity: Unit Price: Total Price:


1 Development kit 1 $250.00 $250.00
2 Microcontroller package 2 $7.50 $15.00
3 Miscellaneous $40.00

Cost per Unit: $305.00

SERVER/DATABASE

Line #: Part: Quantity: Unit Price: Total Price:


4 Computer 1 Donated $0.00
5 Software 1 $0.00 $0.00

Cost per Unit: $0.00

CLIENT

Line #: Part: Quantity: Unit Price: Total Price:


6 Computer 1 Donated $0.00

Cost per Unit: $0.00

Requested from Sponsor = $0.00 Requested from CSEE Department = $305.00

____________________________ _________________________________
Sponsor Signature Date Chair Signature Date

_______________________________
Monitor Signature Date

-4-
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

2.2 Proposed Budget Justification


Line #: Details:

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

2.3 Actual Budget


NODES

Line #: Part: Quantity: Unit Price: Total Price:


1 Single Board Computer 5 Donated $ 0.00
2 X-Bee Modem 5 Donated $ 0.00
3 Computer 2 Donated $ 0.00
4 Software 1 Donated $ 0.00
5 Heat Sink 4 $1.49 $ 5.96
6 5V Regulator 4 $1.59 $ 6.36
7 Mounting Hardware 4 $1.99 $ 7.96
8 5.5/2.1 Coaxial Plug 2 $2.99 $ 5.98
9 DC Power Jack 4 $1.99 $ 7.96
10 Switch 4 $2.99 $ 11.96
11 22 Gauge Wire 1 $4.99 $ 4.99
12 Plexiglass Sheet 1 $12.78 $ 12.84
13 Corner Joint 3 $3.28 $ 9.84
14 Terminal Strip 4 $2.39 $ 9.56
15 Spade Tongue 1 $1.99 $ 1.99
16 Heat Shrink 1 $2.99 $ 2.99
17 Miscellaneous $ 5.41

Total Cost: $ 93.80

CLIENT/SERVER/DATABASE

Line #: Part: Quantity: Unit Price: Total Price:


18 Computer 1 Donated $ 0.00
19 Software 1 $0.00 $ 0.00
20 Software 1 $0.00 $ 0.00
21 Software 1 $0.00 $ 0.00

Total Cost: $ 0.00

Requested from Sponsor = $0.00 Requested from CSEE Department = $100.00

____________________________ _________________________________
Sponsor Signature Date Chair Signature Date

_______________________________
Monitor Signature Date

-6-
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

2.2 Actual Budget Justification


Line #: Details:

1 Single Board Computer

2 X-Bee Modem

3 Workstation Computer

4 X-TCU Software

5 Heat Sink for Node Enclosure

6 5V Regulator for Node Enclosure

7 Heat Sink Mounting Hardware

8 Coaxial Plug for Node Enclosure

9 DC Power Jack for Node Enclosure

10 On/Off Power Switch for Node Enclosure

11 22 Gauge Connection Wire

12 Plexiglass Node Enclosure

13 Brass Corner Joint

14 Terminal Strip

15 Spade Tongue

16 Wire Heat Shrink

17 Miscellaneous

18 Client/Server Computer

19 Apache Web Server

20 PHP 5 Server Language

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

3.2 Final Work Division

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

4.1 Design Level 0


The objective of the Mine Tracking System is to design and build an underground
tracking and communication system that will allow effective communication between
miners, mine operators, and rescue/emergency teams. The system will provide the means
to quickly locate miners and assess conditions to help prioritize rescue efforts in case of
an emergency. Miner ID tags will be the primary source of input and the corresponding
location, name, and time will be the primary output.

Figure 1: Level 0 diagram for the Mine Tracking System

- 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

4.2 Design Level 1


The Mine Tracking System will contain a node network that will relay tracking
information to the server. The server will in turn store this information in a database and
deliver it to the client so the tracking information can be accessed.

Miner Name, Location


Time, Job Information Client

Power
Node Miner ID
Server
Network Node ID
Miner ID

Miner Name, Location


Database
Time, Job Information

Figure 2: Level 1 flowchart for the Mine Tracking System

- 13 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

4.2.1 Node Network

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

Figure 3: Node diagram for the Mine Tracking System

- 15 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

Table 2: Level 1 functional design description for the node network


Module Node Network
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 Node ID: A unique identifier for the node that represents a unique
position in the mine.
Miner ID: The miner’s wearable device identifier.
Functionality Read the unique identifier of the miner’s wearable device.
Send the package to the database.
Receive data packages from other nodes and retransmit them to the
database.

- 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.

Table 3: Level 1 functional design description for the server


Module Server
Inputs Miner ID: The miner’s wearable device identifier.
Node ID: A unique identifier for the node that represents a position in
the mine.
Outputs Miner ID: The miner’s wearable device identifier.
Name: The miner’s name, associated with a Miner ID.
Node ID: A unique identifier for the node that represents a position in
the mine.
Job Skill: Technical skill(s) possessed by the miner.
Functionality Receive the miner data packets from the coordinator node.
Transmit the Miner ID and Node ID to database.
Retrieve data from database to display the results to client.

- 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.

Table 4: Level 1 functional design description for the database


Module Database
Inputs Miner ID: The miner’s wearable device identifier.
Name: The miner’s name, associated with a Miner ID.
Node ID: A unique identifier for the node that represents a position in
the mine.
Timestamp: The time that a packet with Miner ID and Node ID was
received, based on the NTP clock.
Job Skill: Technical skill(s) possessed by the miner.
Outputs Miner Location: The Node ID and time stamp of when a Miner ID was
in the range on the Node ID.
Name: The miner’s name, associated with a Miner ID.
Job Skill: Technical skill(s) possessed by the miner.
Functionality Receive Miner ID, name, and job skill for initial database setup.
Receive updated Miner ID and Node ID from server for storage
purposes.
Send miner location data to server based on given parameters.

- 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

Table 5: Level 1 functional design description for the client


Module Client
Inputs New Miner Information: Information entered by the user to be added as
a new entry in the database.
Miner Location: The Node ID and time stamp of when a Miner ID was
in the range on the Node ID.
Name: The miner’s name, associated with a Miner ID.
Job Skill: Technical skill(s) possessed by the miner.
Outputs New Miner Information: Information entered by the user to be added as
a new entry in the database.
Functionality Receive name, location, and time information.
Display the current version of the name, location, and time.
Send new miner information to server to be inserted into database.

- 20 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

4.3 Design Level 2

Figure 4: Level 2 diagram for the Node Network

- 21 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

4.3.1 Wearable End Device

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

Figure 5: Level 2 flowchart for the Wearable End Device

- 23 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

4.3.2 Routing Node

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

own. The send_data function builds a buffer of acknowledgement options, frame

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”.

See Appendix 2 and Appendix 4 for the source code.

- 24 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

Table 7: Level 2 functional design description for the Routing Node


Module Routing Node
Inputs Miner ID: A unique identifier for a miner’s wearable tracking device.
Node ID: A unique identifier for the first routing node encountered.
This is only an input after the first routing node has been encountered.
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.
Node ID: A unique identifier for the first routing node encountered.
Functionality The first routing node encountered will define the Node ID associated
with the Miner ID. Otherwise, it will transmit the Miner ID and Node
ID to the next routing node closer to the Coordinator node.

- 25 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

Figure 6: Level 2 flowchart for the Routing Node

- 26 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

4.3.3 Coordinator Node

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

next transmission from a routing node.

Table 8: Level 2 functional design description for the Coordinator Node


Module Coordinator Node
Inputs Miner ID: A unique identifier for a miner’s wearable tracking device.
Node ID: A unique identifier for the first routing node encountered.
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 Data File: A text or data file that contains updated Miner IDs that are
linked with appropriate Node IDs.
Functionality Receive the Miner ID and Node ID.
Store the Miner ID and Node ID in a data file and buffer that will be
sent to the server.

- 27 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

Figure 7: Level 2 flowchart for the Coordinator Node

- 28 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

4.3.4 Server

Figure 8: Server flowchart for Mine Tracking System

The server acts as an intermediary between the other subsystems. It reformats


data in order to communicate between the client, database, and node network. Data
coming in from the coordinator is turned into an SQL insert statement to update the
information of the miners. The server receives parameters in the form of an HTTP POST
variable when the client makes a request. It also converts queries from the client into
SQL queries using the POST variables and sends data to the client interface to be read by
the user.

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

5. Secondary Design Aspects

5.1 Analysis Methods and Experiments


The Mine Tracking System used various tests to check for system functionality.
Loopback testes were conducted on Maxstream modems to ensure that each device
functioned properly. Next, we tested the modems again to see how distance and
obstacles between communicating nodes affected the frequency of packet loss and
corrupt data. This information was essential to determining the placement of the routing
nodes in the network. The entire system was tested in a laboratory setting to ensure the
transmission of the proper miner information from the nodes to the server, database, and
graphical user interface. This test was important to rule out programming errors before
the system is deployed in a more realistic environment.

5.2 Ethical and Social Impact


Past mining disasters have shed light on the need to have accurate tracking and
communication for underground mining crews as well as rescue teams [1]. Currently no
reliable technology exists to locate and communicate with trapped miners in cases of
emergency [2]. There would be great ethical and social impact if the Mine Tracking
System would ever be distributed commercially. The MINER Act of 2006 requires “an
electronic tracking system within three years, permitting those on the surface to locate
persons trapped underground” [3]. Mining companies will be required to implement
tracking systems, and they will need the products to do so. The Mine Tracking System
would help these companies meet their ever increasing safety regulations. Consequently,
mine operators’ and rescue team’s ability to locate trapped or injured miners after an
event is greatly increased. The Mine Tracking System will help save lives and better the
image of coal mining wherever it is deployed.

- 30 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

5.3 Engineering Standards


The team had to consider standards of Java coding conventions, C coding
conventions, and ZigBee wireless networking standards.

5.4 Economic Analysis


Most of the materials required to implement the hardware for the Miner Tracking
System were donated for the course of the semester. This includes the Maxstream XBee
Pro modems, the Technologic single board computers, and the computers used to
implement the server, database, and graphical user interface. If the Mine Tracking
System were to be manufactured commercially, the devices would be within the two-
hundred dollar price range stated in the requirements.

5.5 Considered Issues


Issues that were considered in the design and implementation of the Mine
Tracking System were reliability, ease of use, size, durability, and cost. Our system must
be extremely reliable because an accident can happen at any time and the miner data must
be available, accurate, and up to date. Our product must be easy to use and accessible to
any emergency rescue personnel. The device’s size and durability must also be
considered because they will ultimately be placed inside harsh underground environments
and some will be carried around my miners. Finally, cost must be considered to ensure
that the final product would be within a suitable price range for mining companies.

5.6 Team Learning


The Mine Tracking System team was fully capable to design and implement the
final project. However, our research allowed us to gain more depth in several areas
including: MySQL, PHP, Zigbee wireless standards and protocols, and C programming.

- 31 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

5.7 Improvement in Technical Writing


The Mine Tracking System team has completed a great amount of technical
writing, and in doing so has achieved a high level of proficiency in preparing technical
documents, structured weekly reports, and presentations.

- 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

Appendix 1 – End Device Code.


#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>

#define MAX_PACKET_SIZE 100


#define COM_FILE "/dev/ttyAM"
#define MAX_API_HEADER 9 /* With checksum */
#define MASK_UPPER 0x00FF /* Found online as %0x0F.... */
#define MAX_API_PACKET (MAX_PACKET_SIZE + MAX_API_HEADER) /*
109 Bytes */
#define START_DELIMITER 0x7E /* Start Delimiter to start API
sequence */
#define NO_API 0x40 /* Used for initial command
mode */

/* API Identifiers - Sent */


#define COMMAND 0x08 /* Send command (change
parameter value) */
#define TRANSMIT 0x01 /* Transmit message */
#define API_DISABLE_ACK 0x01

/* Serial Port Constants */


const int tiocm_dtr = TIOCM_DTR;
const int tiocm_rts = TIOCM_RTS;

/* 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;

modem_fd = open_port(2, 115200);

- 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);
}

//Needed for XBee?


disable_binary();
status = isatty(modem_fd);
if (status == 1) {
char *name, tempBuffer[MAX_PACKET_SIZE];
//Modem associated with a modem device
name = tempBuffer;
name = ttyname(modem_fd);
printf("\nPort name: %s.\n", name);
}
else {
//Modem not associated with a modem device
printf("\nPort %c is not associated with terminal device!",
i);
close(modem_fd);
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);

//write(modem_fd, str1, strlen(str1));

//Get Data from modem


//strncpy(str2, "", 20);
//while(nbytes <= 0) {
//nbytes = read(modem_fd, str2, 20);
//nbytes = read_data(modem_fd, str2, MAX_API_PACKET,
&timeout);
//}
//fprintf(file1, "%s\n", str2);
close(modem_fd);
//fclose(file1);
return 0;
}

- 35 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

Appendix 2 – Router Code.


#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>

#define MAX_PACKET_SIZE 100


#define COM_FILE "/dev/ttyAM"
#define MAX_API_HEADER 9 /* With checksum */
#define MASK_UPPER 0x00FF /* Found online as %0x0F.... */
#define MAX_API_PACKET (MAX_PACKET_SIZE + MAX_API_HEADER) /*
109 Bytes */
#define START_DELIMITER 0x7E /* Start Delimiter to start API
sequence */
#define NO_API 0x40 /* Used for initial command
mode */
#define OK 1
#define TEMP_BUF_SIZE 150
#define NULCH '\0'
#define BROADCAST 0xFFFF

/* API Identifiers - Sent */


#define COMMAND 0x08 /* Send command (change
parameter value) */
#define TRANSMIT 0x01 /* Transmit message */

#define API_DISABLE_ACK 0x01

/*Modem Read Identifiers*/


#define DATA_READY (-1)
#define DATA_IDLE (-2)

/* Serial Port Constants */


const int tiocm_dtr = TIOCM_DTR;
const int tiocm_rts = TIOCM_RTS;
char COM_ENTER[3] = "+++";
int modem_fd;
long int guard_time = 1; /* Initial setting of 1 second guard
time. */
long int extra_guard_time = 100000; /* 100 ms */

/* 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];

FILE *file1 = fopen("stuff.txt", "w");


struct timeval timeout;

timeout.tv_usec = 50;
timeout.tv_sec = 0;

modem_fd = open_port(2, 115200);


if (modem_fd == -1) {
//Error in opening COM port
printf("\nError opening COM port!!\n");
exit(0);
}

/* Needed for XBee? */


disable_binary();

status = isatty(modem_fd);
if (status == 1) {
char *name, tempBuffer[MAX_PACKET_SIZE];

/* Modem associated with a modem device */


name = tempBuffer;
name = ttyname(modem_fd);
printf("\nPort name: %s.\n", name);
}
else {
/* Modem not associated with a modem device */
printf("\nPort %c is not associated with terminal device!",
i);
close(modem_fd);
exit(0);
}

/* Manually set DL and MY */


MY = 1;
DL = MY-1;

- 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]);
}

//First node check


if ( !strcmp(nodeID, "00") ){
printf("\nFIRST NODE\n");
sprintf(str2, "%.2s%.2X" , minerID, MY);
printf("%s", str2);
}
else {
sprintf(str2, "%.2s%.2s", minerID, nodeID);
}

/* Send data to next node */


send_data(modem_fd, str2, strlen(str2), TRANSMIT, 0, DL);
}

/* 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

Appendix 3 – Coordinator Code.


#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/time.h>

//Socket libraries
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <netdb.h>

#define MAX_PACKET_SIZE 100


#define COM_FILE "/dev/ttyAM"
#define MAX_API_HEADER 9 /* With checksum */
#define MASK_UPPER 0x00FF /* Found online as %0x0F.... */
#define MAX_API_PACKET (MAX_PACKET_SIZE + MAX_API_HEADER) /*
109 Bytes */
#define START_DELIMITER 0x7E /* Start Delimiter to start API
sequence */
#define NO_API 0x40 /* Used for initial command
mode */
#define OK 1
#define TEMP_BUF_SIZE 150
#define NULCH '\0'
#define BROADCAST 0xFFFF

/* API Identifiers - Sent */


#define COMMAND 0x08 /* Send command (change
parameter value) */
#define TRANSMIT 0x01 /* Transmit message */

#define API_DISABLE_ACK 0x01

/*Modem Read Identifiers*/


#define DATA_READY (-1)
#define DATA_IDLE (-2)

/* Max buffer for sending to server */


#define MAX_BUFF_LEN 200

/* Serial Port Constants */


const int tiocm_dtr = TIOCM_DTR;
const int tiocm_rts = TIOCM_RTS;
char COM_ENTER[3] = "+++";
int modem_fd;

- 39 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

long int guard_time = 1; /* Initial setting of 1 second guard


time. */
long int extra_guard_time = 100000; /* 100 ms */

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();
int write_params();
void send_to_modem(char *buf, char *command);
int ascii2hex(char *MY);
void fd_dump(int fd);

int main(int argc, char *argv[]) {


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];

//Variables for sockets


char buffer[MAX_BUFF_LEN];
struct sockaddr_in sin;
int sock, len;
int portnum = 65001;
struct hostent *host;
//End variables for sockets

FILE *file1 = fopen("stuff.txt", "w");


struct timeval timeout;

MYSQL *connection, mysql;


MYSQL_RES *result;
MYSQL_ROW row;
int state;

//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;

//Check for arguments


if(argc < 2) {
printf("Usage: [progname] [server IP]\n");
exit(0);
}

//Send data to server using sockets


//Get a socket: PF means Protocol Family
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sock == -1) {
perror("socket");
exit(1);
}
//Clear the structure so that we don't have garbage around
memset((void *)&sin, 0, sizeof(sin));

//AF means Address Family - same as Protocol Family for now


sin.sin_family = AF_INET;

//Fill in port number in address (careful of byte-ordering)


sin.sin_port = htons(portnum);

//Parse either the text hostname or the IP


/*if(inet_aton(argv[1], &sin.sin_addr) == 0) {
host = gethostbyname(argv[1]);
if (host == NULL) {
herror("gethostbyname");
exit(1);
}
sin.sin_addr = *((struct in_addr *)host->h_addr);
}

printf("Connecting to %s:%d ....\n", inet_ntoa(sin.sin_addr),


ntohs(sin.sin_port));

//Connect to server (notice the cast and size argument)


/*if (connect(sock, (struct sockaddr *)&sin, sizeof(sin)) == -1)
{
perror("connect");
exit(1);
}*/

modem_fd = open_port(2, 115200);


if (modem_fd == -1)
{
//Error in opening COM port
printf("\nError opening COM port!!\n");
return 1;
}

- 41 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

//Needed for XBee?


disable_binary();

status = isatty(modem_fd);
if (status == 1)
{
char *name, tempBuffer[MAX_PACKET_SIZE];

//Modem associated with a modem device


name = tempBuffer;
name = ttyname(modem_fd);
printf("\nPort name: %s.\n", name);
}
else {
//Modem not associated with a modem device
printf("\nPort %c is not associated with terminal
device!", i);
close(modem_fd);
return 1;
}

MY=0;

//Get Data from modem


strncpy(str1, "", MAX_PACKET_SIZE); //clear str2
status = 0; //clear status
while(1){
while(status != DATA_READY){
status = check_fd(modem_fd, 0);
}
if (status == DATA_READY){
char temp[MAX_PACKET_SIZE];
int n_ID, m_ID;
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]);
status = 1;
m_ID = ascii2hex(minerID);
n_ID = ascii2hex(nodeID);

sprintf(temp, "INSERT INTO nodes (miner_id, node_id) VALUES


('%x', '%x')", m_ID, n_ID);
if(mysql_query(connection, temp) != 0)
printf("INSERT statement failed\n");
else
printf("INSERT statement succeeded: %lu rows
affected\n", (unsigned long) mysql_affected_rows(connection));
}

//First node check

if ( !strcmp(nodeID, "00") ) {
printf("\nFIRST NODE\n");

- 42 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

sprintf(str2, "%.2s%.2X" , minerID, MY);


printf("%s", str2);
}
else {
sprintf(str2, "%.2s%.2s", minerID, nodeID);
}
//send(sock, str2, strlen(str2), 0);
}
//write file
fprintf(file1, "%s\n", str2);
close(modem_fd);
fclose(file1);
mysql_close(connection);

return 0;
}

- 43 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

Appendix 4 – Coordinator, Router, and End Device Function


Calls.
/* open_port - Opens port to modem
Returns the file descriptor on success or -1 on error.
*/
int open_port(int port, int baud) {
int fd; /* File descriptor for the port */
int rate; /* Desired baud rate */
char comport[15]; /* Name of com port */

struct termios options;

/* Open the port. */


sprintf(comport,"%s%i",COM_FILE, port-1);

/*fd = open(comport, O_RDWR | O_NOCTTY | O_NDELAY);*/


fd = open(comport, O_RDWR | O_NOCTTY | O_NONBLOCK | O_FSYNC);
if (fd == -1){
/* Could not open the port. */
perror("open_port: Unable to open port - ");
}
else {
/*fcntl(fd, F_SETFL, 0);*/
}

/* Get the current options for the port... */


tcgetattr(fd, &options);

/* Set the baud rates to desired baud rate (baud)... */


switch (baud) {
case 1200:
rate = B1200;
break;

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);

options.c_cflag |= (CLOCAL | CREAD);


options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;

options.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR |


IGNCR | ICRNL | IXON);
options.c_oflag &= ~OPOST;
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG | IEXTEN |
ECHONL);

//Enable the options


tcflush(fd, TCIOFLUSH);
tcsetattr(fd, TCSANOW, &options);

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;
}

/* Check type of data */


switch(type)
{
case NO_API:
{
temp = 0;

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 API Identifier */


tempBuffer[3] = (char) type;
checksum = type;

/* Send Frame ID */
tempBuffer[4] = (char) frame_ID;
checksum += frame_ID;

/* Send Destination Address */


temp = dest_address;

- 46 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

tempBuffer[5] = (char) ( (temp >> 8) & MASK_UPPER );


/* MSB */
tempBuffer[6] = (char) ( temp & MASK_UPPER );
/* LSB */
checksum += ( (int) tempBuffer[5] + (int)
tempBuffer[6] );

/* Send Option */

/* Assuming always set to DISABLE_ACK */


tempBuffer[7] = (char) API_DISABLE_ACK;
checksum += API_DISABLE_ACK;

/* Send Data */

for (which = 0; which < size; which++)


{
checksum += buf[which];
tempBuffer[which + 8] = buf[which];
}

checksum = MASK_UPPER - (checksum & MASK_UPPER);


tempBuffer[size+8] = checksum;

/* 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

tempBuffer[1] = (char) ( (temp >> 8) & MASK_UPPER );


/* MSB */
tempBuffer[2] = (char) ( temp & MASK_UPPER );
/* LSB */

/* Send API Identifier */


tempBuffer[3] = (char) type;
checksum = type;

/* Send Frame ID - AKA Message Number */


tempBuffer[4] = (char) frame_ID;
checksum += frame_ID;

/* Send Command */

for (which = 0; which < size; which++)


{
checksum += buf[which];
tempBuffer[which + 5] = buf[which];
}

checksum = MASK_UPPER - (checksum & MASK_UPPER);


tempBuffer[size+5] = checksum;

/* Change size */
size += 6;

for(temp = 0; temp < size; temp++)


{
printf("%X ", (int) tempBuffer[temp]);
}

printf("\nChecksum: %X.\n", checksum);

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;

while (size > 0)


{
if (times == 0)
{
times = 1;
timeout = max_timeout; /* Sets to initial max
timeout */
}
else
{
/* Reset timeout to get instant check as to whether
there is remaining data */
times = 2;
timeout = &small_timeout;
small_timeout.tv_sec = 0;
small_timeout.tv_usec = 100; /* was 2500 */
}

FD_ZERO( &temp_set );
FD_SET( fd, &temp_set );

nfds = select( fd+1, &temp_set, NULL, NULL, timeout );

printf("nfds = %d\n", nfds);

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;
}

int check_fd(int fd, int usec)


{
int nfds;
fd_set read_set;
struct timeval timeout;

FD_ZERO( &read_set );
FD_SET( fd, &read_set );

timeout.tv_sec = 0;
timeout.tv_usec = usec;

nfds = select( fd+1, &read_set, NULL, NULL, &timeout );

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 */

/* Try dumping modem */


fd_dump(modem_fd);

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

which = read ( modem_fd, bufptr, TEMP_BUF_SIZE );


tempBuffer[which-1] = NULCH;

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");

if (strcmp( tempBuffer, "OK" ) == 0)


{
/* Command mode exited */
return OK;
}
else
{
/* Error exiting command mode */
return -1;
}
}

int write_params()
{
char *bufptr;
char tempBuffer[TEMP_BUF_SIZE];

bufptr = tempBuffer;
send_to_modem(bufptr, "ATWR\r");

if (strcmp( tempBuffer, "OK" ) == 0)


{
/* Parameters successfully saved */
return OK;
}
else
{
/*/ Error error writing parameters */
return -1;
}
}

- 52 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

/* Might need to add command_length parameter in case binary commands


contain NULCH */
/* which would mess up the strlen command */

void send_to_modem(char *buf, char *command)


{
int which;
char *bufptr;
struct timeval timeout;

bufptr = command;
send_data( modem_fd, bufptr, strlen(command), NO_API, 0,
BROADCAST);

timeout.tv_sec = 1;
timeout.tv_usec = 0;

/* Use passed *buf var to store read info */


which = read_data ( modem_fd, buf, TEMP_BUF_SIZE, &timeout );
buf[which-1] = NULCH; /* Remove carriage return */
}

int ascii2hex(char *MY)


{
int int1 = 0x00;
int int2 = 0x00;
int dest_addr = 0x00;
char temp;

if (strlen(MY) == 1)
{
temp = MY[0];
MY[0] = '0';
MY[1] = temp;
}

printf("MY = %s\n", MY);

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;
}

dest_addr = int1 + int2;


return dest_addr;
}
void fd_dump(int fd)
{
char tempBuffer[MAX_API_PACKET+1];
struct timeval timeout;
int nbytes;

timeout.tv_sec = 0;
timeout.tv_usec = 0;

nbytes = read_data(fd, tempBuffer, MAX_API_PACKET, &timeout );


if (nbytes > 0)
printf("Dumped %i bytes.\n", nbytes);
}

- 55 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

Appendix 5 – Client and Server Code


/* index.php

Index page contains all search functionality and displays current


results. Refresh page to query database to update results.
Search by: Name, ID, node ID, job skill

*/

<?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());

/* Include the php file with functions for submitting forms */


include 'includes/functions.php';
print_header();
print_top_nav();
print_side_nav();
?>

<div class="midcontent">
<h1><center>Search for Miners Currently in System:</center></h1>

<p>It is possible to search for miners in multiple ways, but


currently not in combinations. Tracking data is deleted from the
database on a periodic basis as to only retain the most current data
and to preserve the integrity of the system. Searching can be
performed in the following ways:</p><br>
<p>
<ul>
<li>Search by a Miner's NAME</li>
<li>Search by a Miner's ID</li>
<li>Search by a Node LOCATION</li>
<li>Search by a specific JOB SKILL</li>
</ul>
</p><br><br>

<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>&nbsp;&nbsp;<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

<td><strong>Miner ID: </strong><INPUT


TYPE="text" NAME="minerID" SIZE="10"></td>
<td>&nbsp;&nbsp;<INPUT TYPE="submit"
NAME="submit" VALUE="Search Miner ID"></td>
</tr>
</FORM>
</table><br>

<table>
<FORM METHOD="post" ACTION="searchnode.php">
<tr>
<td><strong>Node &nbsp;ID: </strong><INPUT
TYPE="text" NAME="nodeID" SIZE="10"></td>
<td>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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());

$db = @mysql_select_db($db_name, $connection) or


die(mysql_error());

/* Include the php file with functions for submitting forms */


include 'includes/functions.php';
include 'includes/searchfuncs.php';

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

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>";
}
}
?>

</div> <!-- end mid content-->

</div> <!-- end container -->


</body>
</html>

/* 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());

$db = @mysql_select_db($db_name, $connection) or


die(mysql_error());

/* Include the php file with functions for submitting forms */


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[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());

$db = @mysql_select_db($db_name, $connection) or


die(mysql_error());

/* Include the php file with functions for submitting forms */

- 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>";
}
}
?>

</div> <!-- end mid content-->

</div> <!-- end container -->


</body>
</html>

/* admin_login.php

- 61 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

Administration login page. Use of client cookies allows users to view


other pages during a session.

*/

<?php

/* Include the php file with functions for submitting forms */


include 'includes/functions.php';

print_header();
print_top_nav();
print_side_nav();

?>

<div class="midcontent">
<h1><center>Administration Login</center></h1>

<p>Please log in to make changes to the System.</p>


<br><br>
<table>
<FORM METHOD="post" ACTION="auth_user.php">
<tr>
<td><strong>Username: </strong><INPUT
TYPE="text" NAME="username" SIZE=20 MAXLENGTH=20></td>
</tr>
<tr><td></td></tr>
<tr>
<td><strong>Password: </strong><INPUT
TYPE="password" NAME="password" SIZE=20 MAXLENGTH=20><td>
</tr>

<tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;<INPUT
TYPE="submit" NAME="submit" VALUE="Login"></td>
</tr>
</FORM>
</table><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 -->

/* 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>

<p>Administration have the ability to add new users to the


system as it becomes necessary.
Users can be removed from the system when no longer needed.
This is allows the system to be
quickly updated and maintained. When a modem is no longer
being used by a particular user, it
can be reassigned by adding the new user with the specified
modem ID.</p><br>
<p>If new job positions are needed, administration has the
ability to add new job positions,
which can be assigned to different users. A new job
position does no need to be added for
each individual user. The same position can be used by
many different users.</p><br>
<p>If new nodes are placed in the mine, the node identifier
must be updated in the system to
reflect the new node.</p><br>

<p>Below are the available administrative options:</p><br>


<table>

- 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>

</div> <!-- end mid content-->


</div> <!-- end container -->
<div class=\"footer\">
<p>Copyright 2007 WVU Senior Design - Mine Tracking
System</p>
</div>";
}
else
{
header( "Location: admin_login.php");
exit;
}

?>

<?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>

<table width="50%" align=left>


<th align=left>ADD NEW USER</th>
<FORM METHOD="post" ACTION="new_user.php">
<tr><td><strong>Name: </strong><div
class="subtitle">(first and last)</div></td></tr>
<tr><td><INPUT TYPE="text" NAME="miner_name"
SIZE="20"></td></tr>
<tr><td><strong>ID: </strong></td></tr>
<tr><td><INPUT TYPE="text" NAME="miner_id"
SIZE="20"></td></tr>
<tr><td><INPUT TYPE="submit" NAME="submit"
VALUE="Add New User"></td></td></tr>
</FORM>
</table>
<table>
<th align=left>DELETE USER</th>
<FORM METHOD="post" ACTION="delete_user.php">
<tr><td><strong>Name: </strong><div
class="subtitle">(first and last)</div></td></tr>

- 65 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

<tr><td><INPUT TYPE="text" NAME="miner_name"


SIZE="20"></td></tr>
<tr><td><INPUT TYPE="submit" NAME="submit"
VALUE="Delete User"></td></td></tr>
</FORM>
</table><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 -->

/* 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

$msg2 = "<p>Successfully removed $user from


System.</p><br />";
}
}
print_header();
print_top_nav_admin();
print_side_nav_admin();

?>

<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>

<p>Add a new node identifier to the system. When a node is


physically added to the mine,
administration should update the node network by adding the
new node on this page.</p><br>

<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>&nbsp;&nbsp;<INPUT TYPE="submit" NAME="submit"
VALUE="Add New Node"></td>
</tr>
</FORM>
</table><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 -->

/* remove_data.php
Administration can remove data from the database that is more than
three (3) days old.
*/

<?php

/* Include the php file with functions for submitting forms */


include 'includes/functions.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

$db = @mysql_select_db($db_name, $connection) or


die(mysql_error());
/* Remove old data from database

node_id, miner_id, time


*/
$today = date("Y-m-d");
$delete = "DELETE FROM $table WHERE time < ADDDATE('$today',
INTERVAL 3 DAY)";
$result = @mysql_query($delete, $connection) or
die(mysql_error());
$msg1 = "<p>Removing old data from database...<p><br />";

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

/* Include the php file with functions for submitting forms


*/
include 'includes/functions.php';
$connection = @mysql_connect("localhost", "senior_design",
"einstein7") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or
die(mysql_error());

/* Insert miner ID and miner name into miner_db (table).


Ensure that miner name does not already exist.
*/

/* Search for name AND id */


$sql = "SELECT * FROM $table WHERE name = '$name' AND miner_id =
'$id'";
$result = @mysql_query($sql);
$num = mysql_num_rows($result);
if($num != 0)
{
$error = "<p>Cannot add user. The user and ID already
exists in System.</p>
<p>Try searching on the main page to verify.</p>";
}

/* Search for name OR id */


$sql2 = "SELECT * FROM $table WHERE name = '$name' OR miner_id =
'$id'";
$result2 = @mysql_query($sql2);
$num2 = mysql_num_rows($result2);
if($num2 != 0)
{
$error2 = "<p>Cannot add user. The user or ID already
exists in System.</p>
<p>Try searching on the main page to verify.</p>";
}

/* 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>";
}

if($num == 0 && $num2 == 0 && $num3 == 0)


{
$insert = "INSERT INTO miners_id (miner_id, name) VALUES
('$id', '$name')";
$result = @mysql_query($insert, $connection) or
die(mysql_error());
$msg1 = "<p>Adding $name with id: $id to database...</p>";
$msg2 = "<p>The user $name was sucessfully added to the
System</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>

<p>You may add a new job position here if it does not


already exist.
Please look at the positions provided before trying
to add a new position.
The desired position may already exist.</p><br><br>
<?php
$sql = "SELECT job_title FROM jobs_id";
echo "<table border=\"2\" bordercolor=\"#336699\"
cellpadding=\"1\" cellspacing=\"2\" width=\"100%\">";
echo "<tr><h1><center>Current Job Positions in
System</center></h1></tr>";
echo "<tr><td width=\"100%\" align=\"center\">Position
Title</td></tr>";
$result = @mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo "<tr><td>";
echo $row['job_title'];
echo "</td></tr>";
}
?>
<table>
<FORM METHOD="post" ACTION="validate_job.php">
<tr>
<td><strong>Job Title: </strong></td>
<td><INPUT TYPE="text" NAME="job_title"
SIZE="20"></td>
</tr>
<tr><td> </td></tr><tr><td> </td></tr>
<tr>
<td> </td>
<td>&nbsp;&nbsp;<INPUT TYPE="submit"
NAME="submit" VALUE="Add New Job Position"></td>
</tr>
</FORM>
</table><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 -->

/* 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;
}

/* Include the php file with functions for submitting forms */


include 'includes/functions.php';

$db_name = "miner_db";
$table = "jobs_id";

$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.
*/

$sql = "SELECT job_title FROM $table WHERE job_title =


'$new_job'";

$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

$msg1 = "<p>Adding position $new_job to


database...<p><br />";
$msg2 = "<p>Successfully added $new_job into
System.</p><br />";
}
}

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;
}

/* Include the php file with functions for submitting forms */


include 'includes/functions.php';

$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.
*/

$sql = "SELECT node_id FROM $table WHERE node_id = '$new_node'";


$result = @mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$search_result = $row['node_id'];
}
if(strlen($search_result) != '0')
{
$msg = "The node you're trying to add already exists";
}
else{
if(strlen($search_result) == '0')
{
$insert = "INSERT INTO node_ids (node_id) VALUES
('$new_node')";
$result = @mysql_query($insert, $connection) or
die(mysql_error());
$msg1 = "Adding node $new_node to database...<br />";
$msg2 = "Successfully added $new_node into System <br
/>";
}
}

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

/* Include the php file with functions for submitting forms */


include 'includes/functions.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>

<h4>Search by Miner ID</h4>


<p>To search for users by ID, you must enter the full ID
associated with the user. Omitting part of the ID can produce multiple
results.</p><br>

<h4>Search by Node ID</h4>


<p>To search for users by node ID, you must enter the full
node ID. Omitting part of the node ID can produce multiple
results.</p><br>

- 76 -
Team 2: Mine Tracking System: Detailed Design Review December 2, 2007

<h4>Search by Job Skill</h4>


<p>To search by job skill, you must enter the full name of
the job skill. Entering part of the word will not produce any
results.</p><br>

<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>

<h4>Add Users to the System</h4>


<p>To add a new user to the system, you must log in to the
administrator interface with a valid username and password. Once
logged in, click the <b>Modify Users</b> button and proceed to the next
page. Enter the user's full name and his/her associated ID number.
Click <b>Add New User</b> once you're finished. The new user is now
stored in the database and the user is trackable.</p><br>

<h4>Remove Users from the System</h4>


<p>To remove a user from the system, you must log in to the
administrator interface with a valid username and password. Once
logged in, click the <b>Modify Users</b> button and proceed to the next
page. Enter the user's full name. Click <b>Delete User</b> button once
you're finished. The user's name and associated ID are now freed from
the database and the ID number can be reused if necessary.</p><br>

<h4>Add job skills to System</h4>


<p>To add a new job skill to the system, you must log in to the
administrator interface with a valid username and password. Once
logged in, click the <b>Add Job Position</b> button and proceed to the
next page. You will see a list of currently available job positions at
the top of the page. If the job position you're looking for does not
exist in the database, you can enter the new position title and click
the <b> Add Job Title</b> button.
</p><br>

<h4>Add New Nodes to the System</h4>


<p>When a new node is installed in the mine, an administrator must
also add the new node to the database. To add a new node to the
system, you must log in to the administrator interface with a valid
username and password. Once logged in, click the <b>Add System
Node</b> button and proceed to the next page. Enter the node ID of the
new node and click <b>Add New Node</b> once you're finished. The new
node should now be accessible for tracking purposes.
</p><br>

<h4>Remove data from database</h4>


<p>To remove old data from the system, you must log in to the
administrator interface with a valid username and password. Once
logged in, click the <b>Remove Data</b> button. Data that is more than
72 hours old is removed from the database. Periodically removing
unused data from the database will increase efficiency of the system
and will provide more pertinent results when searching.</p><br>
</div> <!-- end mid content-->
</div> <!-- end container -->

- 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

/* Include the php file with functions for submitting forms */


include 'includes/functions.php';
print_header();
print_top_nav();
print_side_nav();
?>

<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>

<p>The System's primary goal is to provide a means to locate


miners if a disaster should
strike and cause damage to the mine. In cases of emergency,
management and rescue teams
will still have access to the web interface and the data stored in
the database. The tracking
system is a valuable asset in locating trapped miners in a time of
emergency. The system
provides the rescue team an approximate location of trapped miners
and should shorten the
time it takes to rescue trapped miners. The tracking system can also
be used by management
or administration to find workers with specific job skills then move
them to a particular location
where they are needed.</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

and data is relayed to a coordinator node at the entrance of the


mine. The user's ID and the
current node ID is then sent to the server and stored in the database
for later retrieval.</p><br>

<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>&middot; Add Users to the System</li>
<li>&middot; Remove Users from the System</li>
<li>&middot; Add New Nodes to the System</li>
<li>&middot; Add job skills to System</li>
<li>&middot; 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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"


"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="includes/screen.css"
media="screen"/>
<link rel="shortcut icon"
href="http://mts.thebigbit.com/favicon.ico">
<title>Miner Tracking System</title>
</head>
EOD;

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 "&nbsp;&nbsp;<br />";
print date('H:i:s');
echo "&nbsp;&nbsp;</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

echo "<div class=\"right\">";


print date('D, M d Y');
echo "&nbsp;&nbsp;<br />";
print date('H:i:s');
echo "&nbsp;&nbsp;</div></div> <!-- end topnav -->";

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";
}

/* Side navigation for administration */

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>

</body> <!-- end body -->


</html> <!-- end html -->
EOD;

- 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;
}

.left {float: left;}


.right {float: right;}

p, li {font: normal 1.2em Verdana, sans-serif;}

table {
margin: 0 5px 10px 10px;
}
tr,td {
font: normal 1.2em Verdana,sans-serif;
}

form,input {margin: 0px; padding: 0; display: inline;}

body {
background: #FFF;
color: #000;
font: normal 62.8% Tahoma,sans-serif;
padding-top: 30px;
}

li {list-style: none;}

h1,h2,h3 {text-decoration: 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 -

Potrebbero piacerti anche