AutoGraL: Java API for configurable electronic dashboards - wseas.us

4 downloads 11129 Views 118KB Size Report
dashboards with the advantages of software programming. ... automotive dashboard, software components, Object Oriented programming, ..... Computer, Vol.
AutoGraL: Java API for configurable electronic dashboards ALESSANDRO DE GLORIA, FRANCESCO BELLOTTI and ALESSANDRO VILLAMAINA DIBE - Department of Electronic and Biophysical Engineering University of Genoa Via Opera Pia 11a, 16145 ITALY

Abstract: - Future generation cars will provide a wide range of services to driver and passengers. An important role for the success of such services will be played by the user interface. In view of this, we have realized AutoGraL, a set of Java graphics APIs for developing configurable automotive dashboards. The paper describes in detail the library, that provides the instruments to join the familiar analog look of traditional dashboards with the advantages of software programming. Key-Words: Java, API, graphics, automotive dashboard, software components, Object Oriented programming, software documentation. detail the AutoGraL APIs, while section 4 shows how to develop an autoGraL application. The conclusions of the work are reported in the final section.

1 Introduction The automotive market of the next few years will be characterized by a wide number of services offered to drivers and passengers [1, 2]. The services will range from safety systems to personal communication, from entertainment to provision of location-aware information. All this amount of services and information will have to be provided without distracting the driver from her/his main goal, that is to safely drive the car. On the contrary, novel systems will have to enhance the driving conditions by providing drivers with the right information at the right moment. These simple considerations suggest the importance that the Human Machine Interface (HMI) modules will play in the future generation cars. In this paper we present the AutoGraL (Automotive Graphics Library) Java package, a library of graphics objects for automotive dashboards. These objects are directly related to the corresponding objects of traditional dashboards, like speedometers, odometers, light indicators, etc. They maintain the same analog look but live within a software application able to manage various dashboard configurations. As mentioned before, the display of variables characterizing the current state of the car (e.g. speed, fuel consumption, etc.) will probably not be the only service provided by the new dashboard interface. In view of this the AutoGraL classes have been thought and designed as components usable to build more complex structures. The remainder of the package is organized as follows. section 2 presents the motivations for implementing a library of Java dashboard APIs. Section 3 describes in

2 Why a Java library? The high cost and complexity of the today software projects have fostered the adoption of development techniques aimed at making the best use of the existing software resources. The Object Oriented (OO) technology has allowed significant advances by promoting the concepts of code re-usability and extension [3]. AutoGraL, implemented in the Java purely OO language [4, 5, 6], introduces the OO technology in the development of automotive dashboards. In fact, it provides a set of APIs (Application Programming Interfaces) that implement the functionality (and some extensions) provided by the current instrument panels. Although the implemented services are numerous and general, the classes can be further extended for full customization. An important advantage of using the library consists in the simple relationship between the software objects and their counterpart in traditional dashboards, like speedometers, fuel gauges, etc. This relationship has been strengthened by the adoption of an accurate choice of the names of the classes and of the methods in order to make the software package meet the actual technical background of technicians involved in the automotive sector. We think that this feature has an important impact in the whole cycle of life of the software, from the development to the maintenance. In fact, code is more comprehensible, facilitating debugging and production/exploitation of the

1

documentation, which is embedded in the source code and can be extracted in html pages by the JavaDoc tool [7].

Void drawObject(Graphics2D g2) The paint routine for this object. Counter getCounter(int index) Gets the specified counter. Pointer getPointer(int index) Gets the specified pointer. void LoadBackground(String name) Loads a background image for the dial.

3 The AutoGraL APIs The package is logically divided into two main sets of classes, those that implement concrete objects displayable on an electronic dashboard and those that provide computational services and/or data structures used by the dashboard objects. The whole class hierarchy is listed below, where indentation means subclassing.

void RemoveAllCounters() Removes all the counters. void RemoveAllPointers() Removes all the pointers. void RemoveCounterAt(int index) Removes the counter specified by the index. void RemovePointerAt(int index) Removes the pointer specified by the index. void SetValue(int value) Sets the value of the physical variable displayed through this dial. void SetSize(int width, int height) Stretches the background image of the dial to the specified size, changes the position of the pointers accordingly and of the counters too. Tab.1 Public methods of the Dial class.

A snapshot of a sample dashboard application is reported in Fig. 1, as an example of the objects belonging to the AutoGraL classes. The remainder of this section is devoted to the description of some of the most interesting aspects of the classes. Indicator

FilledGauge

Indicator

Pointer

Counter

Dial

Fig. 1 - Snapshot of a dashboard application with association of instruments to AutoGraL classes

Pointers can be implemented both as raster polygons (i.e. specifying their shapes by giving the number and the coordinates of their vertices) or as bitmap images (i.e. specifying a vector of image files containing the pointers). In general, AutoGraL provides support for all the most diffused formats, such as GIF, JPG, BMP and PNG. The utilisation of images allows the visualisation of the most various shapes, at the cost of performance issues due to image handling and of memory issues related to the large number of images to be stored. Simple 3D effects can be obtained also using raster pointers. For instance, the TriangularPointer class implements an algorithm that shades one half of the pointer according to its orientation versus the vertical position. The formula used to compute the shaded colour is:

The Dial class emulates the pointer-based analog display of measured inputs (e.g. speed, rpm, fuel consumption etc). One dial can have one or more pointers. Each pointer has a method called SetValue, which is responsible for updating the orientation of a pointer inside the dial according to the value of the read input. Methods are provided to dynamically change the look of dials. Dials can also contain Counter objects, which resemble a mechanical odometer. These objects are directly associated with the dial in order to manage the eventual overlapping with pointers. The main public methods of the Dial class are reported in Tab.1, in the typical Java documentation format.

  α   C e = C s ⋅ 1 −   π + ξ    

Dial - method summary void addCounter(Counter c) Adds a counter to this dial. Void addPointer(Pointer p) Adds a pointer to the vector of pointers of this Dial.

where Ce is the computed colour component, Cs is the pointer’s colour, α is the angle of the pointer versus the vertical position and ξ is the parameter that sets the intensity of the shading effect.

2

The methods that manage the orientation and/or position of the pointer according to the value of the read input physical variable are provided by the Scale support class. This class is declared as protected, since programmers should not directly access its methods. The above mentioned Counter class provides functionality for displaying any sequence of numbers. Its main utilization is for implementing global and partial odometers. the typical analog effect of digits rotating over a cylinder is achieved by using a 10x10 matrix of images of the size of one digit. Each row (one for each digit) contains the current and the previous digit, in ten increasing levels of vertical shift. The matrix is automatically generated from an image of ten vertical digits provided by the programmer at the object’s creation and the images to be displayed are selected according to the corresponding measured input value. Indicators are implemented as temporised sequences of images, inserted in an array. As an example, Fig. 2 represents the core data structure of an oil icon represented as an animated indicator.

Adds an AnimationFrame object to the vector of frames. void drawObject(Graphics2D g2) The paint routine for this object. boolean getValue() Gets the state of the indicator:on or off (true or false). void InsertFrameAt(int index, String filename, long time, boolean loopFlag) Inserts a new frame in the vector of frames at the specified position. void loadOffStateImage(String filename) Loads a new off-state image. void removeFrameAt(int index) Removes the frame from the vector at the specified position. void setValue(boolean val) Sets the state of the indicator. Tab.2 Public methods of the Indicator class.

AnimationFrame objects are associated to Indicator objects, providing low-level support for time-dependent sequencing of images. This class is not directly accessible by programmers, but provides methods that are used within the Indicator class.

“off-state” image

Starting frame for the “on-state” images

AnimationFrame - method summary getImage() Gets the image of this frame. GetLoopFlag() Gets the loopFlag of this frame. getTime() Gets the duration of this frame. setImage(Image image) Sets the image used to draw this frame. SetLoopFlag(boolean loopFlag) Decides whether this frame must be painted every time it occours or only the first time. Protected setTime(long time) void Sets how long this frame must be painted on the screen before the next one is displayed. Tab.3 Methods of the AnimationFrame class. protected Image protected boolean Protected long Protected void Protected void

Fig. 2 – Structure of an Indicator object. Each frame of the animation is represented by an AnimationFrame object.

The array contains an off image and a set of images that can be temporised in order to display a loop or a transient animation for the on state. The images used to draw the current state of the indicator are stored in a vector. The first element in the vector is relative to the off-state image; the other elements are relative to the single frames of the animation corresponding to the on-state. This allows the realization of general animations. A vector of two elements implements the functionality of a simple indicator with an image for the on-state and another for the off-state. A blinking indicator can be built adding to the first two images a third one equal to the first one.

FilledGauge class implements the behaviour of indicators consisting of a background image overlapped by a geometric shape of variable size according to the value of the measured input. Rectangular and bow shapes, painted with linear colour gradient are supported. The graphic properties

Indicator - method summary void

addFrame(String filename, long time, boolean loopFlag)

3

like the behavioural ones can be changed runtime with the appropriate methods calls.

the loadCharSet method. void AddString(String str, String font, int style, int size, Color color, int x, int y) Adds a string to the vector of strings that must be drawn in the specified position using the specified font, style, size and color. void drawObject(Graphics2D g2) The paint routine for this object. void loadBackground(String name) Loads a background image for the text area. void loadCharSet(String name, int charHeight, int[] charWidth, String chars) Loads an image containing a character set. void removeAllStrings() Removes all the strings added with previous addString method calls. void removeStringAt(int index) Removes the string specified by the index. void setSize(int width, int height) Stretches the background image to the specified size. Tab.5 Public methods of the TextArea class.

FilledGauge - method summary void void

void

void

void

void void

void

void void

DrawObject(Graphics2D g2) The paint routine for this object. LoadBackground(String name) Loads a background image for the filled gauge. SetArcStrokeWidth(int arcStrokeWidth) Sets the width of the stroke of the filled arc shape. setEdges(float top, float left, float bottom, float right) Sets the bounding box of the shape to be filled. The box is specified with the distances from the edges of this filled gauge. setFillColor(Color startColor, Color endColor) Sets the filling color for the shape. setOrigin(int ox, int oy) Sets the origin to the specified coordinates. setScale(float startValue, float endValue) Sets the the scale of a rectangular shaped filled gauge. setScale(float startAngle, float endAngle, float startValue, float endValue) Sets the scale of a thick arc shaped filled gauge. setShape(int shapeType) Sets the shape of the filled gauge.

Menu class extends the text area introducing the possibility for the driver of browsing menus and selecting items. Like strings, items can be displayed with fonts or with a character set made of little images. Furthermore, selected items are highlighted with background images drawn behind the strings or with coloured rectangles. Interaction is accomplished by means of the five elementary commands (up, down, right, left, select).

setSize(int width, int height) Stretches the whole instrument (also the filled shape) to the specified size.

Menu - method summary protected void

void

setValue(float val) Sets the value to be displayed by the instrument. Tab.4 Public methods of the FilledGauge class.

void

TextArea is a region where message strings can be displayed using fonts or character sets constituted of little images. Different character sets can be loaded for a single text area but only one can be associated to the string drawn.

void

TextArea - method summary void

AddString(String str, int x, int y, int charSet) Adds a string to the vector of strings that must be drawn in the specified position using the specified character set previously loaded with

4

addItem(String item, RenderableString rs) Adds the RenderableString object to the vector associated to the specified item addItem(String item, String str, int x, int y, int charSet) Adds an item to the vector of items that must be drawn in the specified position using the specified character set. addItem(String item, String str, int x, int y, int normalCharSet, int hilightedCharSet) Adds an item to the vector of items that must be drawn in the specified position using the specified character sets according to the hilighing state of the

item. void addItem(String item, String str, int x, int y, int normalCharSet, String filename, int imageX, int imageY) Adds an item to the vector of items that must be drawn in the specified position using the specified character set and hilighting image. void addItem(String item, String str, String font, int style, int size, Color color, int x, int y) Adds an item to the vector of items that must be drawn in the specified position using the specified font, style, size and color. void addItem(String item, String str, String font, int style, int size, Color color, int x, int y, String filename, int imageX, int imageY) Adds an item to the vector of items that must be drawn in the specified position using the specified font, style, size and color and hilighting image. void drawObject(Graphics2D g2) The paint routine for this object. void EnterSubMenu() Enters the menu corresponding to the current item. protected getCurrentItem(String item) RenderableString Gets the RenderableString object from the vector specified by the string index. protected GetCurrentVector(String item) Vector Gets the vector specified by the string index. protected GetFirstSelectableItem(Vector v) String Gets the first selectable item. void goParentMenu() Returns to the parent menu. void hilightNextItem() Hilights the next item. void hilightPreviousItem() Hilights the previous item. protected isSelectable(String item) boolean Finds whether the specified item is selectable. void removeItem(String item) Removes the specified item. void setCurrentItem(String item) Hilights the specified item setting it the current item for subsequent hilightNextItem or hilightPreviousItem

void

SetHilightColor(Color color) Sets the color of the hilighting rectangle of every item. void setHilightColor(String item, Color color) Sets the color of the hilighting rectangle of the specified item. void SetItemSelectability(String item, boolean selectability) Sets the selectability of the specified item. Tab.6 Methods of the Menu class.

4 Using AutoGraL An application which makes use of the AutoGraL API should run on an in-vehicle embedded system and should display the dashboard on a LCD colour display, substitutive of the traditional mechanical instruments. The management of an electronic dashboard using AutoGraL can be logically divided into two different steps: • Objects Initialisation: the shapes and the initial position of every instrument are defined, together with the rules that state their behaviour; • Values Assignment and State Change: the dashboard application receives input from the vehicle electronics, and change objects' fields accordingly; the instruments, on the base of their behavioural rules, rotate their pointers, light their indicators, change their text areas and colors, appear, disappear, magnify, shrink or change their position inside the dashboard environment. The following lines report a basic example of utilisation of the APIs. First an object is instantiated from its class, in this case Dial: Dial tachometer = new Dial("Img/tachimetro.png", 67, 27);

In this case the background image and the position in the dashboard reference system are specified. Then, the object is given its initial values, like: tachometer.addCounter(newCounter("Img/numbers.gif", 178, 127));

In the main loop of the application, first the state of the object is updated according to the read physical values.

5

tachometer.setValue(CarData.speed);

where CarData is the record written by the carsignal generator. Then, the drawObject() methods of the various visible objects: tachometer.drawObject(g2);

where g2 is the parameter representing the graphics context. The classes have been tested in laboratory in a carlike environment, with a signal generator that sends values over a serial cable. These values drive the AutoGraL applications.

ACKNOWLEDGMENT This research has been developed in collaboration with Robert Bosch Gmbh, Fiat Research Center and ST Microelectronics in the ACTIVE project, cofounded by the European Union within the 5th Framework Programme. We acknowledge the work of Marco Risso, who has co-developed the AutoGraL package. References: [1]A. Jameel, M. Stuempfle, D.Jiang and A. Fuchs, “Web on Wheels: Toward Internet-Enabled Cars”, Computer, Vol. 31, No. 1, January 1998, pp. 6976. [2] T. Lewis and B. C. Fuller, “Fast-Lane Browsers Put the Web on Wheels”, Computer, Vol. 32, No. 1, January 1999, pp. 141-144. [3]G. Booch, Object Oriented Design with Applications, The Benjamin/Cummings Publishing Company, Inc., 1991. [4]B. Eckel, Thinking in Java, Prentice Hall, 1998 [5]K. Arnold, J. Gosling, The Java Programming Language, Addison-Wesley, 1996. [6]J. Gosling, B. Joy, G. Steele, The Java Language Specification, Addison-Wesley, 1996 [7]http://java.sun.com/docs/javadoc-paper.html. Javadoc is available on line at http://java.sun.com/ products/jdk/1.3/docs/tooldocs/javadoc/

6