/*************************************************************************\
* "$RCSfile: Documentation.cpp,v $"                                       *
***************************************************************************
* Information by CVS or VSS:                                              *
*     Last check in on: $Date: 2011/09/07 16:38:29 $                      *
*     by                $Author: goebel $
*     Revision        : $Revision: 1.2 $                                 *
***************************************************************************
* Project documentation                                                   *
\*************************************************************************/
/*!
\mainpage Photonfocus AG + IMAGO Technologies GmbH
\image html B_PSCAM.png
\section Introduction
This application provides a user interface to all functions and
features which are implemented in the software of the VisionCam PS / SM2.
The SDK user can implement his own algorithms using the class CDlgApp.
The user of an application can handle the camera with a web browser.

\section SR Screen regions
The screen is divided into four areas which are handled separately by
the software.

\image html ScreenRegions.png Different regions of the user interface
<table style="border:1px solid #CCCCCC" cellspacing="2" align="center">
<tr><th class="w">Region</th><th class="w">Color</th><th class="w">Description</th></tr>
<tr><td class="l">\ref DR</td><td class="l">Red</td>  <td class="l">User controls displayed simultaneously with the camera image</td></tr>
<tr><td class="l">\ref IR</td>  <td class="l">Blue</td> <td class="l">Logging, histogram, application output</td></tr>
<tr><td class="l">\ref GR</td> <td class="l">Pink</td> <td class="l">CPU load/Temperature/Frame rate/... graph</td></tr>
<tr><td class="l">View</td>  <td class="l">Green</td><td class="l">Camera live image. The imaging application can draw into it.</td></tr>
</table>

\section DR Dialog region
The dialog region is used by following classes:
<table style="border:1px solid #CCCCCC" cellspacing="2" align="center">
<tr><th class="w">Dialog Class</th><th class="w">Description</th></tr>
<tr><td class="l">CDlgApp</td><td class="l">Class for implementing an Imaging Application.\n
	Provides the user interface and a container for a SDK user application.\n
	The user can use the camera framework library and has only to implement this class.</td></tr>
<tr><td class="l">CDlgCam</td><td class="l">Camera settings dialog class.\n
	Provides the user interface to camera and "frame grabber" settings.
	(See \ref CSD)</td></tr>
<tr><td class="l">CDlgConfig</td><td class="l">User interface class to \p Config class.\n
	Provides a user interface to the \p Config class.\n
	The dialog is a full screen dialog and therefore it is modal.</td></tr>
<tr><td class="l">CDlgLog</td><td class="l">Dialog class to view and save the log.\n
	The user can scroll up and down in the log and can save the log to a text file on the SD card. It is modal.</td></tr>
<tr><td class="l">CDlgMain</td><td class="l">Main dialog class.\n
	Provides the main dialog.</td></tr>
<tr><td class="l">CDlgPreviewSettings</td><td class="l">Dialog class for changing zoom factor or ROI.\n
	It is non modal. A down scaled live image is displayed inside the dialog area.
	With a rectangle the ROI is marked. By clicking inside the user can change the
	position of the ROI. The user can zoom in and out.</td></tr>
<tr><td class="l">CDlgSaveImage</td><td class="l">Dialog class for saving an image to SD card.\n
	It is non modal. The user can save an image as *.png, *.jpg or *.bmp. The
	filename contains a up to 5 chars long prefix and an 3 digit number this
	number can be incremented automatically. The path of the filename is
	taken from the \p Config instance CPSApp::m_VicPs.</td></tr>
<tr><td class="l">CDlgTools</td><td class="l">Tools dialog class.</td></tr>
</table>

\section GR Graph region
The graph region is used for displaying CPU load, Temperature, etc.
<table style="border:1px solid #CCCCCC" cellspacing="2" align="center">
<tr>
	<th class="w">Mode</th><th class="w">Description</th><th class="w">Value</th>
</tr>
<tr>
	<td class="l">\image html CPULoad.png</td>
	<td class="l">Graph of CPU load for running the application</td>
	<td class="l">GraphType::CPU_LOAD</td>
</tr>
<tr>
	<td class="l">\image html Temperature.png</td>
	<td class="l">Graph of temperature inside the camera housing</td>
	<td class="l">GraphType::TEMPERATURE</td>
</tr>
<tr>
	<td class="l">\image html Framerate.png</td>
	<td class="l" >Graph of frame rate. The frame rate grabbed by the camera and
	processed by application is shown in magenta. It is marked with
	\p C. The frame rate displayed over Ethernet is shown in cyan. It is
	marked with \p D.</td><td class="l">GraphType::FPS</td>
</tr>
<tr>
	<td class="l">\image html InfoGraph.png</td>
	<td class="l">Info of sensor module status line. If the sensor module status
	line is disabled the last values are shown.</td><td class="l">GraphType::INFO</td>
</tr>
</table>

\section IR Info region
The info region is used for displaying the log, different histogram
versions and an application specific output.
<table style="border:1px solid #CCCCCC" cellspacing="2" align="center">
<tr><th class="w">Mode</th><th class="w">Description</th><th class="w">Image</th></tr>
<tr><td class="l">Log\n InfoType::LOGFILE</td><td class="l">Application log. The
	user can print into this area using CLog::Print() with the CLog instance.</td>
	<td class="l">\image html InfoLog.png</td></tr>
<tr><td class="l">Histogram\n InfoType::HISTOGRAM</td><td class="l">Histogram
	of the grabbed image. Linear scaled.</td>
	<td class="l">\image html InfoHistogram.png</td></tr>
<tr><td class="l">Histo Log\n InfoType::HISTOGRAM_LOG</td><td class="l">Histogram
	of the grabbed image. Logarithmic scaled.</td>
	<td class="l">\image html InfoHistoLog.png</td></tr>
<tr><td class="l">App\n InfoType::APP</td><td class="l">Application specific
	information is shown. This area is used by CPSApp::DisplayDlgAppInfo(). The
	user can assign this function pointer to a self created function. By default
	it is initialized with \p NULL.</td>
	<td class="l">\image html InfoApp.png Example for application specific
	outputs inside the info area.</td></tr>
</table>

\section CSD Camera settings dialog
Class CDlgCam.\n
The camera dialog provides the user interface to camera and "frame grabber" settings. 

\image html Camera01s.png Camera dialog
There are nine dialog sub pages for functional groups. These pages are
selected with the member CDlgCam::m_Sel. Allowed values are defined in
CDlgCam::eDlgCam_SEL.

The sub pages are:

<table style="border:1px solid #CCCCCC" cellspacing="2" align="center">
<tr><th class="w">Page</th><th class="w">Settings</th></tr>
<tr>
	<td class="l">\image html exposure.png</td>
	<td class="l">
	- Exposure time
	- Enable constant frame rate
	- Frame time
	</td>
</tr>
<tr>
	<td class="l">\image html Trigger.png </td>
	<td class="l">
	- Source: Free running, Opto In 0, RS422 In 0, RS422 Encoder
	- Define exposure time by trigger pulse width
	- Trigger delay
	- Invert trigger
	- Interleave mode (simultaneous read out)
	</td>
</tr>
<tr>
	<td class="l">\image html strobe.png</td>
	<td class="l">
	- Delay in respect to trigger input signal
	- Pulse width
	- Invert
	- Output: Disabled, Opto Out 0, Differential Out 0
	</td>
</tr>
<tr>
	<td class="l">\image html DataFormat.png</td>
	<td class="l">
	- Output mode
	- Resolution
	- Digital gain
	- Look up table mode
	- Look up table value
	- Load LUT from file
	- Save LUT to file
	</td>
</tr>
<tr>
	<td class="l">\image html Window.png</td>
	<td class="l">
	Region of interest
	- Position X
	- Position Y
	- Width W
	- Height H
	.
	Multiple regions of interest
	- Index
	- Position Y
	- Height H
	- Info: Total image height
	</td>
</tr>
<tr>
	<td class="l">\image html Linlog.png</td>
	<td class="l">
	Linlog mode
	- Low compression
	- Normal compression
	- High compression
	- User defined
	.
	Values for user defined mode
	- Voltage V1
	- Voltage V2
	- Time T1
	- Time T2
	.
	Other
	- Skimming
	- Blacklevel offset
	</td>
</tr>
<tr>
	<td class="l">\image html correction.png</td>
	<td class="l">
	Mode
	- Off
	- Offset
	- Offset + Hotpixel
	- Hotpixel
	- Offset + Gain
	- Offset + Gain + Hotpixel
	- Black reference output
	- Gray reference output
	.
	Buttons for teaching the correction images
	- Validation Black
	- Set Black Ref
	- Validation Grey
	- Set Grey Ref
	- Save to flash
	.
	Other
	- Histogram stretching
	</td>
</tr>
<tr>
	<td class="l">\image html preset.png</td>
	<td class="l">Load and store settings from SD card. The select box shows the
	existing settings. With the button "Apply Pr." the selected setting is
	loaded. With the Button "Save P" the user can store a setting. All
	settings are loaded	from/stored to the directory "PRESET" on the SD
	card.</td>
</tr>
<tr>
	<td class="l">\image html CamInfo.png</td>
	<td class="l">Displays firmware revisions of sensor.\n Buttons
	- Store as Defaults (stores current setting on sensor module flash)
	- Recall Defaults
	- Factory Reset
	</td>
</tr>
</table>

*/
/*!
\page userclass User Class
For an application only one class has to be implemented by the user:
The application dialog class, CDlgApp.
It is made of a header file CDlgApp.hpp and an implementation file CDlgApp.cpp.
The class creates an own dialog on the left side of screen and gives access to
images grabbed by the camera.\n
This class declares four functions:
- Constructor (CDlgApp::CDlgApp())\n
Construction of the class\n
Initialization of user variables, create dialog items, etc.
- Destructor (CDlgApp::~CDlgApp())\n
Clean up of the class\n
Free allocated memory, etc.\n
- CDlgApp::OnUserIO()\n
This function is automatically called by the framework when an user input
occurs.\n
It is designed to handle user inputs like keyboard or mouse events.
- CDlgApp::OnImage()\n
This function is called by the framework after a new image has been grabbed.\n
It is intended for performing the image processing.
.

See \ref useful for available functions.

CDlgApp provides the user interface and a container for a user application.

The constructor of CDlgApp is called by the application framework as well
as all other functions to display and handle it. All user interface related
functions run as a part of the task task_main() inside the function
CDlgApp::OnUserIO(). Only the function CDlgApp::OnImage() is called by the
task CPSApp::PSGrab().

\image html VIB_PS_SDK_Tasks.png Functions used by CDlgApp of SDK project

\page appclass Application Class
\htmlonly
<style type="text/css">
td {
background-color:#FAFAFA;
border:1px solid #CCCCCC;
margin:2px 0;
padding:2px 10px;
vertical-align:top;
}
</style>
\endhtmlonly

For most of the framework classes only one class instance is allowed.
Therefore constructor and destructor are declared private and the
functions \p CreateInstance() and \p DisposeInstance() are called instead.
Use the function \p GetInstance() to access the members of a class.

The most important class is the main application class CPSApp. It
initializes the program, handles most program parameters and the main program
loop (CPSApp::MainUILoop()).\n
The image acquisition is done in a separate task (CPSApp::TaskPSGrab()).\n
There are many helper functions supporting other classes like
CPSApp::SetApplicationName() or CPSApp::GetIPAdr().

\section useful Useful functions
The following table shows a list with useful functions which can be used in the \ref userclass.

<table style="border:1px solid #CCCCCC" cellspacing="2">
<tr><th class="w">Function</th><th class="w">Description</th></tr>
<tr>
 <td>CPSApp::StartGrabTask()</td>
 <td>Start grab task</td>
</tr>
<tr>
 <td>CPSApp::StopGrabTask()</td>
 <td>Stop grab task</td>
</tr>
<tr>
 <td>CPSApp::SetApplicationName()</td>
 <td>Set name of user application</td>
</tr>
<tr>
 <td>CPSApp::SetApplicationIcon()</td>
 <td>Set icon of user application</td>
</tr>
<tr>
 <td>CPSApp::MessageBox()</td>
 <td>Easy use of message boxes</td>
</tr>
<tr>
 <td>CPSApp::Display()</td>
 <td>Display image</td>
</tr>
<tr>
 <td>CPSApp::GetWidth()<br>CPSApp::GetHeight()</td>
 <td>Get width/height of TCP-Display</td>
</tr>
<tr>
 <td>CPSApp::GetCamWidth()<br>CPSApp::GetCamHeight()</td>
 <td>Get width/height of camera image</td>
</tr>
<tr>
 <td>CPSApp::IsCameraActive()</td>
 <td>Get state of grab loop</td>
</tr>
<tr>
 <td>CPSApp::GetScale()</td>
 <td>Get scale factor of live image</td>
</tr>
<tr>
 <td>CPSApp::GetSkinPath()</td>
 <td>Get path of icon images</td>
</tr>
<tr>
 <td>CPSApp::GetBgImage()</td>
 <td>Get background image</td>
</tr>
<tr>
 <td>CPSApp::GetDispImage()</td>
 <td>Get display image</td>
</tr>
<tr>
 <td>CPSApp::GetIcon()</td>
 <td>Get icon image from global list.<br>(#IconId::OK, #IconId::CANCEL, ...)</td>
</tr>
<tr>
 <td>CPSApp::GetKeyboardHandle()</td>
 <td>Get keyboard handle</td>
</tr>
<tr>
 <td>CPSApp::GetStr()</td>
 <td>Get string from global string table<br>(#StringTable)</td>
</tr>
<tr>
 <td>CPSApp::GetSerialNumber()</td>
 <td>Get serial number of camera</td>
</tr>
<tr>
 <td>CPSApp::GetIPAdr()</td>
 <td>Get IP address</td>
</tr>
<tr>
 <td>CPSApp::GetLibVersion()</td>
 <td>Get version of framework</td>
</tr>
<tr>
 <td>CPSApp::IsDlgInFocus()</td>
 <td>Has the dialog focus?</td>
</tr>
</table>

\page libraries Used libraries
The following libraries are necessary for a project.

<table style="border:1px solid #CCCCCC" cellspacing="2">
<tr><th class="w">Library</th><th class="w">Description</th></tr>
<tr><td class="l">\p Framework_C64p.lib</td><td class="l">Camera framework library\n Application & Framework</td></tr>
<tr><td class="l">\p VIB_C6455_Bios.lib</td><td class="l">VisionBox library\n Basic functions</td></tr>
<tr><td class="l">\p GBIT_C6455.lib</td><td class="l">GBit library\n Ethernet functions</td></tr>
<tr><td class="l">\p GUI_C64p.lib</td><td class="l">GUI library\n Graphical User Interface</td></tr>
<tr><td class="l">\p FreeType.lib</td><td class="l">FreeType library\n TrueType vector font handling</td></tr>
<tr><td class="l">\p JPEG_C64p.lib</td><td class="l">JPEG library\n JPEG functions</td></tr>
<tr><td class="l">\p PNG_C64p.lib</td><td class="l">PNG library\n PNG functions</td></tr>
<tr><td class="l">\p TinyXML_C64x.lib</td><td class="l">TinyXML library\n XML data handling</td></tr>
<tr><td class="l">\p ZLib_C64p.lib</td><td class="l">zlib\n Compression functions (for PNG)</td></tr>
<tr><td class="l">\p csl_c6455.lib \n\p edma3_drv.lib \n\p edma3_rm_C6455.lib</td><td class="l">TI libraries\n Hardware and DMA functions</td></tr>
</table>
*/
/*
\page history Version History
\htmlonly
<style type="text/css">
td {
background-color:#FAFAFA;
border:1px solid #CCCCCC;
margin:2px 0;
padding:2px 10px;
vertical-align:top;
}
</style>
\endhtmlonly
<table style="border:1px solid #CCCCCC" cellspacing="2">
<tr><th class="w">Date</th><th class="w">Function / Module</th><th class="w">Changes</th></tr>
<tr><th colspan="3" class="w">2010</th></tr>
<tr>
 <td>12-May-2010</td>
 <td>&nbsp;</td>
 <td>Internal functions sourced out</td>
</tr>
</table>
*/
/**************************************************************************/
