QuercusVL Programming Manual
2. Basic Programming
The following pages describes the required steps to develop a minimum program capable of
receiving the information generated in a unit.
Basic programming knowledge is assumed to tackle this chapter (C and C++). If you usually
work with some of these technologies, you will have no problem following the examples.
The source code of the examples is found in <installation folder>/Samples.
2.1. C++
The method used by the C++ library to generate events, so that the client application is in
charge of the implementation, is forcing the client application to implement a class according
to a specific interface. When an event occurs in a detector (for instance, generation of a real
time event), the library will call the corresponding method (OnRealTimeInformation in this
case). Take into account that these methods will be called from execution threads which are
different from the main one, so code that is not safe about threads or unable to be executed
out of the main thread, cannot not be used for the implementation.
A short C++ program is shown next, which is capable of capturing events. It corresponds to
the basic C++ sample located at Samples folder in the installation directory.
/*------------------------------------------,
| Copyright (C) 2011 Quercus Technologies |
| All rights reserved. |
`------------------------------------------*/
#include <stdio.h>
#include "VLWrapperCpp"
using namespace VL;
class CEventHandler: public ISystemEH
{
public:
virtual void OnRealTimeInformation(RealTimeInformation info)
{
printf("OnRealTimeInformation (%d,%d)",
info.get_Unit().get_Id(),info.get_DetectorId());
switch(info.get_DetectorType())
{
case DT_SPEED:
printf("DT_SPEED\n");
break;
case DT_QUEUE:
printf("DT_QUEUE\n");
break;
case DT_PRESENCE:
printf("DT_PRESENCE\n");
break;
default:break;
}
}
Quercus Technologies
16