Client Usage

Introduction

The client-side code to communicate with the SADB should be compiled as a library and any SADB client program should link with the libSADB.a file.

Requirements

The client library should not require any external components. For windows, gnuwin32 should be installed.

Configuration

Two files might need to be modified, depending on the operating system and architecture. The first one is "SADB-Client/SADB.". Near the top of the file, you should see the following:
#define SADBPort	0xADB
#define SADBAddress	"127.0.0.1"
These are the default address and port to use to connect to SADB. As the address and port can be specified when connecting to a server, these do not need to be changed, but can be for convenience.

The second part of the file that might need to be configured is the declaration of basic types used to communicate with the database server. You should make sure that the size of the types match according with the architecture.
typedef long Pointer;//size of a memory address (long for 64 bits system, int for 32 bit systems) this is needded for MSVC++ to compile
typedef unsigned char		SADBu8;  // unsigned 8 bits integer
typedef signed char		SADBs8;  // signed 8 bits integer
typedef unsigned short		SADBu16; // unsigned 16 bits integer
typedef signed short		SADBs16; // signed 16 bits integer
typedef unsigned int		SADBu32; // unsigned 32 bits integer
typedef signed int		SADBs32; // signed 32 bits integer
typedef unsigned long int	SADBu64; // unsigned 64 bits integer
typedef signed long int		SADBs64; // signed 64 bits integer
typedef float			SADBfl;  // single precision floating point number
typedef double			SADBdfl; // double precision floating point number

Windows Specific Instructions

I will not provide any support for compiling the client library on windows as I am not familiar with the platform, but the library should be compiled exactly like the linux version if using cygwin or mingw. For simplicity, if using MSVC++, the Windows folder in SADB-Client contains the include files and precompiled dll for libpthread, which is required for compilation. The first thing to do is add the proper paths to your MSVC++ project (Projects-Properties-VC++ Directories). Add the "include" and "lib" folders found in "SADB-C++/Windows". Then make sure that your MSVC++ projects links to the correct lib files (Projects-Properties-Linker-Input-Additional Dependencies). Linking to "pthreadVSE1.lib" and "libpng.lib" should be adequate. Finally, copy the pthreadVSE1.dll, libpng.dll.a, and libz.dll.a files to the same folder as the executable file (or somewhere in your path). These files are originally in the "SADB-Client/Windows/dll" folder.

Using SADB

The archive file in the download section contains a "Tests" folder which contains a variety of sample programs used to test a few functions of the SADB server. The test programs can be compiled with:
# make Tests
A simple demonstration following the ball tracker example used in the last S2-D3 charm report can be executed by running the following two demos (while the server is running). The first demo is Test.BallTracker, which creates the various objects and categories defined in the report.
# ./Test.BallTracker
The demo takes a few seconds to run as it tests the timestamp functions to set different timestamps. The second demo program is Test.RequestBallColor, which requests different values from the SADB server and prints the results.
# ./Test.RequestBallColor
Another interesting test program is Test.Interpolation, which requests values from the server at precise timestamps using both linear interpolation and clipping. For more information about using SADB in your own programs, see this page.