Th3Tr00p3r/gSTED-sFCS
Python-based control & analysis software for our optical measurement system
gSTED-sFCS
Python-based control GUI and analysis software for our optical measurement system.
How this project works:
GUI
-
.uifiles are created graphically using Qt Designer, and are dynamically compiled into Python from within thegui.pymodule. -
Signals/slots (similar to callbacks) are coded as methods for the classes that are named after the windows (
MainWindow,SettingsWindow, etc.). -
Finally, when running the project (
main.py), aMainWindow()object is instantiated and the window is shown on screen.
Implemetation
- The
./logicpackage contains everything other than the most basic GUI - any button press triggers a slot ingui.pywhich in turn calls a function from theslot_implementations.pymodule, which in turn calls upon any of the other modules. In this way the GUI is completely seperated from the implementation and the physical devices.
Physical Device Control
- The
devices.pymodule contains a high-level API for communicating with the instruments, subclassed from the more generaldrivers.py, where existing packages (pyVISA, nidaqmx, instrumental etc.) are imported.
What's here/Noteworthy files:
-
./sfcs_sted.epj- 'Eric IDE' project file, which nicely ties everything together. -
./gui/gui.py- GUI module, containing strictly user interaction signals and slots, the slots implemented inlogic.py. -
./logic/slot_implementations.py- general implementations, slowly taking shape when things are moved to seperate modules. Currently contains mostly implementations of the main application stuff (App()class) and the GUI windows (i.e.MainWin()class). -
./logic/devices.py- module implementing front-end device interaction withlogic.pyand back-end driver communication with physical instruments through subclassing driver implementations indrivers.py -
./logic/helper.py- general helper functions used throughout the project. -
./settings/default_settings.csv- default setting file, initial values for all editable GUI widgets. -
.pre-commit-config.yaml,.flake8,pyproject.toml- these are configuration files for git pre-commit hooks (stuff performed right before commiting). They enforce better code quality (and let us focus on the content).
Notable Dependencies:
-
Python 3.10.10
-
Eric IDE (optional, but was invalueable during development) - very useful for Python GUI projects.
-
PyQt5 - Qt-Python API, used for the GUI (installed with Eric IDE).
-
qasync - to make PyQt5 work with Python's
asynciolibrary. -
NumPy.
-
matplotlib - used for plotting.
-
pyVISA - communication with VISA-supported devices.
-
nidaqmx - communication with NI-DAQmx supported devices.
-
DCx Camera interfaces, Instrumental-lib, nicelib, - communication with DC480 cameras.
-
ftd2xx - communication with UM232, which is a usb port to the FPGA (TDC data).
Installing Eric IDE on Windows:
Eric IDE is notoriously complicated to install properly. I've tried to make it easier with the following steps (assuming Python is installed and added to PATH):
-
Download Eric IDE distribution and extract to temporary folder.
-
In Command Prompt:
-
Go to a directory where you want to install Eric (along with a virtual environment), e.g.
cd c:\Python -
Create a virtual environment, e.g.
python -m venv eric_env -
Activate virtual environment, e.g.
eric_env\Scripts\activate.bat(or& .\activatein powershell).(eric_env)should appear on left of text. -
Install eric via pip e.g.
pip install eric-ide. -
Run install.py from the distribution (still in the virtual environment) e.g.
python C:\temporary folder\eric6-20.10\install.py. -
To have access to Qt Designer from within Eric IDE, go to 'settings' --> 'Qt' --> 'Qt Tools' and set 'Tools Directory' to
\eric_env\Lib\site-packages\qt5_applications\Qt\bin.
-
-
That's it, icons should appear on desktop.
Compiling the Software Correlator Dynamic Library
Windows:
-
Install MinGW
-
add /bin to Path
-
in cmd or PowerShell, cd to
/SoftCorrelatorDynamicLib -
Compile:
g++ -o SoftCorrelatorDynamicLib_win32.so -shared -fPIC -O2 SoftCorrelatorDynamicLib.cpp Correlator.cpp CountCorrelator.cpp CPhDelayCrossCorrelator.cpp CPhDelayLifeTimeCrossCorrelator.cpp
MacOS:
-
in terminal, cd to
/SoftCorrelatorDynamicLib -
Compile:
g++ -o SoftCorrelatorDynamicLib_mac.so -shared -fPIC -O2 SoftCorrelatorDynamicLib.cpp Correlator.cpp CountCorrelator.cpp CPhDelayCrossCorrelator.cpp CPhDelayLifeTimeCrossCorrelator.cpp