DevWare Module Reference

The devware module provides other DevWare application functions not directly related to accessing the camera.

Console Class

The Console class is a file-like class that directs character stream data to the Python Console window. DevWare sets sys.stdin, sys.stdout and sys.stderr to a Console object.

Constructor

Normally you can just use sys.stdin, sys.stdout and sys.stderr to access the Python Console window, but the constructor can be called directly.

Console(unit)

Construct a Console object. If the parameter is 0 the text written will be black (or the default window text color) in the Python Console window. If the parameter is 1 the text will be red and may trigger a pop-up warning dialog (this is used for sys.stderr). The parameter may be omitted and defaults to 0.


Attributes

There are no attributes.

Methods

write(str)

Adds the text to the Python Console output window. This is called implicitly by the Python print() function.

readline(size)

Pops up a small dialog with a text entry control. Returns the text entered by the user. If the size parameter is present and non-negative, the returned string is limited to size characters. This is called implicitly by the Python input() function. If the user cancels the dialog, the return value is an empty string.

flush()

Does nothing. Included for compatibility with other Python file-like objects.


Devware Methods

The devware module methods are based on the methods exposed through DevWare's COM interface. For more details about these functions see the DevWare COM interface document, DevWare COM Development Guide.pdf.
For more details about DevWare state variables see the INI file document, DevWare inifile User Guide.pdf.

getstate(statename)

Returns the value of the specified state variable. Some variables have integer values and some have string values. See the INI file user's guide for more details.

setstate(statename, value)

Assign a new value to a state variable. Some state variables are integer valued and some are string valued. The type of the value parameter must match the type of the named state variable.

getoption(optionname)

Returns the value of an integer-valued option variable. See the COM interface document for more details.

setoption(optionname, value)

Assign a new value to an option variables. Option values are persistent across invocations of DevWare.

getoption_str(optionname)

Like getoption() but for string values.

setoption_str(optionname, value)

Like setoption() but for string values. Option values are persistent across invocations of DevWare.

get_mouse_selection()

Returns the Mouse Selection on the DevWare left-hand Info panel and the currently selected image area. Returns a tuple with five items; the selection type, the x and y coordintates of the start of the area, and the x and y coordinates of the end of the area. Example:
sel, x1, y1, x2, y2 = get_mouse_selection()
Sel can be 'off', 'row', 'column', 'rectangle', or 'point'. For 'row' only y1 is relevant, for 'column' only x1 is relevant, and for 'point' only x1 and y1 are relevant.

set_mouse_selection(sel, x1, y1, x2, y2)

Set a new selection area.

image(width, height, type)

Override DevWare's calculation of the current sensor output image size and image type. The type parameter is optional. If you only want to set the image type then pass 0 for width and height. See the INI file user's guide, IMAGE= command for more details. Example:
image(640, 480, 'YCBCR')

load_preset(preset)
load_preset(file, preset)

Execute an INI file preset. If the file parameter is not given, the method will load from the currently executing ini file, or if that can't be determined, the main ini file.

open_ini_file(file)

Create a new Additional Presets dialog showing the given file. If the file parameter is omitted or an empty string then DevWare puts up a standard Open File browse dialog and the user may choose the file.

upload_firmware(file, burst)

Loads firmware or firmware patches from a file. The burst parameter determines whether to use I2C burst writes. Returns the actual number of bytes loaded.
See the COM interface document for more details.

upload_image_file(file, offset, length)

Loads a test image (or any binary data) to a supported emulator platform. The offset and length parameters are optional. Same as the COM interface function.

command(cmd, param)

The command() method sends a WM_COMMAND message to the DevWare main window. See the COM interface document for more details.

stop(bool)

Stops or starts the image capture and image display threads in DevWare. Call stop(True) to stop the threads, and stop(False) to resume them. Every call to stop(True) must be matched with a call to stop(False). DevWare stops the threads before executing an ini file preset, so this function will have no effect in that situation. But if your Python code may run in a thread you created, or may be called from a plug-in or from the COM interface then the capture and display threads may be running concurrently with your Python code.

begin_access_regs()

Tells DevWare that register accesses are following. If the device driver can't do simultaneous register access and frame capture then this function will pause the image capture thread. Using this function is not necessary, but calling begin_access_regs() before a sequence of many register accesses saves the overhead of pausing and unpausing the capture thread on each register access. This function is typically not needed in ini file presets because the capture thread is normally already turned off before the ini preset is executed. Every call to this function must be matched with a call to end_access_regs() or else the capture thread will not resume.

end_access_regs()

Resume the image capture thread if it was paused by a call to begin_access_regs().

log(string)

If the Register Log window is enabled, adds a string to the log.

get_warning_choice(id)

Get the automatic response to the DevWare warning dialog given by the id number. The response can be devware.IDOK for OK or Yes, devware.IDNO for No, or -1 to show the warning dialog.

set_warning_choice(id, choice)

Set the automatic response to the DevWare warning dialog.

reset_warnings()

Reset all warning dialogs to be shown (no automatic response).

close()

Equivalent to clicking the close button on the DevWare main window. This is may be preferred to sys.exit(), which may cause an error message pop-up dialog. The function allows a parameter, but ignores it. Note that this function does return, and if executed in the DevWare main UI thread, DevWare doesn't exit until the script is finished.