\chapter{The Blackhawk Testing Application}

The Blackhawk testing application is designed to help the production staff to check the reports sent by new produced blackhawk units. It can indicate which blackhawk unit is good, which blackhawk unit is bad. The checking will be based on the function 1 reports. The function 1 reports are sent by the blackhawk units when they are powered on. The application will be able to add passed blackhawk units to the blackhawk database, generate reports of testing report and do some statistically analysis as well.

\section{Introducion}
The Blackhawk testing application is developed by C\# using Visual Studio 2005. It will be used in the factory by the production staff. It will be able to access the factory database and the blackhawk database outside the factory. Figure~\ref{fig:application} shows the main structure of the application running environment.

\begin{figure}[htcb]\centering
\epsfxsize=120mm
\epsfbox{application.eps}
\caption{Main structure}
\label{fig:application}
\end{figure}

\subsection{Factory Database}
The factory has a database to manage all new produced blackhawk units. This database is factory's own database and has nothing to do with blackhawk company. My application will connect to this database to get the basic information of the new blackhawks. Factory database is also inside the factory, the application will treat it as local database. The blackhawk unit information in the Factory database in different from the blackhawk database. 

\subsection{Blackhawk Database}
The Blackhawk database is the database from which the application can get the unit reports from. All the reports sent by the blackhawk units will be recorded in this database. The Blackhawk database is outside the factory. The application will need internet connection to connect to the blackhawk database.
\section{How can we archive it}
The application can find out the faulty blackhawk units base on the reports sent by the blackhawk units. The application load the blackhawk units from the database, then get the reports sent by these blackhawk units using Blackhawk APIs and check the reports using the checking rules. If there are any problems with the reports, we can say the blackhawk units that sent the reports are faulty. After checking, the application can add the passed blackhawk unit to the blackhawk database using the blackhawk APIs. 

\subsection{Blackhawk APIs}
The Blackhawk company has provided a bounch of APIs that I can use to operate the blackhawk database. The Blackhawk APIs are based on web service. Here is a list of the APIs:\\

BlackhawkAdminService

BlackhawkCustomerService

BlackhawkDeviceService

BlackhawkEventService

BladkhawkFactoryService

BlackhawklnvoiceService

BlackhawkLoginService

BlackhawkReportService

BlackhawkSMSService

BlackhavvkTrackService

\subsubsection{BlackhawkLoginService} 
BlackhawkLoginServeice provides the Login, Logout and other methods. To use the Blackhawk APIs, the user have to login to the Blackhawk server within the Login method. Different users will have different access rights to the blackhawk database. The security problem will be managed by the Blackhawk API Server, so that the application doesn't need to worry about it. 

\subsubsection{BlackhawkEventService}
BlackhawkEventService contains the most important APIs for this application. Using these APIs, we can get all the Blackhawk events as we need.The word ``Event'' here is the same meaning as report. Each time the blackhawk unit is triggered, we treat it as a event. Once a event happen, the blackhawk will send a report to the blackhawk server. If we want to know what kind of event it is, we can have look at the event report.

\begin{figure}[htcb]\centering
\epsfxsize=150mm
\epsfbox{eventService.eps}
\caption{The BlackhawkEventService APIs}
\label{fig:eventService}
\end{figure}

Figure~\ref{fig:eventService} shows all the web services I can use to get Blackhawk Events.  The method FindEventsForDeviceByFunction() will be mainly used in this application. The powering on event will cause the blackhawk unit to send a Function one report to the server. The application can use this method to get all the function one report for the devices. The function code of the report is made to indicate what kind of event is triggered. Once a blackhawk unit is powered on, it will be automatically reset. This will cause the blackhawk unit to set the function code to 1 and send the report including other information to the blackhawk server. So we call this report as function one report. 

\subsubsection{Other Web services}
Other web services are not used in the application at this stage, we may need to use them in the future. The company may add more requirements to the application to meet new conditions.

\subsection{Unit reports}
Table~\ref{tab:unitReport} is a sample unit report I extracted from blackhawk database. This is not a function one report. We can see that this is a ``Blackhawk installed'' report from the Table~\ref{tab:unitReport}. I have no idea what the function code is, because they have mapped the function code to the event name.

\begin{table}[hcb]
\begin{center}
\begin{tabular}{|lr|} %table with 3 columns
\hline
FIX &3\\
ID &30243\\
Date Recorded &8/06/2008 19:18\\
SEN &120244\\
IMS &5.30011E+14\\
LAT &3656.8163S \\
LON &17450.2974E \\
ALT &32\\
SPD &0\\
COG &63\\
HRS &0\\
BAT &12.3\\
SSI &0\\
BAL &0\\
BER &0\\
SWV &703404016\\
FUN &Blackhawk installed \\
Latitude &-36.9469\\
Longitude &174.8383\\
Device &E10248 \\
Address &11 Lippiatt Road, Otahuhu, Auckland City \\
Accuracy &0\\
Port &6672\\
Data &\\
\hline
\end{tabular}
\end{center}
\caption{This is my next table}
\label{tab:unitReport}
\end{table}

The application doesn't need to check everything in the report. But most of them will be checked. This report is not difficult to understand. The FIX should be something new added recently which I don't really know. ID is the event ID. Date Recorded is the time at which this report is received. SEN is the serial number of the Blackhawk unit. IMS is the number belong to the SIM card. LAT is the latitude of the blackhawk location. LON is the Longitude of the blackhawk location. If you look carefully, you will find another Latitude and Longitude in this report. They also stand for the location of the blackhawk location, but in different format. 

The application will check this report using the checking rules. 

\subsection{Checking Rules}
Checking rules are rules we made to check the unit reports. For example, The IMS number should be the same as the IMS number from the factory database, the address should be the factory address.


\section{The softeware requirements}

The application shall have a login panel that allows the user to login.

The application shall have the ability to accept the input from the scanner.

The application shall have the ability to read and update the factory database.

The application shall have the ability to read the received units reports from the Blackhawk database.

The application shall highlight the pass units with green color.

The application shall highlight the faulty units with orange color.

The application shall highlight the units whose reports cannot be detected with red color.

The application shall be able to retest the units that are highlighted red.

The application shall be able to add the new pass units to the Blackhawk database.

The application shall be able to generate a report of the testing result.

The Application should be able to do some statistical analysis of the results.

The Application should be configurable so that can be used in different conditions.

\subsection{Use case Diagram}
To make life easier, we want the application to do as much as it can. We don't want the production staff waste any time on testing the blackhawk units. Figure~\ref{fig:usecase} shows how easy will be for the production staff with the help of the application.

\begin{figure}[htcb]\centering
\epsfxsize=120mm
\epsfbox{usecase.eps}
\caption{The Testing Process}
\label{fig:usecase}
\end{figure}

Form the diagram, we can see that the tester only need to do two things, run the application and Scan and power on all the units. All other things will be done by the application automatically. How does the tester do the job? The tester run the application and do some setting if needed. Then navigate to the testing panel. The tester then use a scanner to scan the barcode of the blackhawk unit to the application and put the blackhawk unit into a tray which can supply power one by one. Then the final thing, simply click the ``start'' button in the application. Now the tester can sit down and have a cup of coffee waiting the application to give testing results. After 15 (can be configured to other value) minutes, the tester come back to the application, find out the faulty units if any and return them to the factory for fixing. All the passed units then will be packed and ready to be sent to the Blackhawk Company by the tester. When the Blackhawk company receive these new products, all of them are ready for sell, because all the information of these new products has been updated to the blackhawk database by the application.

You may be interested in what the application does in the background. Let me explain this diagram a little bit. When the tester scan the blackhawk units, the application will load information of the blackhawk units from the factory database. After the ``start'' button is clicked, the application will get and check the units reports from the blackhawk database every two minutes. The units sent problem reports will highlighted orange. The units sent fine reports will be highlighted green. Other units whose reports cannot be received after time out will be highlighted red. Then, the application add the passed units to the blackhawk database. The application will need to generate report of testing result as well. We may upload the result report to the blackhawk database in the future. The application may be able to do some Statical analysis.

\subsubsection{Why every two minutes}
Once the tester put a blackhawk unit in the tray and power on, the blackhawk unit will be reset. Then it will send a function one report to the Blackhawk server. This process will take some time. Because the Blackhawk unit have to warm up and gather all the information that need to be sent, such as Latitude and Longitude. The latitude and longitude are got from the GPS satellites. If the GPS signal is too week, it take longer time for the blackhawk unit to get the latitude and longitude. If there is not GPS Signal, the testing cannot be done. The blackhawk company is planing to set up a GPS magnifier in the factory to avoid any GPS signal problem. Once all the information are gathered, the blackhawk unit will connect to the blackhawk server through GPRS. As GPRS is a kind of slow protocol, it also take time to send the report to the blackhawk server. Beyond that, we need to consider the GPRS signal as well. For this reason, the blackhawk server will not get the units reports immediately after they are powered on. Some reports may be received earlier, some reports may be received later. To make sure we can get all the sent reports, we set a polling interval which is two minutes.  Also, we set a time out interval to stop the application keeping polling Blackhawk APIs for getting reports. Both the polling interval and time out interval are configurable.
\subsection{Confiuration}
To make the application more flexible, we need to add the reconfigurability to the application. For example, if we have a good GPS signal and GPRS signal, we may want to reduce the time out interval. The application do supply a setting panel for configuration. But we still need somewhere we can save the change. I'm using a XML file to save the configuration. 
\begin{verbatim}
<!file name: bta.exe.config-->
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="TimeOut" value="15" />
<add key="FactoryAddress" value="Auckland University" />
<add key= "Interval" value="2" />
<add key= "Lat_Min" value="0" />
<add key= "Lon_Min" value="0" />
..
</appSettings>
</configuration>
\end{verbatim}
In this example, the timeout interval is set to 15 minutes. The factory address is set to Auckland University. The advantage of using this format is that c\# support it very well.


\subsection{Generating reports}
\subsection{Statstatic support}
\subsection{Update Factory Database}
\subsection{Update Blackhawk Database}
\subsection{The Application Overview}
\subsubsection{Why use buttons to stand for blackhawk units}

