Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 4 of 18

Qlarity-Based Terminal Programmer's Reference Manual: Chapter 1 Qlarity-based Terminal Software Fundamentals

Pages 13 to 18 of 134, from Qlarity-Based Terminal Programmer's Reference Manual

The original document is the PDF (1.5 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

Filed in the catalog under the QSI Corp QTERM-G70

Page 13

CHAPTER 1 QLARITY-BASED TERMINAL SOFTWARE FUNDAMENTALS

1.1 Qlarity-based Terminal Software Qlarity-based terminal software is divided into four major components, as shown below.

The following third-party components are used in the system software:

• The operating system is based on µC/OS, the Real Time Kernel, by Jean Labrosse.

• The FreeType library is used to render TrueType fonts. • The TCP/IP stack is based on code in the XINU operating system, written by Douglas Comer and others.

• The ZLIB library is used for compression / decompression. 1.1.2

User Application

The user application code consists of:

• Object templates • Global code and data • Object instances You can create a user application using Qlarity Foundry™, which runs in Windows®, or by writing a text description of the application in the Qlarity language (using a text editor). You then compile the design file, which converts it to an application binary file that can be downloaded to the terminal and stored in flash memory.

1.2 Qlarity Programming Language 1.1.1

System Software (Firmware)

The system software (firmware) is the terminal resident software that controls the Qlarity-based terminal. System software consists of the following:

• Operating system • Qlarity™ execution engine • Message handling system • Qlarity API functions (operating system calls)

The Qlarity language provides an object-based, event driven framework for the user application. The user application is a collection of objects and data that determine how a user will interact with the terminal at runtime. You design the application by selecting or creating “object templates” for the objects you want to use. Each object template has properties and methods that define the function of the object. You create “object instances” from the object templates by setting up the properties for each object in the user application. Code written in Qlarity defines the objects, their properties, and their functions.

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 14

2

QSI Qlarity-based Terminal Programmer’s Reference

Objects are the basic units of a Qlarity application. Each object template is an abstract representation of a user interface element such as text, a picture, a line, a window, a button, and so on. The abstract representation allows you to control each element by setting familiar properties of the element without worrying about the low level details of the actual manipulation. Objects are characterized by their properties (data) and methods (code). The properties and methods define what an object is and how it behaves. 1.2.1

Object Templates

An object template is defined by the properties and methods that it contains, as well as, those of the template it extends (if any). All object instances created from the same object template have the same number and type of properties (although the values stored in these properties may be different). Similarly, all object instances from the same template have the same list of methods (although each object may override the default functionality of a method with user-defined code).

The actual syntax for defining a new object template is covered in the chapter on “Advanced Design” in the Qlarity Foundry User’s Manual. 1.2.1.2 Creating Instances of an Object To create instances of an object, you give the instance a name and declare the name of the template from which the instance will be created. The properties of the object instance are those defined in the template. New properties may not be defined in the instance, but initial values for the instance may be assigned inside the instance declaration (using the init statement). The methods of the instance are also those defined in the template. You may override these methods by declaring a function inside the instance with the same name, parameters, and return value as the method defined in the template. This function replaces the template function for that instance only. The code for the override function may call the template method if desired. 1.2.2

Each object template can define default values for its properties and default code for its methods. When an object is instantiated (i.e., an object instance is created from the object template), any properties that are not explicitly given values retain their default values. Any method that is not explicitly overridden with user-defined code retains its default functionality. 1.2.1.1 Defining a New Object Template To define a new object template, you give the object a name, declare what type of object it will be (non-drawable, area, or container), and then add the properties and methods to the object definition. Variables that are created (using the dim statement) inside the object definition are object properties. These variables may be given a default initial value (using the init statement) that will be assigned to the variable if no initial value is given the object instance. Functions that are created inside the object definition are object methods. These methods may consist of ordinary functions, validation functions, or event handlers. Methods need not contain any actual code; however, a method must be declared in the object definition before it can be overridden in instances of that object template.

Object Types

There are three basic types of object templates: non-drawable objects, area objects, and container objects. Each of these object types has certain built-in functionality that helps the system software handle the object efficiently. 1.2.2.1 Non-Drawable Objects The non-drawable object type includes objects that do not directly interact with the terminal display. Examples include a keypad object (not a touch key object) and a serial communications object. Non-drawable objects have the following built-in data that is maintained by the system software and accessible through the Qlarity API (Application Programming Interface): NAME (character string) – the name of the object ENABLED (boolean) – indicates whether the object is eligible to process messages. PARENT (reference to container) – the parent container for the object Note that these attributes are NOT actual properties of the object. However, when using Qlarity to create an object, property variables that represent these attributes are often

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 15

QSI Qlarity-based Terminal Programmer’s Reference added to the object. Regardless of whether the object itself maintains properties analogous to these attributes, the attributes must be initialized and maintained by the object through Qlarity API function calls. The enabled status of an object can be modified through the Enable() API function, and the parent can be assigned with the Attach() API function. All Qlarity API functions are described in Chapter 4, “Qlarity API Function Reference”.

3 properties that best describe an object. There is no need to make the “built-in properties” or system software attributes visible outside the object. For example, a circle object might best be described with a center point and a radius. When these properties are set, code inside the object calculates the position and size from the property values and calls the Qlarity API functions that set the attributes. 1.2.2.3 Container Objects

1.2.2.2 Area Objects The area object type includes objects that directly interact with the terminal display by drawing something on the display and/or processing area-based messages. All area objects are rectangular. Examples include a text object, a bitmap object, and a touch key object. Area objects have the following built-in data that is maintained by the system software and accessible through the Qlarity API: NAME (character string) – the name of the object

The container object type is very similar to the area object type, except that container objects may “contain” other objects. Container objects can be used to create a hierarchical organization of objects in an application; thus they are central to the Qlarity messaging system. Each user application starts with a “root container.” Though invisible, it is the container in which you place all other objects. The following illustration shows a root container with several objects in it.

ENABLED (boolean) – indicates whether the object is eligible to process messages PARENT (reference to container) – the parent container for the object XPOSITION (integer) – the horizontal displacement (in pixels) from the origin of the object's parent container. Positive values indicate displacement to the right. YPOSITION (integer) – the vertical displacement (in pixels) from the origin of the object's parent container. Positive values indicate downward displacement. XSIZE (integer) – the width of the object in pixels YSIZE (integer) – the height of the object in pixels As with non-drawable objects, these attributes are not strictly properties of an object, but the object often defines analogous properties. In any event, every object of this type must initialize and maintain these attributes through Qlarity API function calls. The position and size of the object are established and can be modified through the Relocate() and Resize() API functions. The enabled status of an object can be modified through the Enable() API function, and the parent can be assigned with the Attach() API function. The separation of these system software attributes and the object properties provides you with the freedom to choose

In this illustration, two container objects plus another object are linked to the root container. In addition, each container object has objects linked to it, which are referred to as its “children.” The container object is the “parent.” If an object is not attached to a container object, it is linked to the root container by default. All container objects are rectangular. Examples might include a form object or a window object, which could serve as generic containers to organize objects into areas on the terminal display. Container type objects have the following built-in data that is maintained by the system software and may be set through the Qlarity API: NAME (character string) – the name of the object

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 16

4

QSI Qlarity-based Terminal Programmer’s Reference

ENABLED (boolean) – indicates whether the object is eligible to process messages event. Events are sent through the message handling system (see section 1.5, “Message Handling System”).

PARENT (reference to a container) – the parent container for the object

1.4 Z-Order

CHILDREN (ordered list of object references) – the list of objects attached to the container (maintained in Zorder, see section 1.4) XPOSITION (integer) – the horizontal displacement (in pixels) from the origin of the object's parent container. Positive values indicate displacement to the right. YPOSITION (integer) – the vertical displacement (in pixels) from the origin of the object's parent container. Positive values indicate downward displacement. XSIZE (integer) – the width of the object in pixels. YSIZE (integer) – the height of the object in pixels. ORIGINX (integer) – the x coordinate of the top left pixel in the container, relative to the parent container. ORIGINY (integer) – the y coordinate of the top left pixel in the container, relative to the parent container. These attributes are identical to the attributes of an area type object except for the list of children. The position and size of the container are accessible through the Relocate() and Resize() API functions. The enabled status of an object is accessible through the Enable() API function, and the parent and children attributes can be manipulated with the Attach() API function and the Z-order change functions.

1.3 Event Processing Qlarity is event-driven, which means that instead of one long, linear program being run that has constant control of the terminal, relatively short and independent sections of code are run in response to specific events. These code sections are called event handlers. Typical events include: a timer tick, a keypad press or release, a touch screen press or release, or a serial character receive. In Qlarity, event handlers can be defined as object methods or global functions that are registered to handle a given

Z-order describes “front to back” ordering (which is the same as the object hierarchy ordering). On a two-dimensional display, where X denotes left to right spacing and Y denotes top to bottom spacing, the Z axis extends out normal to the plane of the display. Thus, Z-ordering is the implied third dimension on the display, allowing objects to be “in front of” or “behind” other objects.

1.5 Message Handling System When an event occurs, the system software (firmware) and/ or hardware drivers generate a message indicating that the event has occurred. When a message is generated, it is passed through the message handling system located in the system software, which determines who gets the message and in what order the message is processed. An object must be enabled to process most messages. This also causes area and container objects with non-zero area to be drawn on the screen. Disabled containers do not process most messages and therefore cannot pass those messages to their children (attached objects). (Broadcast, tool, and direct user messages are processed by enabled or disabled objects.) Each message is processed to completion before the next message is examined and distributed. Processing of the current message is never preempted by another message, except for certain user messages. See Chapter 3, “Messages and Message Handler Prototypes” for more details. There are seven different types of events, classified by how each type is handled by the messaging system, as follows:

• Broadcast messages • Area messages • Draw messages • Registered messages • User messages • Direct messages • Tool messages (generated only in Qlarity Foundry)

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 17

QSI Qlarity-based Terminal Programmer’s Reference

1.5.1

Broadcast Messages

Broadcast messages are sent to all objects (regardless of enabled or disabled status) in Z-order. A message is first passed to the root container, which passes it to each of its children beginning with the front-most object (highest Zorder). When the message is passed to a container object, the container object first handles the message then passes it to each of its children beginning with the front-most object. In this manner, the message filters down through the object hierarchy until all objects have received the message.

5

If the handler in the registration list is an object method, the object owning the method is checked by the system software to ensure that it and every parent container (back to the root container) is enabled. If this condition is satisfied, the event handler is called. Because the root container cannot be disabled, global function event handlers are called without this check. If more than one object has registered for a given message, the objects receive the message in Z-order (as with area messages) with the root container (global handlers) receiving highest priority.

Refer to section 3.1 for a list of valid broadcast messages. Refer to section 3.4 for a list of valid registered messages. 1.5.2

Area Messages 1.5.5

Area messages are associated with a given area, or point, (X,Y coordinate) on the terminal display. The message is first passed to the root container, which checks for any enabled children that contain or overlap the area of the message. This checking is done in Z-order, starting with the front-most object. If a child is eligible to receive the message, the message is passed to the child. When the message is passed to a container object, it first handles the message then does a similar check for enabled children which contain or overlap the message area. In this manner, the message filters down through the object hierarchy until all eligible objects have received it.

User Messages

Although hardware events are generated by the system software, it is often desirable for the application to have the ability to send messages to indicate software events. Qlarity provides a mechanism to define user messages and a flexible set of Qlarity API functions to send these messages. User messages may be broadcast messages (object may be enabled or disabled), send messages (behave like area messages), or direct (object may be enabled or disabled). Refer to section 3.5 for details on defining and sending user messages and defining user message handlers.

Refer to section 3.2 for a list of valid area messages.

1.5.6

1.5.3

Direct messages are sent by the system to a specific object. These messages are enqueued in the message queue as are most other messages, but they are only passed to a single object when they are handled.

Draw Messages

A draw message is a type of area message that is processed in reverse Z-order, or back to front (see section 1.4, “ZOrder”). Refer to section 3.3 for more information on draw messages.

Refer to section 3.6 for more information on direct messages. 1.5.7

1.5.4

Direct Messages

Tool Messages

Registered Messages

Registered messages are associated with system events, such as a serial character receive or timer tick. Event handlers that process these messages are registered with the system software using registration functions in the Qlarity API. Because these events are usually handled by a small number of functions, registration avoids the need to filter the message through the entire object hierarchy.

Because objects may be completely defined by the user, Qlarity Foundry has no knowledge of the appearance or behavior of a given object. Therefore, the object itself must define its behavior for Qlarity Foundry development activities such as drag-and-drop, resize by dragging resize grips on a selected object, and so on. Tool messages are generated by the Qlarity Foundry software to tell an object that these activities are taking place. These messages are sent directly to the target object (i.e., they do not propagate through the

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 18

6

QSI Qlarity-based Terminal Programmer’s Reference object hierarchy). The object should have message handlers for these events to properly function in Qlarity Foundry. Refer to section 3.7 for a list of valid tool messages. 1.5.8

Handling Events

A message is handled by defining a global function or a function within an object that handles that event. Because information about the event is often passed as a parameter to the handler function, the handlers for a given message must follow a specific format (number and type of parameters and type of return value).

Often, when a message is handled by an object or function, it is desirable that the message be terminated (i.e., not passed on to other objects). This is indicated by the boolean return value of the message handler. If the handler returns true, the message is terminated. If the handler returns false, then the message is allowed to propagate to the next eligible object in the hierarchy. Some messages (the draw message in particular) cannot be terminated in this manner. If a global message handler is defined, it is considered to be a method of the root container. It therefore will be called before the message is passed to any other object.

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770