part02-develope.tex 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. %!TEX root = ../Kapture2 Docu.tex
  2. \chapter{GUI Developement}
  3. \label{ch:dev}
  4. \section{Pagackelist}
  5. \begin{itemize}
  6. \item PyQT4
  7. \item sip
  8. \item pyqtgraph
  9. \item numpy
  10. \item psutil
  11. \item pyepics
  12. \item setuptools
  13. \end{itemize}
  14. \section{misc}
  15. \label{ch:dev:misc}
  16. 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.
  17. 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.
  18. Also it should work also on the old KAPTURE-1 System but it has not been tested.
  19. \section{Design}
  20. \label{ch:dev:misc}
  21. From bottom to top.
  22. \subsection{Modules}
  23. \subsubsection*{base/backend/board/communication}
  24. This contains the \code{class PCI}, witch wrapps the systemcalls for the pci communication to the FPGA.
  25. It also creates one instance of the class with the name \code{pci}. By using
  26. \begin{lstlisting}
  27. from .communication import pci
  28. \end{lstlisting}
  29. one can then read and write to the FPGA.
  30. 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.
  31. \subsubsection*{base/backend/board/board\_config}
  32. 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.
  33. 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
  34. \begin{enumerate}
  35. \item observers\_write:\\ those are controlled by the class it self. They write the settings to the board.
  36. \item observers\_for\_all:\\ they are called everytime one setting is changed - indipendent of the key
  37. \item observers:\\ they are called when the coresponding key changes. Those are mainly used to update the GUI.
  38. \end{enumerate}
  39. 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.
  40. In widgets one can register a observer via the function \code{observe(who, callback, key)}\\
  41. 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). \\
  42. callback is the function that will be called and needs to have one parameter by wich the new value will be passed.\\
  43. key is the setting that will be observed.
  44. When the widget will be deleted all coresponding observers need to be removed by \code{unobserve(who, key)}!
  45. One example from acquiresettings widget
  46. \begin{lstlisting}
  47. def __init__(...):
  48. self.board_config = board.get_board_config(board_id)
  49. self.fileSizeOutLabel = self.createLabel("??")
  50. self.board_config.observe(self.fileSizeOutLabel, self.set_filesize, 'turns_observe')
  51. .
  52. .
  53. def set_filesize(self, state):
  54. .
  55. .
  56. def closeEvent(self, event):
  57. self.board_config.unobserve(self.fileSizeOutLabel, 'turns_observe')
  58. .
  59. .
  60. \end{lstlisting}
  61. \subsubsection*{base/backend/board/sequences}
  62. 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.
  63. The module contains to function:\\
  64. \code{def read_sequence(board_version)}\\
  65. \code{def run_sequnce(board_id, sequence, progressbar=None)}
  66. 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.
  67. \subsubsection*{base/backend/DataSet}
  68. Contains measured data. It has all the needed functions to open files, decode them and prepare them for plotting etc.
  69. \subsubsection*{base/backend/TimeScan}
  70. Class to read and generate timescans files.
  71. \subsubsection*{base/backendinterface}
  72. The most messy module. It contains a vast amount of functions.
  73. Including:\\
  74. wrapperfunctions for the \code{board_control} \\
  75. functions to run the sequences\\
  76. everything for data acquisition
  77. \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.
  78. there are by now:
  79. \begin{itemize}
  80. \item AcquireSettingsWidget
  81. \item PlotWidget
  82. \item SingleReadWidget
  83. \item TimeingWidget
  84. \item TimescanWidget
  85. \item EpicsWidget
  86. \item AdcWidget
  87. \item UpdateCalibrationWidget
  88. \item CorrelationWidget
  89. \end{itemize}
  90. To activate a widget put the modulename in widgets/\_\_init\_\_.py
  91. \newpage
  92. \section{FPGA stuff}
  93. \TextGrafik[H]{Bank Register}{pl:bank}{1}{BankRegister.PNG}