123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- %!TEX root = ../Kapture2 Docu.tex
- \chapter{GUI Developement}
- \label{ch:dev}
- \section{Pagackelist}
- \begin{itemize}
- \item PyQT4
- \item sip
- \item pyqtgraph
- \item numpy
- \item psutil
- \item pyepics
- \item setuptools
- \end{itemize}
- \section{misc}
- \label{ch:dev:misc}
- The Code is written to be working on both Python2 and Python3. At the moment this guide mostly only provides infos for the modules I devloped or changed.
- Before the Idea of KAPTURE2 came to live there was the idea to put multiple Kapture1 boards in on PC. So to the GUI a multi Kapture support was added. Unfortunately not in a perfect OOP fashion and therefore the code is now a little bit inconsistent. The new changes for KAPTURE2 mostly ingnore things from the multi kapture implementation and therefore the current GUI version does not realy support multi KAPTURE anymore - sry.
- Also it should work also on the old KAPTURE-1 System but it has not been tested.
- \section{Design}
- \label{ch:dev:misc}
- From bottom to top.
- \subsection{Modules}
- \subsubsection*{base/backend/board/communication}
- This contains the \code{class PCI}, witch wrapps the systemcalls for the pci communication to the FPGA.
- It also creates one instance of the class with the name \code{pci}. By using
- \begin{lstlisting}
- from .communication import pci
- \end{lstlisting}
- one can then read and write to the FPGA.
- There is also a dummy class wich is selected when the gui ist started with --testing parameter. It does not read or write to the hardware and can be therefore used while developing on a system without a KAPTURE board - even on a windows system.
- \subsubsection*{base/backend/board/board\_config}
- This contains the \code{class BoardConfiguration}. It is the central control Class for all the KAPTURE settings. (Like Delay, Turns to observe ...) It uses a dictonary to stores all the settings.
- It is mainly base on observers. The function \code{update(key, value)} is used to change a setting. It then calls the observers. There are 3 Types of observers
- \begin{enumerate}
- \item observers\_write:\\ those are controlled by the class it self. They write the settings to the board.
- \item observers\_for\_all:\\ they are called everytime one setting is changed - indipendent of the key
- \item observers:\\ they are called when the coresponding key changes. Those are mainly used to update the GUI.
- \end{enumerate}
- The \code{update} function has an additional parameter \code{write=True} it controls weather the observers\_write will be called or not. By default it is set to true. This is only needed for the function \code{read\_from\_board}, wich reads the settings from the FPGA, to prevent it from unnessesary rewrite it.
- In widgets one can register a observer via the function \code{observe(who, callback, key)}\\
- who is used as an identifyer when one wants to remove the observer. It can be nearly everything - Object, variable - usualy in the GUI it is the Object that will be changed (Like the lable that is updated). \\
- callback is the function that will be called and needs to have one parameter by wich the new value will be passed.\\
- key is the setting that will be observed.
- When the widget will be deleted all coresponding observers need to be removed by \code{unobserve(who, key)}!
- One example from acquiresettings widget
- \begin{lstlisting}
- def __init__(...):
- self.board_config = board.get_board_config(board_id)
- self.fileSizeOutLabel = self.createLabel("??")
- self.board_config.observe(self.fileSizeOutLabel, self.set_filesize, 'turns_observe')
- .
- .
- def set_filesize(self, state):
- .
- .
- def closeEvent(self, event):
- self.board_config.unobserve(self.fileSizeOutLabel, 'turns_observe')
- .
- .
- \end{lstlisting}
- \subsubsection*{base/backend/board/sequences}
- The sequences are used to initialize the board. They are series of commands send to the FPGA. It is controlled by the \code{board_config} and from the backendinterface.
- The module contains to function:\\
- \code{def read_sequence(board_version)}\\
- \code{def run_sequnce(board_id, sequence, progressbar=None)}
- The sequences are stored in json files in \textit{base/backend/board/sequences/sequence\_x.json} with x to be the board\_version. The board\_version is read by \code{board_config} from the FPGA.
- \subsubsection*{base/backend/DataSet}
- Contains measured data. It has all the needed functions to open files, decode them and prepare them for plotting etc.
- \subsubsection*{base/backend/TimeScan}
- Class to read and generate timescans files.
- \subsubsection*{base/backendinterface}
- The most messy module. It contains a vast amount of functions.
- Including:\\
- wrapperfunctions for the \code{board_control} \\
- functions to run the sequences\\
- everything for data acquisition
- \subsubsection*{widgets/} The most of the controling is in the widgets. They can be understood as some kind of modules. To add new functionality to the gui - like advanced analytics - one can just add a new Widget.
- there are by now:
- \begin{itemize}
- \item AcquireSettingsWidget
- \item PlotWidget
- \item SingleReadWidget
- \item TimeingWidget
- \item TimescanWidget
- \item EpicsWidget
- \item AdcWidget
- \item UpdateCalibrationWidget
- \item CorrelationWidget
- \end{itemize}
- To activate a widget put the modulename in widgets/\_\_init\_\_.py
- \newpage
- \section{FPGA stuff}
- \TextGrafik[H]{Bank Register}{pl:bank}{1}{BankRegister.PNG}
|