Chapter
5
Reference Manual
Ruler E
Ruler API
5
Ruler API
When developing the applications that analyze the measurement data from the Ruler, you
use the Ruler API for controlling the Ruler as well as retrieving the resulting profiles.
There are two different APIs installed with the development software for the Ruler:
Ruler C++ API
For use with C++
RulerNet API
For use with .Net
Both APIs contain the same functions and differ mainly in the syntax used. The biggest
difference is that the Ruler C++ API uses
set
and
get
methods to access the object
properties.
The Ruler APIs are based on the
Ruler
class, which is the main class associated with a
Ruler camera. In addition there are a number of support classes for geometry information
(
Point
,
FieldOfView
,
Rotation
and
Transformation
) and enumerations (error
and status codes).
When building an application using the RulerNet API, make sure that there is a reference
to the
RulerNet.dll
library. When using the Ruler C++ API, make sure that the program
is linked with the
icon2.lib
library.
This chapter describes the RulerNet API, and the examples are written in VB.Net. However,
the Ruler C++ API contains the same functions having the same names. An example
program showing how the Ruler C++ API is used can be found in Examples on page 48.
You can also explore the functions in the API with the RulerGUIExample program.
More detailed information on the Ruler APIs is found in the online help for the APIs, which
can be opened from the Start menu.
5.1
Connecting to the Camera
To connect to the Ruler camera from your application, do the following:
$
Create a
Ruler
object.
$
Set the
CameraAddress
property to the IP address of the camera.
$
Set the
ParameterFile
property to point out the parameter file that contains the
configuration that the camera should use. Parameter files are created with Ranger Stu-
dio.
$
Call the Ruler object’s
InitRuler()
method. The Ruler will then enter the
Stopped
state, which means that it is connected but not measuring.
' Create a new Ruler and give it a name
Dim
myRuler
As
New
Ruler.RulerNet("MyRuler")
' Set the IP address of the Ruler unit we want to connect to.
myRuler.CameraAddress = "192.168.0.43"
' Set the path to the parameter file to use.
myRuler.ParameterFile = "parameterFile.prm"
' Initialize the Ruler unit with the above settings.
Dim
res
As
ErrorCodes
res = myRuler.InitRuler()
40
SICK IVP • Industrial Sensors • www.sickivp.com • All rights reserved