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 9 of 18

Qlarity-Based Terminal Programmer's Reference Manual: Chapter 4 Qlarity API Function Reference, pages 47 to 55

Pages 47 to 55 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 47

CHAPTER 4 QLARITY API FUNCTION REFERENCE

The Qlarity API (Application Programming Interface) is a library of functions that allow Qlarity applications to interact with the Qlarity-based hardware and perform common tasks that would be tedious or difficult to program in Qlarity. This chapter describes the available API functions, their parameters and return values, and the operations they perform.

4.1 Communications Interface The communications API functions use an enumerated type called “comm” to specify the communications resource or interface. Variables of type “comm” may be assigned the values “COM1” (for the primary serial interface), “COM2” (for the secondary serial interface) or a value may be obtained from a call to NetOpen(), which assigns access to the Ethernet interface. 4.1.1

Send

Syntax:

Parameters: {resource} The communications resource to transmit the data. {data} An array of any type that contains the data for transmission. {block} A boolean flag to select buffered or unbuffered transmission. Description: The transmit function sends the data in “{data}” to the communications interface specified by “{resource}.” If the “{block}” parameter is true, then the unit waits until the transmission has finished before returning from the API function. If “{block}” is false, then the system software buffers the data and returns immediately. Transmission takes place in the background. Using buffered output is generally a more efficient use of system resources and is recommended for most transmissions.

send(resource as comm, data[] as anytype)

4.1.3

SetBreak

Parameters: {resource} The communications resource to transmit the data.

Syntax:

{data} A byte array that contains the data for transmission.

Parameters:

setbreak(resource as comm, state as boolean)

{resource} The communications resource to change the state of.

Description: This function generates a MSG_COMM_TRANSMIT message. The data in “{data}” is passed to any handlers for the message. This function is useful when implementing a common transmission interface (the MSG_COMM_TRANSMIT handler) to perform protocolization, gather statistics, and so on.

{state} A boolean flag used to indicate whether a break state should begin. A value of “true” indicates to place the resource in break, where as “false” indicates that the break condition should be terminated. Description:

4.1.2

Transmit This function allows the user to set the break state of a communications port.

Syntax: transmit(resource as comm, data[] as -> reference? to anytype, block as boolean)

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

Page 48

36

QSI Qlarity-based Terminal Programmer’s Reference

4.1.4

GetComMessageSource

Syntax: getcommessagesource()returns comm

Description: This function returns the “comm” identifier for the current communications message. 4.1.5

NetOpen

Syntax: netopen(obj as objref, prot as -> netprotocol, localport as unibyte, -> foreignport as unibyte, ipaddr[] as -> reference? to byte)

Parameters: {obj} A reference to the object that will receive MSG_COMM_ACCEPT message (see below).

the

{prot} The protocol to be used for the connection (see below). {localport} The local port number to be used for TCP or UDP transmissions. {foreignport} The port number on the remote machine to be used for TCP or UDP transmissions. {ipaddr} A 4-byte array containing the IP address of the remote machine. Description: The NetOpen() function is used to establish an Ethernet communications channel. NetProtocol is an enumerated type with the following legal values: NET_UDP Use the User Datagram Protocol (UDP/IP) NET_TCP Use the Transmission Control Protocol (TCP/IP) NetOpen() issues the request to open a communications channel. When the channel is established, the communications resource (used to receive and transmit data) is passed by the system to the object referenced by “{obj}” by the system in a MSG_COMM_ACCEPT message. This communications resource is passed to the Send() and Transmit() API functions to indicate which network channel should be used for transmission. It is also used to register for MSG_COMM_ RECEIVE messages generated by the network channel. If “{foreignport}” is set to 0, the Qlarity-based terminal acts as a server listening for TCP connection requests or UDP datagrams on the port specified by “{localport}.” Connections or datagrams with any foreign port number are accepted on this local port. When a new connection or datagram (from a unique foreign port) is accepted, a network channel is allocated and passed to the application in a MSG_COMM_ ACCEPT message. If no TCP connection is established or UDP datagram received, the application continues to listen on the specified local port until the terminal is reset. NOTE: This is a deprecated method for starting network servers. Use the NetServerOpen() API function instead. Up to 64 channels (32 TCP channels) may be open at any given time. Channels may be released by calling NetClose(). Multicast Information Only: If you are opening a multicast channel (any class D IP address), the following information applies Calling NetOpen and specifying any class D IP address for the “{ipaddr}” parameter will open a multicast channel. You must specify NET_UDP as the protocol. TCP/IP does not support multicast communication. The “{foreignport}” parameter is only used to specify which port outgoing transmissions will be directed to. Incoming transmission's foreign port are not compared against this parameter. In other word, it doesn't matter what local port a device uses when transmitting to the multicast group. The “{localport}” parameter is normally used to filter incoming data. Generally, you will only receive data packets that are directed at the multicast group specified by “{ipaddr}” and directed to the port specified by “{localport}”. If you specify zero (0) for the local port, then

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

Page 49

QSI Qlarity-based Terminal Programmer’s Reference

ALL transmissions directed to the multicast group are received. You cannot transmit on a comm channel that was opened with a local port of zero. Incoming data on a multicast channel will be received via MSG_COMM_RECEIVE_MULTICAST messages. You should call RegisterMsgHandler as normal in a MSG_COMM_ACCEPT message to register for the MSG_COMM_RECEIVE_MULTICAST message. 4.1.6

NetServerOpen

Syntax: netserveropen(obj as objref, prot as -> netprotocol, localport as unibyte) -> returns servercomm

Parameters: {obj} A reference to the object that will receive MSG_COMM_ACCEPT messages for this server (see below).

37

This communications resource is used with the Send() and Transmit() API functions to indicate which network channel should be used for transmission. It is also used to register for MSG_COMM_RECEIVE messages generated by the network channel. Connections or datagrams with any foreign port number are accepted on this local port. When a new connection or datagram (from a unique foreign port) is accepted, a network channel is allocated and passed to the application in a MSG_COMM_ ACCEPT message. The application continues to listen on the specified local port until the terminal is reset. Up to 64 channels (32 TCP channels) may be open at any given time. Channels may be released by calling NetClose(). The server will continue to listen on the specified local port until it is closed by calling the NetServerClose() API function. 4.1.7

NetClose

Syntax: {prot} The protocol to be used for the connection (see below).

netclose(channel as comm)

Parameters: {localport} The local port number where the server will listen for datagrams (UDP) or connection requests (TCP).

{channel} The communications channel to be closed. Description:

Description: The NetServerOpen() function is used to start an Ethernet communications server listening on the port specified by localport. NetProtocol is an enumerated type with the following legal values:

This function closes the channel associated with the specified comm resource, which must have been obtained from a previous call to NetOpen(). 4.1.8

NetServerClose

NET_UDP Use the User Datagram Protocol (UDP/IP)

Syntax:

NET_TCP Use the Transmission Control Protocol (TCP/IP)

Parameters:

NetServerOpen() starts the server and returns a server communications resource of type “servercomm.” Connections or datagrams with any foreign port number are accepted on the local server port. When a new connection or datagram (from a unique foreign port) is accepted, a network communications resource is allocated and passed to the object referenced by “{obj}” in a MSG_COMM_ ACCEPT message.

netserverclose(channel as servercomm)

{channel} The communications channel to be closed. Description: This function closes the channel associated with the specified servercomm resource, which must have been obtained from a previous call to NetServerOpen().

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

Page 50

38

4.1.9

QSI Qlarity-based Terminal Programmer’s Reference

ChangePort

Syntax: changeport(channel as comm, {newport} as -> unibyte)

Parameters: {channel} The communications resource to modify. {newport} The new local port number for the communications resource. Description: This function modifies a UDP communications resource that was previously obtained from a call to NetOpen(). The local port number for the communications resource is changed to “{newport}.” ChangePort() can only be called for UDP resources; other resource types are not affected by this function. 4.1.10 TransmitUrgent Syntax: transmiturgent(channel as comm, data[] as -> reference? to anytype)

Parameters: {channel} The communications resource whose information will be returned. {prot} A reference to type “NetProtocol” that will receive “{channel}’s” protocol. {lport} A unibyte variable that will receive “{channel}’s” local port number. {fport} A unibyte variable that will receive “{channel}’s” foreign port number. {ipaddr} A byte array that will receive “{channel}’s” foreign IP address. Description: This function retrieves information about the “{channel}” communications resource. The protocol, local port number, foreign port number, and foreign IP address are stored in the reference parameters. 4.1.12 SetSerialRecvSize

Parameters: {channel} The TCP communications resource to transmit the data. {data} An array of any type that contains the data for urgent transmission via TCP.

Syntax: setserialrecvsize(res as comm, newsize as -> integer)

Parameters: {res} A serial communications resource (COM1 or COM2).

Description: This function sends the data in “{data}” via TCP urgent data mode to the TCP communications interface specified by “{channel}.” Transmission takes place in the background. 4.1.11 GetNetChannelInfo Syntax: getnetchannelinfo(channel as comm, prot -> as reference to netprotocol, lport as -> reference to unibyte, fport as reference -> to unibyte, ipaddr[] as reference to byte)

{newsize} The desired size for the receive buffer. Description: This function sets the size of the receive buffer for serial communications on the specified interface. The receive buffer is the maximum number of characters that can be received with a single MSG_COMM_RECEIVE message. A MSG_COMM_RECEIVE message is generated whenever (1) the receive buffer is full, or (2) the receive buffer is not empty and no characters have been received for the timeout period (see SetSerialTimeout()).

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

Page 51

QSI Qlarity-based Terminal Programmer’s Reference

4.1.13 SetSerialTimeout

4.1.15 ReadRTS

Syntax:

Syntax:

setserialtimeout(res as comm, newtimeout -> as integer)

readrts(resource as comm) returns boolean

39

Parameters: Parameters: {res} A serial communications resource (COM1 or COM2).

{resource} The communications resource from which to read. Description:

{newtimeout} The desired number of 20 ms intervals that should elapse before a timeout occurs (1 = 20ms). Description: This function sets the timeout period for serial communications on the specified interface. The timeout period is the maximum period of time between received characters before a MSG_COMM_RECEIVE message is generated. A MSG_COMM_RECEIVE message is generated whenever (1) the receive buffer is full (see SetSerialRecvSize()), or (2) the receive buffer is not empty and no characters have been received for the timeout period. Setting the timeout period to 0 disables timeout, meaning that MSG_COMM_ RECEIVE messages are only generated when the receive buffer is full. 4.1.14 SetCTS

This function is used to read the RTS line on a serial port of the Qlarity-based terminal if the line is available for use. (RTS/CTS flow control is only supported for the EIA-232 interface.) 4.1.16 SetDSR Syntax: setdsr(resource as comm, outValue as -> boolean)

Parameters: {resource} The communications resource to change the DSR line of. {outValue} The value to be placed on the DSR line. Description:

Syntax: setcts(resource as comm, outValue as -> boolean)

Parameters: {resource} The communications resource in which to change the CTS line. {outValue} The value to be placed on the CTS line.

This function is used to set the DSR line on a serial port of the Qlarity-based terminal, if that line is available for use. NOTE: The DSR line is not available on the Qlarity-based terminal primary or auxiliary serial ports. It may be available on expansion serial ports. 4.1.17 ReadDTR Syntax: readdtr(resource as comm) returns boolean

Description: This function is used to set the CTS line on a serial port of the Qlarity-based terminal if the line is available for use. (RTS/CTS flow control is only supported for the EIA-232 interface.)

Parameters: {resource} The communications resource from which to read. Description: This function is used to read the DTR line on a serial port of the Qlarity-based terminal, if that line is available for use.

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

Page 52

40

QSI Qlarity-based Terminal Programmer’s Reference

NOTE: The DTR line is not available on the Qlarity-based terminal primary or auxiliary serial ports. It may be available on expansion serial ports. 4.1.18 Read DCD is for transmission only. No response to the datagram will be received unless the appropriate channel has been established.

4.2 Registering for Messages 4.2.1

Syntax:

RegisterMsgHandler readdcd(resource as comm) returns boolean

Syntax:

Parameters:

registermsghandler(obj as objref, msgnum -> as message, msgparm as unibyte)

{resource} The communications resource from which to read.

Parameters:

Description:

{obj} The object registering for the message.

This function is used to read the DCD (carrier detect) line on a serial port of the Qlarity-based terminal, if that line is available for use.

{msgnum} The name of the message (e.g., MSG_TIMETICK).

4.1.19 NetSendDatagram Syntax: netsenddatagram(localport as unibyte, -> foreignport as unibyte, ipaddr[] as -> reference? to byte, data[] as reference? -> to byte)

{msgparm} A parameter whose meaning depends on the message (see section 3.4). Description:

Parameters:

This function registers an object to receive registered messages. After this call, the object passed in “{obj}” is eligible to receive “{msgnum}” messages if it has an enabled path to root.

{localport} The local port number to be used for the UDP datagram.

4.2.2

UnregisterMsgHandler

{foreignport} The port number on the remote machine to be used for the UDP datagram.

Syntax:

{ipaddr} A 4-byte array containing the IP address of the remote machine.

Parameters:

{data} An array of bytes that contains the data for transmission in the datagram.

{msgnum} The name of the message (e.g. MSG_-TIMETICK).

Description: The NetSendDatagram() function is used to send a single datagram on the network using the User Datagram Protocol (UDP/IP). This function allows a datagram to be transmitted without opening a network channel (i.e. with the NetOpen API function). Both "{foreignport}" and "{localport}" must be set to non-zero values. This function unregistermsghandler(obj as objref, -> msgnum as message, msgparm as unibyte)

{obj} The object registering for the message.

{msgparm} A parameter whose meaning depends on the message (see section 3.4). Description: This function unregisters the “{obj}” object so that it will no longer receive “{msgnum}” messages.

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

Page 53

QSI Qlarity-based Terminal Programmer’s Reference

4.2.3

RegisterKey

4.3.2

41

GetObjProp

Syntax:

Syntax:

registerkey(obj as objref, keycode as -> unibyte)

getobjprop(obj as objref, name[] as -> reference? to byte) returns string

Parameters:

Parameters:

{obj} The object registering for the message.

{obj} A reference to the object with the desired property.

{keycode} The keycode that causes a message to be generated for the object.

{name} A string containing the name of the property to retrieve. Description:

Description: This function registers an object to receive MSG_KEY_DOWN, MSG_KEY_PRESS, and MSG_KEY _RELEASE messages when the keyboard or keypad key associated with “{keycode}” is activated. A list of valid keycodes is included in Appendix A.

This function returns the value for the desired property converted to a string. The returned value is converted to a string (identical to calling the API function Str() on the property). 4.3.3

SetObjProp

Syntax: In addition, there are two special keycodes not directly associated with specific keys. The KEY_ANY keycode registers the object to receive key messages for all keys. The KEY_NONE keycode effectively unregisters the object for key messages. A given object may only be registered for one keycode value. Each call to RegisterKey() preempts any keycode that was previously registered for the “{obj}” object.

setobjprop(obj as objref, name[] as -> reference? to byte, {value}[] as -> reference? to byte)

Parameters {obj} A reference to the object with the desired property. {name} A string containing the name of the property to set.

4.3 Manipulating Objects 4.3.1

GetObjref

{value} The new value for the property converted to a string.

Syntax:

Description:

getobjref(name}[] as reference? to byte) -> returns objref

This functions converts the string in “{value}” to the correct data type for the specified property then assigns that value to the property (refer to the “Val” function for conversion rules; see section 4.10.2).

Parameters: {name} A string (byte array) that contains the name of the desired object.

4.3.4

Enable

Syntax: Description:

enable(obj as objref, flag as boolean)

This function takes the name of an object and returns an objref to the object.

Parameters: {obj} A reference to the object to be enabled/disabled.

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

Page 54

42

QSI Qlarity-based Terminal Programmer’s Reference

{flag} A boolean flag containing the desired status. A value of “true” enables the object, and a value of “false” disables it.

{eval} The type of information desired. Description:

Description: This function enables or disables an object according to the “{flag}” parameter. An object must be enabled to receive messages and appear on the display. 4.3.5

GetContainer

Syntax: getcontainer(obj as objref) returns objref

This function returns the status of the object “{obj}” based on the information desired (indicated by “{eval}”). Legal values for “{eval}” are: GET_ENABLED Request the enabled status of an object. GET_ZENABLED Request whether the object’s parents are enabled to root (does not include the object itself).

Parameters: {obj} A reference to a child object. Description: This function returns a reference to the parent container of the “{obj}” object. 4.3.6

GetChildren

Syntax: getchildren(contobj as objref) returns -> objref[]

Parameters: {contobj} A reference to a container type object. Description:

4.3.8

GetPosInfo

Syntax: getposinfo(obj as objref, pval as -> position_info) returns integer

Parameters: {obj} The object for which the position information is to be returned. {pval} The type of information desired. Description: This function returns the requested position information for “{obj}” based on the information desired (indicated by “{pval}”). Legal values for “{pval}” are:

This function returns an array containing references to all of the object’s direct children (all objects whose parent is “{contobj}”). The children are returned in Z-order.

GET_X The current x-position of the object (relative to its parent).

4.3.7

GET_Y The current y-position of the object (relative to its parent).

GetEnableInfo

Syntax: getenableinfo(obj as objref, eval as -> enable_info) returns boolean

GET_WIDTH The current width of the object.

Parameters: {obj} The object for which the status information is to be returned.

GET_HEIGHT The current height of the object. GET_ORIGIN_X The current origin x value (for a container only).

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

Page 55

QSI Qlarity-based Terminal Programmer’s Reference

GET_ORIGIN_Y The current origin y value (for a container only).

4.4.1

43

Attach

Syntax: GET_XGLOBAL The current x-position of the object (top, left of display: 0,0). GET_YGLOBAL The current y-position of the object (top, left of display: 0,0) 4.3.9

SetOrigin attach(obj as objref, parent as objref)

Parameters: {obj} A reference to the object that will be attached. {parent} A reference to the new parent object. Description:

Syntax: setorigin(cont as objref, originX as -> integer, originY as integer)

Parameters: {cont} The container for which to set the origin. {originX} The x coordinate of the top left pixel in the container, relative to the parent container.

This function attaches an object to a container. The object being attached is placed in front of any other objects already attached to the parent. If the object is already attached to the parent, it will be moved to the top of the Z-order. 4.4.2

SendtoFront

Syntax: sendtofront(obj as objref)

Parameters:

{originY} The y coordinate of the top left pixel in the container, relative to the parent container.

{obj} A reference to the object to be moved in Z-order.

Description:

This function moves the object to the front of the list of children of the object's parent. If the object is the only child of its parent, or is already at the front, this has no effect.

This function sets the origin of the container so that the upper left pixel of the container has the coordinates “{originX},{originY}” (with a default value of 0,0). The “{originX}” and “{originY}” coordinates are relative to the container itself. This causes all objects drawn on the container to be shifted appropriately. This does not change the manner in which the container’s background is drawn.

4.4 Manipulating Z-Order These functions change the Z-order of objects in the object hierarchy. Because the message handling system is highly dependent on Z-order, all changes to Z-order requested by these functions are postponed until processing of the current message is complete. Z-order changes are then executed in the order in which they were requested.

Description:

4.4.3

SendtoBack

Syntax: sendtoback(obj as objref)

Parameters: {obj} A reference to the object to be moved in Z-order. Description: This function moves the object to the back of the list of children for the object's parent. If the object is the only child of its parent, or is already at the back, this function has no effect.

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