Python MAEDaemon

Index Home MAE Python Interface > Python Index > Python MAEDaemon

Module MAEDaemon
Public Properties
Public Methods
setfield(device, table, field, value)
settext(device, text, style)
write(device, text, style)
writeln(device, text, style)
writewiki(device, text)
addhotspot(device, text, action, cbdata, style)
addhinttext(device, text)
button(device, text, action, cbdata)
format(device, control, on)
newregion(device, newtag, styleName, size)
style(device, styleName)
attention(device, text)
selection(device, value)
chat(device, from, text)
clear(device)
show(device)
hide(device)
newtable(device, tableName, tableType, rows, columns)
newlist(device, name, items)
record(device, recordName, idmap, values, overwrite)
report(device, reportName, table, table_id)
prompt(device, query, value, promptType, xid, style)
select(device, option0, options, xid, selected)
checkbox(device, query, value, xid, style)
textarea(device, text, xid, style, saveLabel)
form(device, formName, vars, xid)
screen(device, name, rows, columns)
scrattr(device, attributes)
scrchar(device, row, column, letter, amount)
setmenu(device, menu, option, command)
unsetmenu(device, menu, option)
setwindow(device, windowName)
unsetwindow(device, windowName)
setindex(device, indexName)
unsetindex(device, indexName)
newsection(device, title, sectionType, newtag)
collapseSection(device)
expandSection(device)
displayImage(device, imageName, image_type, action, cbdata, append)
displayImage(device, image_id, action, cbdata, append)
playAudio(device, audioName)
download(device, query, fileclass, xid)
upload(device, imageName, image_type)
imagelibpre(device, id)
bufimage(device, imageName, image_type, width, height, size, binary, chunk, totalChunks, chunksize, data)
setvar(device, variable, value)
getvar(device, variable, value)
run(device, appname, startParams)
stop(device)
userAccountChange(userId, action, value)
registerApp(appmode, apptype, action, contentInputType, contentOutputType, operations, msgchannel, privatePages)
startraw(device, statusCode, contentType)
writeraw(device, text, isBinary)
closeraw(device)
send(request, params)
simpleEncrypt(text, offset)
simpleEncryptLike(text, likeOtherText)
isSimpleEncrypted(text)
simpleDecrypt(text)
prompt(device, question, prefillAnswer, queryType, cbapp, cbtag, cbdata, style)
select(device, question, choices, cbtag, cbdata, defaultValue)
textarea(device, question, origText, cbtag, cbdata, style, saveButtonLabel)
checkbox(device, question, cbtag, cbdata, defaultValue, style)
form(device, formName, formDefaults, cbtag, cbdata)
run(device, appname, appparams)
download(device, query, cbtag, cbdata, fileclass)
registerMenu(device, menuname, menuoption, action)
registerKey(device, keystroke, action)
registerHotspot(device, region, action)
redirectHotspot(device, region, otherapp)
registerMouse(device, region, action)
registerCommand(device, cmd, cmdparams)
send(request, params)
htmlize(url)
urlize(url)
sendImage(device, iid, errmsg, action, cbdata)
saveToImageLib(device, filename, filetype, filecontent, xid, category)
saveToImageLib(image_id, filename, filetype, filecontent, category)
updateImageLib(image_id)
saveToImageLib(image_id, filecontent)
setImageCategory(image_id, category)
setImageName(image_id, name)
setImageType(image_id, type)
newImage(table, id)
send(request, params)
response(device, xid, text)
chat(device, text)
cmd(device, cmd)
key(device, key)
click(device)
mouse(device, direction, x, y, action, cbdata)
hotspot(device, action, cbdata)
upload(device, fileclass, filetype, imagelibid, xid)
refresh(device)
select(device, value)
online(device, appparams)
withdraw(device)
timeout(device)
send(request, params)
open(name, mode, cbtag, cbdata)
putchar(ioId, c, ioChannel)
write(ioId, text, ioChannel)
write(ioId, data, ioChannel)
seek(ioId, offset, ioChannel)
lock(ioId, exclusive, wait, ioChannel)
unlock(ioId, exclusive, wait, ioChannel)
close(ioId, ioChannel)
fsverify(node, ioChannel)
fsreview(dirResourceId, ioChannel)
fsconfirm(node, size)
fsupdate(node, change, size)
ls(maepath)
stat(maepathandfilename, statbuf)
send(request, params, channel)
Class Cache
Public Methods
__init__(self, objType, size)
__del__(self)
add(self, newKey, newOne)
removeKey(self, key)
remove(self, pos)
findPos(self, searchKey, fetchIfMissing)
exists(self, searchKey)
get(self, key)
__getitem__(self, pos)
__len__(self)
Class Datastore
Summary
Public Properties
Public Methods
__init__(self, tableName)
valid(self)
status(self)
statusOK(self)
isOpen(self)
statusMsg(self)
fieldNameToType(self, name)
fieldTypeToName(self, fieldtype)
errorMsg(self, rcToGetMsgFor)
open(self, tableName)
select(self, tableName)
connected(self)
pack(self)
close(self, specifiedTable)
getTableList(self)
addField(self, fieldName, type, size, table, isIndex)
getFieldId(self, fieldName, table)
addFieldEnum(self, fieldName, enumName, enumId, table)
getFieldType(self, fieldName, table)
addRecord(self, data, recno, table)
deleteRecord(self, recno, table)
lockRecord(self, recno, table)
unlockRecord(self, recno, table)
clearField(self, recno, fieldName, table)
setValue(self, recno, fieldName, value, table)
setRecord(self, recno, newValues, table)
getFieldInt(self, recno, fieldName, table)
getFieldString(self, recno, fieldName, table)
getFieldFloat(self, recno, fieldName, table)
getFieldEnumValue(self, recno, fieldName, table)
getRecord(self, recno, fields, table)
getFieldEnumValueAsInt(self, recno, fieldName, table)
queryRecordsEnum(self, fieldName, value, sortby, table)
queryRecords(self, fieldName, value, sortby, table)
queryRecords2(self, criteria, ANDed, sortby, table)
queryExpr(self, expression, fields, sortby, table)
queryAllRecords(self, sortby, table)
queryFieldNames(self, table)
queryFieldIds(self, table)
connect(self)
doCommand(self, cmd, params)
send(self, params)
receive(self)
encodeNewline(self, text)
unencodeNewline(self, text)
Class HashArray
Summary
Using HashArray
Caveats
Public Methods
__init__(self, value, separator)
setProps(self, other)
size(self)
empty(self)
set(self, key, value)
setBool(self, key, value)
unset(self, key)
get(self, key)
getInt(self, key)
getFloat(self, key)
getDouble(self, key)
getBool(self, key)
toString(self, separator)
isHashArray(text)
fromString(self, text, separatorCharacter)
Class ImageLib
Using ImageLib
Public Methods
__init__(self, id)
__init__(self, name, category)
clear(self)
__init__(self, data)
set(self, data)
append(self)
save(self)
toHashArray(self, forDB)
load(self, id)
toString(self)
fromString(self, data)
calcChecksum(self)
getName(self, id)
getHeightWidth(self, id, height, width)
getType(self, id)
find(self, name, category)
Class Image
Summary
Using Image
Graphics Commnds
setSize()
setOrigin()
setWindow()
drawBox()
drawLine()
drawCircle()
drawText()
drawArc()
drawPolygon()
drawPolyline()
Public Methods
__init__(self, group_id, imageName, module)
valid()
Class MAEApp
Summary
Public Methods
__init__(self, programName, appchannels)
Class MAEConn
Summary
Public Properties
Public Methods
__init__(self, host, port)
writeLine(self, text)
read(self)
readCommHub(self, wait, rcLineOnly)
readDB(self, wait, lockoutCallbacks)
readMsg(self, wait, queueOk)
readRpc(self, wait, lockoutCallbacks, queueOk)
readyCommHub(self)
readyDB(self)
readyMsg(self)
readyRpc(self)
msgSize(self)
dbSize(self)
rpcSize(self)
setCommHubCB(self, cb, data)
setDBCB(self, cb, data)
setMsgCB(self, cb, data)
setRpcCB(self, cb, data)
setRpcRespCB(self, cb, data)
getMsgCB(self)
readLine(self, wait, lockoutCallbacks)
processLine(self, line, lockoutCallbacks)
getCmdCount(self)
servicePendingCallbacks(self, includingCommHub)
setDbPrefix(self, prefix)
setMsgPrefix(self, prefix)
setRpcPrefix(self, prefix)
recordLine(self, send, text)
setTap(self, tap)
getTap(self)
tapActive(self)
Class MAEDaemon
Summary
Public Methods
__init__(self, programName, appchannels)

Module MAEDaemon

Public Properties

debug_on

Flag: True if debug output should generated, False if not

Default value: 0

programName

The program's name, as known to MAE

Default value: 'programName not set'

dbgf

The file pointer to the debug file

Default value: None

MAX_OFFSET

Default value: 26

cypher

Default value: "OriginalSoftwareWrittenInBasicOnCommodore64,PortedToTurboPascal,ThenPortedToC/C++,AndNowOntoLinuxAndMySQL."

db

Default value: None

TEXT_FONT_SIZE

Default value: 12

svgStartTag

Default value: None

svgEndTag

Default value: None


Public Methods

setfield(device, table, field, value)

device

the end-user's device

table

the area with a collection of fields in it

field

the specific field within that area

value

the string to display


Update/Replace the table and field entry with the value provided

Return value: true if sent successfully

settext(device, text, style)

device

the end-user's device

text

the text to put there

style

display style for the text


Replace the display region with the text provided.

Return value: true if sent successfully

write(device, text, style)

device

the end-user's device

text

the text to append

style

display style for the text


Append to the display reagion with the provided text for the user specified

Return value: true if sent successfully

writeln(device, text, style)

device

the end-user's device

text

the text to append

style

display style for the text


Append to the display reagion with the provided text for the user specified, followed by a line break.

Return value: true if sent successfully

writewiki(device, text)

device

the end-user's device

text

the text to append


Convert the text from wiki text (see wiki2doc) and display to the display region.

Return value: true if sent successfully

addhotspot(device, text, action, cbdata, style)

device

the end-user's device

text

the text to append

action

the message keyword to send when user clicks on text (aka request)

cbdata

data to send along with action message

style

the preset way to display the text (color, font, etc)


Append the tagged area with the provided text for the user specified and make it a hot spot that triggers an action.

Return value: true if sent successfully

addhinttext(device, text)

device

the end-user's device

text

the hint text to show the user


Provide hint text to the end-user for the display region. Exact implementation up to the end interface, but it may be to display text when the user hovers over the display region.

Return value: true if sent successfully

button(device, text, action, cbdata)

device

the end-user's device

text

the text on the button

action

the message keyword to send when user clicks on text (aka request)

cbdata

data to send along with action message


Append the tagged area with the provided text on a button for the user on the device specified. When clicked, it triggers a a message with the action and callback data.

format(device, control, on)

device

the end-user's device

control

the UI state keyword to update, e.g. strong, emphasis, bold, italic, underline, color:color

on

flag to say turn the control on or off


DEPRECATED - use style() instead.  Update the current display style state.

Return value: true if sent successfully

newregion(device, newtag, styleName, size)

device

the end-user's device

newtag

the new region's name

styleName

the preset way to display the text (color, font, etc)

size

the number of characters wide for the new region (suggestion)


Create a new display region inside device's current display region.

Return value: true if sent successfully

style(device, styleName)

device

the end-user's device

styleName

the new region's name


Set the named display style for device's current display region.  See the configured properties of the style in the appropriate end-user display type (e.g. usergw uses HTML CSS).

Return value: true if sent successfully

attention(device, text)

device

the end-user's device

text

the text for the user to see


Display a message to get the user's attention.

Return value: true if sent successfully

selection(device, value)

device

the end-user's device

value

the value to show on the selector


When a display region contains a selector, set the active selection to the value provided. If the value is not a valid selection, behavior is undefined.

Return value: true if sent successfully

chat(device, from, text)

device

the end-user's device

from

name of user whom the message is from

text

the message to display


Send a chat message to the end-user's device.

Return value: true if sent successfully

clear(device)

device

the end-user's device


Clear all displayed objects and text from the current display region of the device.

Return value: true if sent successfully

show(device)

device

the end-user's device


Display the objects and text inside the current display region of the device.

Return value: true if sent successfully

hide(device)

device

the end-user's device


Hide the objects and text inside the current display region of the device. Make them non-visible.

Return value: true if sent successfully

newtable(device, tableName, tableType, rows, columns)

device

the end-user's device

tableName

the name of the table

tableType

the type of table, e.g. left, center, right

rows

the number of rows in the table

columns

the number of columns in the table


Create a table display region on the user'd device. It will be setup with the rows and columns specified.  Note that referencing one column more to the right will create that column; and referencing one more row below will create that row.

Return value: true if sent successfully

newlist(device, name, items)

device

the end-user's device

name

the name of the list

items

a count of the expected number of list items (suggestion)


Create a bulleted list that can contains items. Note that adding a list item immediately beyond the end will expand the list.

Return value: true if sent successfully

record(device, recordName, idmap, values, overwrite)

device

the end-user's device

recordName

the record template's name (this corresponds to a file under .../html/record)

idmap

(optional) mapping of template field names to actual ids to use

values

key/value paris of id/values to fill in values in the record

overwrite

flag: true to replace existing display region, false to append


Output a record of information using a templte to map old UI ids to new ones.  For idmap, the key is the old id and the value is the new id

Return value: true if sent successfully

report(device, reportName, table, table_id)

device

the end-user's device

reportName

the name of the report to output

table

the name of the table to ...?

table_id

the id for the table ...?


FUTURE USE.  Output a report of information

Return value: true if sent successfully

prompt(device, query, value, promptType, xid, style)

device

the end-user's device

query

(optional) the question text for the user

value

the default value

promptType

the type of prompt, e.g. text, yn, int, etc.

xid

a transaction id maintained by the calling app (guibroker)

style

the style to use for the query


Present the user with a question and response (text entry) box. The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI).

Return value: true if sent successfully

select(device, option0, options, xid, selected)

device

the end-user's device

option0

The visible question that is the first option on the list - and the default if no value is given.  If the user actually selects this option, the app will be given the value $NA

options

the list of options to show the user.  They key is show; the value is returned as the reply.

xid

a transaction id maintained by the calling app (guibroker)

selected

the selected option


Present the user with a selection of choices.  The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI).

Return value: true if sent successfully

checkbox(device, query, value, xid, style)

device

the end-user's device

query

(optional) the question text for the user

value

the default value

xid

a transaction id maintained by the calling app (guibroker)

style

the style to use for the query


Present the user with a selection of choices as checkboxes.  The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI).

Return value: true if sent successfully

textarea(device, text, xid, style, saveLabel)

device

the end-user's device

text

the initial text in the box

xid

a transaction id maintained by the calling app (guibroker)

style

the style to use for the query

saveLabel

the label on the button for the user to click on to send the revised text


Present the user with an area to type a lot of text.  The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI).

Return value: true if sent successfully

form(device, formName, vars, xid)

device

the end-user's device

formName

the name of the form (relates to .../html/form files)

vars

key/value paris of id/values to fill in default values

xid

a transaction id maintained by the calling app (guibroker)


Present the user with input form template.  The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI).

Return value: true if sent successfully

screen(device, name, rows, columns)

device

the end-user's device

name

the name of the screen for reference

rows

number of rows in the screen

columns

the number of columns in the screen


Create a terminal screen of the specified size on the user's device.

Return value: true if sent successfully

scrattr(device, attributes)

device

the end-user's device

attributes

a comma separated list of styles, e.g. cursor, bold, underline, reverse, red, blue, etc


Set the current terminal screen attributes for the next character(s) to be written.

Return value: true if sent successfully

scrchar(device, row, column, letter, amount)

device

the end-user's device

row

the terminal row

column

the terminal column

letter

a numerical value for the letter to write, e.g. ASCII. Note that letters 0-31 are non-printable.

amount

the number of letters to write out (repeating letters)


Write a character to the terminal screen previously defined at device's display region.

Return value: true if sent successfully

setmenu(device, menu, option, command)

device

the end-user's device

menu

the menu heading that contains menu options

option

the menu option text

command

the request keyword to send to the app


Configure the end-user's device with the menu option under the specified menu.  When the end-user selects it, the specified command will be sent as a message request of the app.

Return value: true if sent successfully

unsetmenu(device, menu, option)

device

the end-user's device

menu

the menu heading that contains menu options

option

the menu option text


Remove the menu option under the specified menu on the end-user's device.

Return value: true if sent successfully

setwindow(device, windowName)

device

the end-user's device

windowName

the name of the window; it appears as the window's title


Configure the end-user's device with a window, titled with the name provided.

Return value: true if sent successfully

unsetwindow(device, windowName)

device

the end-user's device

windowName

the name of the window; it appears as the window's title


Remove/Close the named window from the end-user's device.

Return value: true if sent successfully

setindex(device, indexName)

device

the end-user's device

indexName

the name of the index; it appears as the index's title


Configure the end-user's device with the index (tab).  

Return value: true if sent successfully

unsetindex(device, indexName)

device

the end-user's device

indexName

the name of the index; it appears as the index's title


Remove the named index from the end-user's device.

Return value: true if sent successfully

newsection(device, title, sectionType, newtag)

device

the end-user's device

title

the section title

sectionType

a comma separated list of section qualities, e.g. collabsable, h2, h3

newtag

the tag for the section (must begin with Section_)


Add a section the the UI.  Sections can be manipulated, for example expanded/collapsed.

Return value: true if sent successfully

collapseSection(device)

device

the end-user's device


Collapse the section identified as the current display region.

Return value: true if sent successfully

expandSection(device)

device

the end-user's device


Expand the section identified as the current display region.

Return value: true if sent successfully

displayImage(device, imageName, image_type, action, cbdata, append)

device

the end-user's device

imageName

the Image's name (see Image class)

image_type

the image type, e.g. svg, gif

action

(optional) if specified, then image is a hot spot; when the user clicks on it, a message will be send with this action/request keyword

cbdata

(optional) if an action was specified, then image is a hot spot; when the user clicks on it, a message will be send with this callback data

append

Add the image or replace the contents of the device's current region. Default: false/replace.


Display the referenced buffered image that has already been transferred to display channel. If an action is provided, the image can be clicked on to trigger the action with its callback data.

Return value: true if sent successfully

displayImage(device, image_id, action, cbdata, append)

device

the end-user's device

image_id

the image id from the ImageLib library

action

(optional) if specified, then image is a hot spot; when the user clicks on it, a message will be send with this action/request keyword

cbdata

(optional) if an action was specified, then image is a hot spot; when the user clicks on it, a message will be send with this callback data

append

Add the image or replace the contents of the device's current region. Default: false/replace.


Display the referenced buffered image that has already been transferred to display channel. If an action is provided, the image can be clicked on to trigger the action with its callback data.

Return value: true if sent successfully

playAudio(device, audioName)

device

the end-user's device

audioName

the audio sound's name (or HTML tag, e.g. audio_audioName)


Play the referenced audio sound.  

Return value: true if sent successfully

download(device, query, fileclass, xid)

device

the end-user's device

query

the question/prompt to the user

fileclass

a comma separated list of file types, e.g. html, pdf, svg, etc.

xid

a transaction id maintained by the calling app (guibroker)


Request that the user send the app a file.

Return value: true if sent successfully

upload(device, imageName, image_type)

device

the end-user's device

imageName

the Image's name (see Image class)

image_type

the image type, e.g. svg, gif


Send a file to the end-user's device that has already been transferred to display channel.  

Return value: true if sent successfully

imagelibpre(device, id)

device

the end-user's device

id

the image's id in ImageLib


Pre-fetch and image from ImageLib.  

Return value: true if sent successfully

bufimage(device, imageName, image_type, width, height, size, binary, chunk, totalChunks, chunksize, data)

device

the end-user's device

imageName

the Image's name (see Image class)

image_type

the image type, e.g. svg, gif

width

image width, in pixels

height

image height, in pixels

size

size of image, in bytes

binary

flag set to true if data is binary (hex encoded)

chunk

chunk #, starting at 0, increasing with subsequent chunks

totalChunks

total number of chunks being sent

chunksize

size of this chunk of data, in bytes

data

the data of this chunk


Send a chunk of data to the display chennel (to fit within a message max size).

Return value: true if sent successfully

setvar(device, variable, value)

device

the end-user's device

variable

the end-user device variable to set, e.g. wid (tenant id), pc

value

the new value of the variable


Alter a end-user device built-in variable value.

Return value: true if sent successfully

getvar(device, variable, value)

device

the end-user's device

variable

the end-user device variable to set, e.g. wid (tenant id), pc

value

(output) the current value of the variable


Alter a end-user device built-in variable value.

Return value: true if sent successfully

run(device, appname, startParams)

device

the end-user's device

appname

the app to run

startParams

the initial parameters for running that app (app-specific); note that any XML sub-objects will not pass through to new process - only key/value property pairs


Switch the user from running one app to a different app using the provided parameters.

Return value: true if sent successfully

stop(device)

device

the end-user's device


Stop running the current application.

Return value: true if sent successfully

userAccountChange(userId, action, value)

userId

User datastore's id for user

action

Action to take on user's account, e.g disable

value

Parameter for action, e.g. T, F


Take an action on a user's account.

Return value: true if sent successfully

registerApp(appmode, apptype, action, contentInputType, contentOutputType, operations, msgchannel, privatePages)

appmode

Name of appmode, likely the app's name. All URL's for //site/appmode/ will trigger a message using action below

apptype

type of behavior to remote client: Ux (asynchronous user experience in browser), Direct (synchronous query gets synchronous response), Pipe (streamed data from remote connection is fed to app by line or binary block)

action

name of action to send to app when URL connection established

contentInputType

the expected input content payload. A HTTP simple form POSTing sends form-data; a REST call may send json or xml.

contentOutputType

the default response content payload, e.g. json, xml

operations

a list of HTTP operations allowed. "GET,POST" is typical, but a REST interface may also include PUT, DELETE, or PATCH. The value is a comma separted list.

msgchannel

specify if other than the default channel for the calling app.

privatePages

true if only authenticated users may access, false if public


Register an app mode with UserGW. This captures all URL activity for URLs that begin with that appmode.

Return value: true if sent successfully

startraw(device, statusCode, contentType)

device

the end-user's device

statusCode

disposition status of the connection: 0- Success, 1- Input error, 2- Invalid, 3- Not authorized, 4- Failure (no output

contentType

the output content type, likely json or xml. However a major/minor value is allowed (and passes straight through)


Declare to UserGW that response output is ready to send.

Return value: true if sent successfully

writeraw(device, text, isBinary)

device

the end-user's device

text

the text to send

isBinary

true if text is hexadecimal codes for binary data


Output text to the connection without modifying the text at all.  If the text is binary, it is converted from hex codes to binary before transmission.

Return value: true if sent successfully

closeraw(device)

device

the end-user's device)


Append to the display reagion with the provided text for the user specified

Return value: true if sent successfully

send(request, params)

request

params


simpleEncrypt(text, offset)

text: str

offset: int

Default value: -1


Return str value:

simpleEncryptLike(text, likeOtherText)

text: str

likeOtherText: str


Return str value:

isSimpleEncrypted(text)

text: str


Return bool value:

simpleDecrypt(text)

text: str


Return str value:

prompt(device, question, prefillAnswer, queryType, cbapp, cbtag, cbdata, style)

device

question

prefillAnswer

queryType

cbapp

cbtag

cbdata

style


select(device, question, choices, cbtag, cbdata, defaultValue)

device

question

choices

cbtag

cbdata

defaultValue


textarea(device, question, origText, cbtag, cbdata, style, saveButtonLabel)

device

question

origText

cbtag

cbdata

style

saveButtonLabel


checkbox(device, question, cbtag, cbdata, defaultValue, style)

device

question

cbtag

cbdata

defaultValue

style


form(device, formName, formDefaults, cbtag, cbdata)

device

formName

formDefaults

cbtag

cbdata


run(device, appname, appparams)

device

appname

appparams


download(device, query, cbtag, cbdata, fileclass)

device

query

cbtag

cbdata

fileclass


registerMenu(device, menuname, menuoption, action)

device

menuname

menuoption

action


registerKey(device, keystroke, action)

device

keystroke

action


registerHotspot(device, region, action)

device

region

action


redirectHotspot(device, region, otherapp)

device

region

otherapp


error check

registerMouse(device, region, action)

device

region

action


registerCommand(device, cmd, cmdparams)

device

cmd

cmdparams


send(request, params)

request

params


htmlize(url)

url: str


Converts a string to a string usable inside HTML code.

The returned pointer should be free()ed by the calling routine.

Return str value:

urlize(url)

url: str


Operations performed:

change % to %25

change = to nothing

change + to %3b

change space to %20

change # to %23

Return str value:

sendImage(device, iid, errmsg, action, cbdata)

device

iid

errmsg

action

cbdata


saveToImageLib(device, filename, filetype, filecontent, xid, category)

device

filename

filetype

filecontent

xid

category


saveToImageLib(image_id, filename, filetype, filecontent, category)

image_id

filename

filetype

filecontent

category


updateImageLib(image_id)

image_id


saveToImageLib(image_id, filecontent)

image_id

filecontent


setImageCategory(image_id, category)

image_id

category


setImageName(image_id, name)

image_id

name


setImageType(image_id, type)

image_id

type


newImage(table, id)

table

id


send(request, params)

request

params


response(device, xid, text)

device

xid

text


chat(device, text)

device

text


cmd(device, cmd)

device

cmd


key(device, key)

device

key


click(device)

device


mouse(device, direction, x, y, action, cbdata)

device

direction

x

y

action

cbdata


hotspot(device, action, cbdata)

device

action

cbdata


upload(device, fileclass, filetype, imagelibid, xid)

device

fileclass

filetype

imagelibid

xid


refresh(device)

device


select(device, value)

device

value


online(device, appparams)

device

appparams


withdraw(device)

device


timeout(device)

device


send(request, params)

request

params


open(name, mode, cbtag, cbdata)

name

mode

cbtag

cbdata


putchar(ioId, c, ioChannel)

ioId

c

ioChannel


write(ioId, text, ioChannel)

ioId

text

ioChannel


write(ioId, data, ioChannel)

ioId

data

ioChannel


seek(ioId, offset, ioChannel)

ioId

offset

ioChannel


lock(ioId, exclusive, wait, ioChannel)

ioId

exclusive

wait

ioChannel


unlock(ioId, exclusive, wait, ioChannel)

ioId

exclusive

wait

ioChannel


close(ioId, ioChannel)

ioId

ioChannel


fsverify(node, ioChannel)

node

ioChannel


fsreview(dirResourceId, ioChannel)

dirResourceId

ioChannel


fsconfirm(node, size)

node

size


fsupdate(node, change, size)

node

change

size


ls(maepath)

maepath


stat(maepathandfilename, statbuf)

maepathandfilename

statbuf


send(request, params, channel)

request

params

channel


Class Cache

Public Methods

__init__(self, objType, size)

objType

the class of the object to cache

size: int

the maximum size allowable for the cache

Default value: 0


Constructor.

__del__(self)

Destructor

add(self, newKey, newOne)

newKey: int

newOne


Add a record to the cache. It must be valid().

Return int value:

removeKey(self, key)

key


Remove a record from the cache

Return bool value:

remove(self, pos)

pos: int


Remove a record from the cache

Return bool value:

findPos(self, searchKey, fetchIfMissing)

searchKey

fetchIfMissing: bool

Default value: True


Locate the cache position (-1 if not found)

Note: Pull into cache if fetchIfNotFound is True

Note: key must be a positive (non-zero) number

Return int value:

exists(self, searchKey)

searchKey: int


Check if key exists in list

Return bool value:

get(self, key)

key


Get pointer to data for the key. Check if result is valid().

Note: key must be a positive (non-zero) number

__getitem__(self, pos)

pos: int

position in cache, from 0+


This method allows the class instance to be indexed, e.g. HelloCache[2] to get the second element (not key==2)

Return value: the instance at position

__len__(self)

Return the size of the cache when using the len() function

Class Datastore

Summary

This class abstracts database protocols and allows an app to use this interface to perform database table queries and changes.

This class connects to dbbroker, which actually performs the database manipulation.  Note that dbbroker can be configured to connect to a variety of databases; this gets rid of app responsibility for database connection and syntax; an app can simply use the database.

It is safe (and convenient) to create an instance of this class for each table your program uses.

If you have an existing database table and you want to create a class interface to it, consider using genmae like this:

genmae db2h tablename > classname.h

genmae py classname.h > classname.py

Likewise, if you create .h file with the core class variables, you can use genmae to create the SQL code to setup the table, like this:

genmae h2sql classname.h > tablename.sql

Note that database manipulation commands will block program execution until a response from dbbroker is received.

Public Properties

FieldType

Default value: Enum('FieldType', 'FieldInt', 'FieldTime', 'FieldEnum', 'FieldLogical', 'FieldString', 'FieldFloat', 'FieldDate', 'FieldBinary')

OK

DB operation was successful (no error)

Default value: 0

INVALID_NAME

DB operation failed - invalid name given

Default value: -1

OPEN

DB operation failed - cannot open table

Default value: -2

INVALID_TYPE

DB operation failed - invalid field type

Default value: -3

INVALID_FIELD

DB operation failed - invalid field name

Default value: -4

INVALID_REC

DB operation failed - invalid record id

Default value: -5

INVALID_ENUM

DB operation failed - invalid enum

Default value: -6

INVALID_PARAM

DB operation failed - invalid parameter

Default value: -7

LOCKED

DB operation failed - record locked

Default value: -8

NOT_SUPPORTED

DB operation failed - operation not supported

Default value: -9

FAILED

DB operation failed - (non-specific)

Default value: -10

REC_NOT_FOUND

DB operation failed - record not found

Default value: -11

ALREADY_EXISTS

DB operation failed - record already exists

Default value: -12

INVALID_SCHEMA

DB operation failed - invalid schema

Default value: -13

COMM_ERROR

DB operation failed - communications error

Default value: -14

CORRUPT_REPLY

DB operation failed - reply was corrupt (cannot parse)

Default value: -15

INVALID_CONN

DB operation failed - invalid connection

Default value: -16

INVALID_EXPR

DB operation failed - invalid expression

Default value: -17

LINEPAYLOADMAX

Maximum line length to send to dbbroker

Default value: 10000 - 100

PAYLOADMAX

Default value: 10000


Public Methods

__init__(self, tableName)

tableName: str

Default value:


Constructor to initialize our data structure.  This does not yet setup the connection to dbbroker.

valid(self)

Determine status of our connection to database - is it valid?

Return int value: True if connected to db

status(self)

Get the status of the last request

Return int value: the status of the last request (see codes at top of Datastore.py)

statusOK(self)

Determine if the status of the last operator was successful.

Return bool value: True if last operation successful, False otherwise.

isOpen(self)

Determine if the database connection is established and ready.

Return bool value: True if db connection ready

statusMsg(self)

Return human readable status of last request.

Return str value: msg corresponding to last DB request

fieldNameToType(self, name)

name: str


fieldTypeToName(self, fieldtype)

fieldtype


Return str value:

errorMsg(self, rcToGetMsgFor)

rcToGetMsgFor: int

the return code number to look up

Default value: 1


Get the status message of the specified return code.

Return str value: the text of the error message

open(self, tableName)

tableName: str

the name of the table to use as the current table.

If not successful, check status() for the code or statusMsg() for human readable description.


Set the currently active table by opening it.

Return int value: the status code of the operation.

select(self, tableName)

tableName: str

the name of the table to use as the current table.

If not successful, check status() for the code or statusMsg() for human readable description.


Identifical to open().  Set the currently active table by opening it.

Return int value: the status code of the operation.

connected(self)

Check to make sure the database connection is working.

Return bool value: True if db responding to our requests

pack(self)

Pack the database (remove deleted records), if the database supports this.

Otherwise, it is ignored.

Return bool value: True upon success, False upon failure (see statusMsg())

close(self, specifiedTable)

specifiedTable: str


Signal to close this database table.

@param table name of the table to close; if none, then last table used

Return bool value: True upon success, False upon failure (see statusMsg())

getTableList(self)

Get the list of defined tables.

Return value: the list of tables in the database

addField(self, fieldName, type, size, table, isIndex)

fieldName: str

name of field for operation

type

type of field (string, int, float)

size: int

(optional) size of field in bytes

table: str

name of table for operation

Default value:

isIndex: bool

True if this field is an index for the table

Default value: False


Obsolete. Add a field to the named database table.

Return 0 value: field id of new field

getFieldId(self, fieldName, table)

fieldName: str

name of the field for which to get the fieldid

table: str

name of table for operation

Default value:


Query field id from field name for the named table.

Return int value: nonzero on success, 0 on failure

addFieldEnum(self, fieldName, enumName, enumId, table)

fieldName: str

id of the enum field

enumName: str

name/identifier for enum

enumId: int

(optional) integer value to use for enum

table: str

name of table for operation

Default value:


Obsolete.  Add field enumeration to the nanmed table.

Return int value: new enum value

getFieldType(self, fieldName, table)

fieldName: str

id of the enum field

table: str

name of table for operation

Default value:


Query a field type (string, float, etc) for the provided field name in the provided table.

Return value: the field type

addRecord(self, data, recno, table)

data

any data to pre-populate the record

recno: int

(optional) id for the record

Default value: 0

table: str

name of table for operation

Default value:


Add/Append a new record to the table provided, populated with the data provided.

Return value: new record number added

deleteRecord(self, recno, table)

recno

number of the record to delete

table: str

name of table for operation

Default value:


Delete a record in the named table.

Return bool value: transaction status (see statusMsg())

lockRecord(self, recno, table)

recno

number of the record to lock

table: str

name of table for operation

Default value:


Lock a record in the named table; prevent other applications from modifying this record until it is unlocked.

Return bool value: transaction status (see statusMsg())

unlockRecord(self, recno, table)

recno

number of the record to unlock

table: str

name of table for operation

Default value:


Unlock a record in the named table, allowing other applications to now modify it.

Return bool value: transaction status (see statusMsg())

clearField(self, recno, fieldName, table)

recno

number of the record containing the field

fieldName: str

name of the field to clear

table: str

name of table for operation

Default value:


clear/empty the value for the field with this field name

Return bool value: transaction status (see statusMsg())

setValue(self, recno, fieldName, value, table)

recno

number of the record in which to set the value

fieldName: str

value

the value to set

table: str

name of table for operation

Default value:


change a string value identified by field ID

@param field name of the field in which to set the value

Return bool value: transaction status (see statusMsg())

setRecord(self, recno, newValues, table)

recno

number of the record in which to set the value

newValues

table: str

name of table for operation

Default value:


change several field values at once

@param newValue key/value pairs for new field/value changes

Return bool value: transaction status (see statusMsg())

getFieldInt(self, recno, fieldName, table)

recno

number of the record containing the value

fieldName: str

name of the field to get

table: str

name of table for operation

Default value:


get an int field value identified by field name

Return int value: the int value or -1 if unsuccessful

getFieldString(self, recno, fieldName, table)

recno

number of the record containing the value

fieldName: str

name of the field to get

table: str

name of table for operation

Default value:


get a string field value identified by field name

Return str value: the string value or zero length string if unsuccessful

getFieldFloat(self, recno, fieldName, table)

recno

number of the record containing the value

fieldName: str

name of the field to get

table: str

name of table for operation

Default value:


get a float field value identified by field name

Return float value: the float value or ??? if unsuccessful

getFieldEnumValue(self, recno, fieldName, table)

recno

number of the record containing the value

fieldName: str

name of the field to get

table: str

name of table for operation

Default value:


get an enum value identified by field name

Return str value: the enum value or zero length string if unsuccessful

getRecord(self, recno, fields, table)

recno

number of the record containing the value

fields

Default value: []

table: str

name of table for operation

Default value:


get an int field value identified by field name

@param fieldName name of the field to get

Return value: key/value pairs of field/value values from record.  Error if empty, check status()/statusMsg().

getFieldEnumValueAsInt(self, recno, fieldName, table)

recno

number of the record containing the value

fieldName: str

name of the field to get

table: str

name of table for operation

Default value:


get an enum value as an int identified by field name

Return int value: the enum value or zero length string if unsuccessful

queryRecordsEnum(self, fieldName, value, sortby, table)

fieldName: str

name of field to search

value: str

enum value to search for

sortby: str

Default value:

table: str

name of table for operation

Default value:


simple query for enum value by field name

Return list value: list of record numbers matching criteria

queryRecords(self, fieldName, value, sortby, table)

fieldName: str

Name of field to search, paired with the value; alternatively fieldName can be an XMLData object with key/value pairs to search for (if so, value is ignored)

value: str

string value to search for

Default value:

sortby: str

Default value:

table: str

name of table for operation

Default value:


simple query for string value by field name

Return list value: list of record numbers matching criteria

queryRecords2(self, criteria, ANDed, sortby, table)

criteria

ANDed: bool

Default value: True

sortby: str

Default value:

table: str

name of table for operation

Default value:


compound query for a field value

@param list list of field key/value pairs to be searched for

Return list value: list of record numbers matching criteria

queryExpr(self, expression, fields, sortby, table)

expression: str

using field names, comparison operators, and logic operators, specify which records match the query

fields: list

a list of fields to return

Default value: 'Id'

sortby: str

field name to use to sort the results start with + (default) for ascending sort, - for descending sort

Default value:

table: str

name of table for operation

Default value:


Using an expression, query records and return the requested fields, sorted if specified.

@param results - (output) a list of records and their fields that matched

Return bool value: True upon success

queryAllRecords(self, sortby, table)

sortby: str

Default value:

table: str

Default value:


query for all records in the named (or current) table

Return list value: recList with results which will be empty if unsuccessful

queryFieldNames(self, table)

table: str

the name of the table to query for fields

Default value:


query for all field names and types

Return value: XMLData which will be empty if unsuccessful. Otherwise key is field name, value is field type.

queryFieldIds(self, table)

table: str

the name of the table to query for fields

  1. @return XMLData which will be empty if unsuccessful. Otherwise key is field name, value is field id.

Default value:


query for all field names and types

connect(self)

Connect to database server.

In actuality, this only checks to make sure we're connected to the MAE daemon, commhub.

Return bool value: True on success; False on failure

doCommand(self, cmd, params)

cmd: str

params

Default value: None


Send a command for dbbroker that has no parameters. And wait for the reply.

Return bool value: True on success; False on failure

send(self, params)

params


Send data to commhub for DB operation

Return bool value: True if sent; False if failed

receive(self)

Wait for a dbbroker response from commhub.

Return bool value: True if reply received; False if not

encodeNewline(self, text)

text: str

the text to encode


commhub wants a comment to have new \n characters, so encode them

unencodeNewline(self, text)

text: str

the text to unencode


commhub didn't let dbbroker send any \n characters, so unencode them

Class HashArray

Super class: dict

Summary

This class behaves a lot like the dict class, but with more control over the value types.

Note that all keys are strings.

Using HashArray

The HashArray data type is a key-value container.

It is typeless, but a specific type can be asserted (e.g. setBool()) or retrieved (e.g. getBool(), getInt(), etc).  It is up the the application to store/retrieve by type consistently.

This data type is very convenient for messaging.  Calling the toString() method converts the HashArray into a string.  Using the fromString() method or constructor converts it back.

Caveats

  1. Numerical keys are not handled rigorously; unless numerical keys are set sequentially, you may get inconsistencies.
  2. When used inside XMLData, keys must be identifers with alphanumeric characters; if non-alphanumerics are given, they will be converted to underscores when converted using toString().  XMLData requires keys to be valid XML tag identifiers.

Public Methods

__init__(self, value, separator)

value: str

Default value:

separator: str

Default value: '\n'


Constructor

setProps(self, other)

other


Set the properties of the other HashArray into this HashArray, replacing any previous values

size(self)

Return the number of key-value pairs.

Return int value: # keys in hash array

empty(self)

Determine if there are no key-value pairs in the hash array.

Return bool value: True if there are no key-value pairs, False if there's at least one

set(self, key, value)

key: str

name of the key to set

value

value to set to key


Assign a value into the dict

setBool(self, key, value)

key: str

name of the key to set

value: bool

value to set to key


Assign a boolean value to a key.

unset(self, key)

key: str

name of the key to unset


Remove a key/value pair from the dict

get(self, key)

key: str

name of the key to unset


Get a string value from the dict key

Return str value:

getInt(self, key)

key: str

name of the key to unset


Get a integer value from the dict key

Return int value:

getFloat(self, key)

key: str

name of the key to unset


Get a floating point value from the dict key

Return float value:

getDouble(self, key)

key: str

name of the key to unset


Get a double precision floating point value from the dict key. Same as getFloat().

Return float value:

getBool(self, key)

key: str

name of the key to unset


Get a boolean value from the dict key

Return bool value:

toString(self, separator)

separator: str

text that separates each key/value pair.

Default value: '\n'


Serialize the HashArray into a string.

isHashArray(text)

text: str

a text string to examine


Examine the text string provided and determine if it's a HashArray or not.

Return bool value: True if text string is a serialized HashArray, False otherwise

fromString(self, text, separatorCharacter)

text: str

the text string to decode

separatorCharacter: str

the text that separated key/value pairs

Default value: '\n'


Take a text string that was generated by toString() and restore the data inside HashArray.

Return bool value: True if text could be fully decoded.

Class ImageLib

Using ImageLib

This class holds a reference to and then ultimately delivers the binary content of an image in the Image Library (the ImageLib table).  This class holds the image id, name, category, image type, height and width of the image.

Public Methods

__init__(self, id)

id


__init__(self, name, category)

name: str

category: str


clear(self)

__init__(self, data)

data


set(self, data)

data


append(self)

save(self)

toHashArray(self, forDB)

forDB: bool


load(self, id)

id


Return bool value:

toString(self)

Return str value:

fromString(self, data)

data: str


Return bool value:

calcChecksum(self)

Return int value:

getName(self, id)

id


Return str value:

getHeightWidth(self, id, height, width)

id

height: int

width: int


Return bool value:

getType(self, id)

id


Return str value:

find(self, name, category)

name: str

category: str


Class Image

Summary

This class represents images within the MAE system.

Images may be drawn by the app or pulled from ImageLib database table.

Drawn images draw into a coordinate system with the size (height, width) and origin specified by the application.  For example, to create an image with a coordinate system that is 5 units wide and 4 units tall with the origin(0,0) in the center, you specify setSize(5, 4) and setOrigin(-2.5,-2).  How large the image is when it is displayed depends upon the unit size. If you'd like your 5 unit wide image to be 50 pixes wide, then specify setSize(5, 4, 10).

To display an image to the user, see the UserDevice class.

Use this class to communicate with imager, which renders them appropriately for the user.

Using Image

This data structure abstracts a vector image.  The API is used to describe the image.  It is not rendered into JPG, PNG, SVG, or other specific image technology until it is ready to be rendered to the end-user.  Rendering is performed by the imager daemon.

The API could be richer, but the API must be able to render to each of the ultimate image types.

The Image class may refer to an existing image file in a specific format via ImageLib class, which specifies where to retrieve the image and the image's size.

Graphics Commnds

setSize()

setSize(double newWidth, double newHeight, int newUnitSize)

Set the canvas dimensions and specify how many pixes per unit.  For example, a 4.0x5.0 image where unit size is 10 would create a 40x50 pixel image.

setOrigin()

setOrigin(double newOriginX, double newOriginY)

Specify how many units over the origin should be located if (0,0) is the lower left

setWindow()

setWindow(double minX, double minY, double maxX, double maxY, int newUnitSize)

Specify the width and origin implicitly by specifying the window into the view.  Use this instead of setSize() setOrigin()

drawBox()

drawBox([[#Point]] corner1, Point corner2, string color, bool fill, string link)

Draw a rectangle with the corners specified.  Default color is black.  The box may be an outline or solid/fiilled.

An optional link (e.g. URL) may be provided if resulting image supports linking.

drawLine()

drawLine([[#Point]] p1, Point p2, string color, string link)

Draw a line from p1 to p2 of the color specified.

An optional link (e.g. URL) may be provided if resulting image supports linking.

drawCircle()

drawCircle([[#Point]] center, double radius, string color, bool fill, string link)

Draw a full circle with the specified center and radius.  The default color is black.  The circle may be an outline or solid/fiilled.

An optional link (e.g. URL) may be provided if resulting image supports linking.

drawText()

drawText([[#Point]] start, string text, string color, string link)

Draw text into the image with the lower left corner of the text at the start point.

drawArc()

bool drawArc([[#Point]] center, double startang, double endang, double radius, string color, bool fill)

drawPolygon()

drawPolygon([[#Point]]List p, string color, bool fill, string link)

Given a series of points, draw the enclosed polygon.  The default color is black.  The polygon may be an outline or solid/fiilled.

An optional link (e.g. URL) may be provided if resulting image supports linking.

drawPolyline()

drawPolyline([[#Point]]List p, string color, string link)

Given a series of points, the the line that connects them from start to end.  The default color is black.

An optional link (e.g. URL) may be provided if resulting image supports linking.

Public Methods

__init__(self, group_id, imageName, module)

group_id: int

this is an application-specific number to differentiate this image name from others; it is used to help create a unique image name for the user's display device

Default value: 0

imageName: str

this is the application-specific name given to the image

Default value:

module: str

this is the application-specific category for the image, such as the application's name

Default value:


Construct an empty image.

valid()

Query if the current image is valid.

Return bool value: True if valid; False if invalid

Class MAEApp

Super class: MAE

Summary

This class builds on top of the MAE class. It ensures MAE knows that your MAE task is an app and supports it appropriately. An app is a persistent program servicing user requests via UI.

Public Methods

__init__(self, programName, appchannels)

programName: str

the name of the task as registered inside MAE

appchannels: str

a comma separated list of message channels used. Default is one channel using the program's name.

Default value:


Declare your app MAE instance of this task.

Class MAEConn

Super class: Socket

Summary

This class handles the communication layer between a MAE daemon/app and CommHub.

The challenge that this class faces is that CommHub communicates asynchronously with its client daemons/app, so an app may have sent a DB request (for example) and while wating for the DB response, it may receive some messages, an RPC request, or control message (perhaps initiated by the user).  So, this class has to remember those messages and then process them after the DB response arrives.

Internally, MAEConn discerns these logical communication categories:

Public Properties

dbPrefix

Default value: "Db"

msgPrefix

Default value: "Msg"

rpcPrefix

Default value: "Rpc"

commhub

Default value: []

db

Default value: []

msg

Default value: []

rpc

Default value: []

tapf

Default value: None

COMMHUB_LINE_NOFMT

CommHub line protocol characters

Default value: 0

COMMHUB_LINE_TEXT

Default value: ' '

COMMHUB_LINE_CHUNK

Default value: '='

COMMHUB_LINE_BINARY

Default value: 'x'

COMMHUB_LINE_SUCCESS

Default value: '+'

COMMHUB_LINE_FAILURE

Default value: '-'


Public Methods

__init__(self, host, port)

host: str

The hostname to connect to (if empty, then localhost)

Default value:

port: int

The remote TCP port to connect to

Default value: 0


Prepare for a TCP socket connection

Return value: instance of Socket to open().  If FALSE, check errno().

writeLine(self, text)

text: str


Send text to commhub

Any \n will be converted to text (and later back)

Return bool value:

read(self)

Read any inbound text.

Use its callback (if defined) to process the inbound text.

Return int value: socket status (-1 EOF) - messages ready to be ready (with no callback)

readCommHub(self, wait, rcLineOnly)

wait: bool

block until we have input from commhub

Default value: False

rcLineOnly: bool

wait until we get a response line (starts with + or -) and return that; other lines are queued

Default value: False


Wait for text from commhub.

Read text up to a newline.

Return str value: the string read.  If empty, check errno().

readDB(self, wait, lockoutCallbacks)

wait: bool

Default value: False

lockoutCallbacks: bool

Default value: False


Wait for DB response.

Read DB response text up to a newline.

Return str value: the string read.  If empty, check errno().

readMsg(self, wait, queueOk)

wait: bool

Set to True to wait until there's valid input, False if just checking quickly

Default value: False

queueOk: bool

Set to True if it's OK to pull queued/pending messages (this is normal/default)

Default value: True


Wait for text message.

Read a Message text up to a newline.

Return str value: the string read.  If empty, check errno().

readRpc(self, wait, lockoutCallbacks, queueOk)

wait: bool

Set to True to wait until there's valid input, False if just checking quickly

Default value: False

lockoutCallbacks: bool

Set to prevent other requests from being serviced while waiting

Default value: False

queueOk: bool

Set to True if it's OK to pull queued/pending messages (this is normal/default)

Default value: True


Wait for text message.

Read an RPC text up to a newline.

Return str value: the string read.  If empty, check errno().

readyCommHub(self)

Return True if commhub command queue has a command ready to be processed

Return bool value: True if there's 1+ backlog commands

readyDB(self)

Return True if DB command queue has a command ready to be processed

Return bool value: True if there's 1+ backlog commands

readyMsg(self)

Return True if msgbroker message command queue has a command ready to be processed

Return bool value: True if there's 1+ backlog commands

readyRpc(self)

Return True if RPC command queue has a command ready to be processed

Return bool value: True if there's 1+ backlog commands

msgSize(self)

Get size of msg backlog queue

Return int value: size of the queue

dbSize(self)

Get size of db backlog queue

Return int value: size of the queue

rpcSize(self)

Get size of rpc backlog queue

Return int value: size of the queue

setCommHubCB(self, cb, data)

cb

callback function

Default value: None

data

callback data

Default value: None


Setup the commhub callback

setDBCB(self, cb, data)

cb

callback function

Default value: None

data

callback data

Default value: None


Setup the DB callback

setMsgCB(self, cb, data)

cb

callback function

Default value: None

data

callback data

Default value: None


Setup the msgbroker message callback

setRpcCB(self, cb, data)

cb

callback function

Default value: None

data

callback data

Default value: None


Setup the RPC request callback

setRpcRespCB(self, cb, data)

cb

callback function

Default value: None

data

callback data

Default value: None


Setup the RPC response callback

getMsgCB(self)

Get the msgbroker message callback method

Return value: the msgbroker message callback method

readLine(self, wait, lockoutCallbacks)

wait: bool

Default value: False

lockoutCallbacks: bool

Default value: False


Read text up to a newline.

  1. Figure out which queue the message is bound for, and push it into that queue.

Return bool value: True if something read

processLine(self, line, lockoutCallbacks)

line: str

the line from commhub to process

lockoutCallbacks: bool

True if no callbacks should be called to immediately handle a message

Default value: False


Put line into right queue or send to callback (if not locked out/blocked)

getCmdCount(self)

of lines received

Return int value:

servicePendingCallbacks(self, includingCommHub)

includingCommHub: bool

Default value: True


If any callbacks are configured and data is pending, service them.

Return bool value:

setDbPrefix(self, prefix)

prefix: str

the new prefix


If a different DB prefix is needed, configure new prefix here

setMsgPrefix(self, prefix)

prefix: str

the new prefix


If a different msgbroker message prefix is needed, configure new prefix here

setRpcPrefix(self, prefix)

prefix: str

the new prefix


If a different RPC prefix is needed, configure new prefix here

recordLine(self, send, text)

send: bool

True is message is outbound, False if message is inbound

text: str

the message


Save a message out to tap file

setTap(self, tap)

tap

Default value: None


Useful for monitoring all socket communication - a socket tap

will record all read/write activity (set to NULL to disable)

Use msgplayer to replay messages for testing/debugging.

getTap(self)

Query the tap's file pointer

tapActive(self)

Determine if tap is active

Return bool value:

Class MAEDaemon

Super class: MAE

Summary

This class builds on top of the MAE class. It ensures MAE knows that your MAE task is an app and supports it appropriately. A daemon is a persistent program providing support to other MAE tasks.

Public Methods

__init__(self, programName, appchannels)

programName: str

the name of the task as registered inside MAE

appchannels: str

a comma separated list of message channels used. Default is one channel using the program's name.

Default value:


Declare your daemon MAE instance of this task.