via commands. Commands can be executed
locally
or re-
motely
(i.e.
across a network). Network access to a device
and its commands is provided by an application pro-
grammers interface using a remote procedure call.
3.2 The Device
The device is at the heart of the device server model. It
represents a level of abstraction which previously did not
exist. A device can be a physical piece of hardware
(e.g.
an
interlock bit), an
ensemble
of hardware (e.g. a screen at-
tached to a stepper motor), a logical device (e.g. a taper),
or a combination of all these (e.g. a storage ring). Each
device has a unique name. At the ESRF a three field name
space (consisting of DOMAIN/FAMILY/MEMBER)
has been adopted.
The decision of what level of abstraction a device rep-
resents depends on the requirements of the clients. At the
ESRF these are the machine physicists. Devices should
model the clients view of the problem as closely as possi-
ble,
Hardware dependencies should be hidden behind the
device abstraction. For example if a corrector consists of
three independant powersupplies the client (assuming she
is a machine physicist) should only see a single device —
the corrector, and not three independant devices.
All devices are treated as having state. Each device
has a list of commands which it understands. Before
any command can be executed the state machine gets
checked to see if the command can be executed in the
present state. The commands and the state machine are
implemented in the device's class.
3.3 The Server
Another integral part of the device server model is the
server concept. The server is a process whose main task is
to offer one or many service(s) for
clients
who want to take
advantage
thereof.
The server spends most of its time in a
wait-loop
waiting for clients to demand its service(s). This
division of labour is known as the client-server concept.
It
exists in
different flavours and is very common in modern
operating systems.
The adoption of this concept in the device server model
has certain implications. The server in the device server
model is there to serve one or many device(s) i.e. there
is one server per device but there can be many devices
per server. The exact configuration depends on the hard-
ware organisation, CPU charge, and the available memory.
The fact that there can be many devices per server means
that a single device should not monopolise the server for
more than a pre-defined amount of time. Otherwise the
server is blocked and new or existing clients will not be
able to connect to the same or other devices served by that
server. The server waits for clients by listening at a certain
network address. The mechanism for doing this is imple-
mented by a remote procedure call. At the ESRF the
network addresses are determined dynamically (at server
startup time) and then stored in a
database.
The first time
a client connects to a server it goes to the database to re-
trieve the server's address, after which it communicates
directly with the server.
3.4 Objects In C
The use of objects and classes in the device server model
necessitates appropiate OOP tools. The natural choice
would have been to use one of the many OOP languages
which are available on the market today. If possible one
for which a standard exists or will exist (e.g. C++). The
choice of a language is not independant of the develop-
ment evironment however. The language chosen has to be
fully compatible with the development environment. At
the ESRF the device access and control development envi-
ronment consists of OS9, HP-UX, SunOS and the SUN
NFS/RPC. Unfortunately there is no commercially
avail-
able OOP language compatible with this environment.
The only language which supports the above environment
is C. In order to use OOP techniques it was therefore
necessary to develop a methodology in C, called Objects
In C (from here on OIC). The methodology developed is
implemented entirely in C and is closely modelled on the
widget programming model (ref. [3]).
OIC implements each class as a structure in C. Class
hierarchies are supported by subdividing a class structure
into partial structures. Each partial structure representing
a super- or a sub-class. Each class requires a minimum of
three files :
• a private include file describing the class and object
structures,
• a public include file defining the class and object
types as pointers to structures and the class as an
external pointer to the class structure,
• a source code
file
which contains the code implement-
ing the class.
The private include file is used to define constants and/or
variables which should not be visible to the outside world
(the inverse being true for the public include file). AH
functions implementing the class are defined to have static
scope in C. This means that they cannot be accessed di-
rectly by any other classes or applications - they are only
accessible via the method-finder or as commands. This
enforces code-hiding and reinforces the concept of en-
capsulation - a way of reducing coupling between soft-
ware modules and making them immune to changes in
the class implementation.
OIC implements an explicit method-finder. The
method-finder is used
to
search for methods in a class or hi-
erarchy of
classes.
The method-finder enables methods to
be inherited. Two special versions of the method-finder
exist for creating and for deleting objects.
Objects are also implemented as structures. Each object
has a pointer to its class structure. This means that class
515