Table of Contents | ||
---|---|---|
|
...
If there is a preset called [Python: Unload], DevWare will automatically execute it when the corresponding ini file window is closed, or when DevWare exits. This can be used to clean up background threads.
DevWare only executes [Python:] when the ini file is opened in a Presets window. In scripts you have to execute [Python:] explicitly if the file isn't in a window, or in applications outside of DevWare.
You can load an ini file into a DevWare Presets window with:
devware.open_ini_file(inifilepath)
This will run [Python:].
DevWare automatically creates a variable called __IniFileName. When the execution of an ini file preset begins, DevWare sets the contents of this variable to the full path to the ini file. This is useful for accessing other files in the same directory as the current ini file. Note that when execution of the preset ends, the variable reverts back to its previous value, so the variable is not meaningful if accessed from a background thread that remains running after the preset that launched it is finished. If the ini file path is needed in a thread function, then it must be passed to the thread function as a parameter.
...
When the user invokes [Python: Thread Test] in the Presets dialog, the DevWare UI thread shuts down the camera and display threads, executes [Python: Thread Test] (which only creates a new thread and then finishes), and then resumes the camera and display threads. Simultaneously the new thread begins executing and remains alive after [Python: Thread Test] has finished. The 'test_run' thread increments the COARSE_INTEGRATION_TIME register 60, 120, 180, … 1200 every 1000ms until finished, which takes about 20 seconds. When the function exits the thread self-destructs.
If there is a preset called [Python: Unload], DevWare will automatically execute it when the corresponding ini file window is closed, or when DevWare exits. This can be used to clean up background threads.
Subprocesses
If the use of a Subprocess is necessary instead of a thread, "sys.prefix" can be used to ensure that the same version of Python is being used.
An example;
import os
import sys
import subprocess
...
reg | Returns a RegisterSet object that can be used to conveniently access the sensor registers. | |
name | Sensor name. Ex. 'A-3132SOC'. | |
version_name | Sensor version as a string. Ex: 'REV2' | |
versionsensor | Sensor version as an integer. Ex: 2 | |
minor_version | Sensor minor version as an integer. Ex: | 21 |
part_number | Sensor part number as a string. Ex: 'MT9T112' | |
product_variant | Sensor product variant. Ex: ‘Clarity+’ | |
file_name | Sensor data file name. For a physical sensor, this is the .xsdat file. For bitmap or video file pseudo-sensor, it's the image or video file. | |
base_addr | Sensor SHiP base address. Ex: 0x78. Read/write. | |
num_regs | Number of registers. | |
addr_size | Width of a register address in bits. Usually 8 or 16. | |
data_size | Width of a register in bits. Usually 8 or 16. | |
width | Current image width. To change use apbase.image() for now. | |
height | Current image height. To change use apbase.image() for now. | |
image_type | Current image type as a string. To change use apbase.image() for now. | |
full_width | Nominal full image width of sensor. | |
full_height | Nominal full image width of sensor. | |
pixel_bits | Significant bits per pixel. | |
pixel_bytes | Bytes per pixel in memory. | |
fuse_id | Fuse ID of sensor. | |
fuse_id_far1 | Fuse ID of ISP's Sensor #1. | |
fuse_id_far2 | Fuse ID of ISP's Sensor #2. |
...