4$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlpictureA{tex2html_wrap7886}%
-\includegraphics[width=\textwidth]{images/sample_with_fluorescence}%
-\lthtmlpictureZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{section}
-\stepcounter{subsection}
-{\newpage\clearpage
-\lthtmlpictureA{tex2html_wrap7892}%
-\includegraphics[width=\textwidth]{images/bad_ff_col}%
-\lthtmlpictureZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsection}
-{\newpage\clearpage
-\lthtmlpictureA{tex2html_wrap7897}%
-\includegraphics[width=\textwidth]{images/FFSetup}%
-\lthtmlpictureZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{section}
-\stepcounter{subsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline7904}%
-$ Vthreshold=7$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline7906}%
-$ Counts=500$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline7908}%
-$ Resolution=4$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline7910}%
-$ \pm$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlpictureA{tex2html_wrap7911}%
-\includegraphics[width=\textwidth]{images/noise_thresholdscanuntrimmed}%
-\lthtmlpictureZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlpictureA{tex2html_wrap7915}%
-\includegraphics[width=\textwidth]{images/trimbitdistribution}%
-\lthtmlpictureZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlpictureA{tex2html_wrap7919}%
-\includegraphics[width=\textwidth]{images/trimbitplot}%
-\lthtmlpictureZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlpictureA{tex2html_wrap7923}%
-\includegraphics[width=\textwidth]{images/noise_thresholdscantrimmed}%
-\lthtmlpictureZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{section}
-\stepcounter{subsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline7932}%
-$ \cdot$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{section}
-\stepcounter{section}
-\stepcounter{subsection}
-\stepcounter{chapter}
-\stepcounter{section}
-\stepcounter{section}
-\stepcounter{section}
-\stepcounter{section}
-\stepcounter{chapter}
-\stepcounter{section}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline7946}%
-$ \alpha_{jm}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline7948}%
-$ R_m$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline7950}%
-$ \Phi_m$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline7952}%
-$ D_m$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline7954}%
-$ c_m$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline7956}%
-$ o_m$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline7958}%
-$ k_m$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7960}%
-$\displaystyle \alpha_{jm}=\Phi_m-{\ensuremath{\left({{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{180}}}}{{\ensuremath{\displaystyle{\pi}}}}}}}}\right)}}\arctan{\ensuremath{\left({{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{D_m-pj}}}}{{\ensuremath{\displaystyle{R_m}}}}}}}}\right)}}$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7962}%
-$\displaystyle \alpha_{jm}=o_m+{\ensuremath{\left({{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{180}}}}{{\ensuremath{\displaystyle{\pi}}}}}}}}\right)}}c_mk_m+{\ensuremath{\left({{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{180}}}}{{\ensuremath{\displaystyle{\pi}}}}}}}}\right)}}\arctan{\ensuremath{\left[{{\ensuremath{\left({j-c_m}\right)}}k_m}\right]}}$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7965}%
-$\displaystyle c_m$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7967}%
-$\displaystyle =$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7969}%
-$\displaystyle {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{D_m}}}}{{\ensuremath{\displaystyle{p}}}}}}};$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7971}%
-$\displaystyle k_m$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7975}%
-$\displaystyle {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{p}}}}{{\ensuremath{\displaystyle{R_m}}}}}}};$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7977}%
-$\displaystyle o_m$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7981}%
-$\displaystyle \Phi_m-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{180}}}}{{\ensuremath{\displaystyle{\pi}}}}}}}{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{D_m}}}}{{\ensuremath{\displaystyle{R_m}}}}}}}.$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7984}%
-$\displaystyle \Phi_m$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7988}%
-$\displaystyle o_m+{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{180}}}}{{\ensuremath{\displaystyle{\pi}}}}}}}c_mk_m;$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7990}%
-$\displaystyle R_m$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7994}%
-$\displaystyle {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{p}}}}{{\ensuremath{\displaystyle{k_m}}}}}}};$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay7996}%
-$\displaystyle D_m$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8000}%
-$\displaystyle c_m p.$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{section}
-\stepcounter{subsection}
-\stepcounter{subsubsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8005}%
-$ {\ensuremath{{2\theta}}}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8007}%
-$ 2\theta$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsubsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8010}%
-$\displaystyle {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\mathrm{d}{}\, }}\bf {\sigma}}}}}{{\ensuremath{\displaystyle{{\ensuremath{\mathrm{d}{}\, }}\Omega}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8012}%
-$ \Omega$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8014}%
-$\displaystyle {I_0}\Delta t \Delta\Omega{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\mathrm{d}{}\, }}\bf {\sigma}}}}}{{\ensuremath{\displaystyle{{\ensuremath{\mathrm{d}{}\, }}\Omega}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8016}%
-$ \Delta t$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8018}%
-$ \Delta\Omega$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8020}%
-$ I_0$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8024}%
-$ \Delta\Omega\propto \Delta {\ensuremath{{2\theta}}}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8035}%
-$ P$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8037}%
-$ k$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8039}%
-$ k=1,\ldots,P$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8041}%
-$ N_k$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8043}%
-$ 2\theta\equiv{\ensuremath{{2\theta}}}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8045}%
-$\displaystyle b_{k,j}={\ensuremath{\left[{{\ensuremath{{2\theta}}}_{k,j}^{-},{\ensuremath{{2\theta}}}_{k,j}^{+}}\right]}},\qquad j=1,\ldots,N_k
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8047}%
-$\displaystyle \hat{b}_{k,j}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{{2\theta}}}_{k,j}^{+}+{\ensuremath{{2\theta}}}_{k,j}^{-}}}}}{{\ensuremath{\displaystyle{2}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8049}%
-$\displaystyle {\ensuremath{\left|{b_{k,j}}\right|}}={\ensuremath{{2\theta}}}_{k,j}^{+}-{\ensuremath{{2\theta}}}_{k,j}^{-}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8051}%
-$ C_{k,j}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8053}%
-$ e_{k,j}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8055}%
-$ m_{k,j}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8057}%
-$ b_{k,j}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8059}%
-$\displaystyle I_{k,j}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{e_{k,j}}}}}{{\ensuremath{\displaystyle{m_{k,j}}}}}}}}{\ensuremath{\left({C_{k,j}+\min{\ensuremath{\left({1,C_{k,j}}\right)}}}\right)}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8061}%
-$\displaystyle \sigma_{I_{k,j}}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{e_{k,j}}}}}{{\ensuremath{\displaystyle{m_{k,j}}}}}}}}\sqrt{{\ensuremath{\left({C_{k,j}+1}\right)}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8063}%
-$\displaystyle r_{k,j}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{I_{k,j}}}}}{{\ensuremath{\displaystyle{{\ensuremath{\left|{b_{k,j}}\right|}}}}}}}}}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{e_{k,j}}}}}{{\ensuremath{\displaystyle{m_{k,j}{\ensuremath{\left|{b_{k,j}}\right|}}}}}}}}}{\ensuremath{\left({C_{k,j}+\min{\ensuremath{\left({1,C_{k,j}}\right)}}}\right)}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8065}%
-$\displaystyle \sigma_{r_{k,j}}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\sigma_{I_{k,j}}}}}}{{\ensuremath{\displaystyle{{\ensuremath{\left|{b_{k,j}}\right|}}}}}}}}}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{e_{k,j}}}}}{{\ensuremath{\displaystyle{{\ensuremath{\left|{b_{k,j}}\right|}}m_{k,j}}}}}}}}\sqrt{{\ensuremath{\left({C_{k,j}+1}\right)}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8067}%
-$ M$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8069}%
-$\displaystyle B_\ell=[{\ensuremath{{2\theta}}}_0+(\ell-1)B, {\ensuremath{{2\theta}}}_0+\ell B],\qquad \ell=1,\ldots,M
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8071}%
-$\displaystyle {\ensuremath{\left|{B_\ell}\right|}}=B$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8073}%
-$\displaystyle \hat{B}_\ell={\ensuremath{{2\theta}}}_0+(\ell-1/2)B,$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8075}%
-$ {\ensuremath{{2\theta}}}_0$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8077}%
-$ {\ensuremath{{2\theta}}}_{max}={\ensuremath{{2\theta}}}_0+MB$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8079}%
-$ \ell$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8081}%
-$\displaystyle b_{k,j}$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8082}%
-$\displaystyle \qquad {\ensuremath{\left|{ b_{k,j}\cap B_\ell }\right|}} > 0.
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8085}%
-$\displaystyle \qquad \hat{b}_{k,j}\in B_\ell .
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8089}%
-$ B_\ell$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8091}%
-$ N_E$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8093}%
-$ O_n$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8095}%
-$ O$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8097}%
-$ \sigma_{O_n}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8099}%
-$ \nu_n$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8101}%
-$\displaystyle \langle O\rangle ={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-\mathop{\sum}_{n=1}^{N_E}\nu_n
-O_n\sigma_{O_n}^{-2}
-}}}}{{\ensuremath{\displaystyle{
-\mathop{\sum}_{n=1}^{N_E}\nu_n
-\sigma_{O_n}^{-2}
-}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8103}%
-$\displaystyle {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\left|{ b_{k,j}\cap B_\ell }\right|}}}}}}{{\ensuremath{\displaystyle{B}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8105}%
-$ k,j$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8109}%
-$\displaystyle X_\ell=\mathop{\sum_{k,j}}_{ {\ensuremath{\left|{ b_{k,j}\cap B_\ell }\right|}} > 0}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\left|{ b_{k,j}\cap B_\ell }\right|}}}}}}{{\ensuremath{\displaystyle{B}}}}}}}\ r_{k,j}\ {\ensuremath{\left({\sigma_{r_{k,j}}}\right)}}^{-2}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8111}%
-$\displaystyle Y_\ell=\mathop{\sum_{k,j}}_{ {\ensuremath{\left|{ b_{k,j}\cap B_\ell }\right|}} > 0}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\left|{ b_{k,j}\cap B_\ell }\right|}}}}}}{{\ensuremath{\displaystyle{B}}}}}}}\ {\ensuremath{\left({\sigma_{r_{k,j}}}\right)}}^{-2}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8113}%
-$\displaystyle R_\ell={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{X_\ell}}}}{{\ensuremath{\displaystyle{Y_\ell}}}}}}};
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8115}%
-$\displaystyle \sigma_{R_\ell}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{\sqrt{Y_\ell}}}}}}}}.
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8117}%
-$ R_\ell$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8119}%
-$ \sigma_{R_\ell}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8121}%
-$ B$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8123}%
-$ K$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8127}%
-$\displaystyle \mathop{\sum}_{\ell=1}^M{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{KR_\ell}}}}{{\ensuremath{\displaystyle{K^2\sigma_{R_\ell}^2}}}}}}}=
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{K}}}}}}}
-\mathop{\sum}_{\ell=1}^M{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{R_\ell}}}}{{\ensuremath{\displaystyle{\sigma_{R_\ell}^2}}}}}}}=M
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8131}%
-$\displaystyle K={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-1
-}}}}{{\ensuremath{\displaystyle{
-M
-}}}}}}}\mathop{\sum}_{\ell=1}^M{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{R_\ell}}}}{{\ensuremath{\displaystyle{\sigma_{R_\ell}^2}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8133}%
-$\displaystyle \hat{B}_\ell, \quad KR_\ell, \quad K\sigma_{R_\ell}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsubsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8144}%
-$ X_\ell=0$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8146}%
-$ Y_\ell=0$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8148}%
-$ b$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8152}%
-$\displaystyle X_\ell={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\left|{ b\cap B_\ell }\right|}}}}}}{{\ensuremath{\displaystyle{B}}}}}}}\
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{e(C+1)}}}}{{\ensuremath{\displaystyle{m|b|}}}}}}}\
-{\ensuremath{\left({
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{|b|m}}}}{{\ensuremath{\displaystyle{e\sqrt{C+1}}}}}}}}
-}\right)}}^{2}
-={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\left|{ b\cap B_\ell }\right|}}}}}}{{\ensuremath{\displaystyle{B}}}}}}}{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{|b|m}}}}{{\ensuremath{\displaystyle{e}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8154}%
-$\displaystyle Y_\ell={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\left|{ b\cap B_\ell }\right|}}}}}}{{\ensuremath{\displaystyle{B}}}}}}}\
-{\ensuremath{\left({
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{|b|m}}}}{{\ensuremath{\displaystyle{e\sqrt{C+1}}}}}}}}
-}\right)}}^{2}
-={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\left|{ b\cap B_\ell }\right|}}}}}}{{\ensuremath{\displaystyle{B}}}}}}}{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{|b|^2m^2}}}}{{\ensuremath{\displaystyle{e^2(C+1)}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8156}%
-$\displaystyle R_\ell={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{X_\ell}}}}{{\ensuremath{\displaystyle{Y_\ell}}}}}}}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{e(C+1)}}}}{{\ensuremath{\displaystyle{m|b|}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8160}%
-$\displaystyle \sigma_{R_\ell}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{\sqrt{Y_\ell}}}}}}}}=
-\sqrt{{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{B}}}}{{\ensuremath{\displaystyle{{\ensuremath{\left|{ b\cap B_\ell }\right|}}}}}}}}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{e\sqrt{(C+1)}}}}}{{\ensuremath{\displaystyle{|b|m}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8164}%
-$\displaystyle \sqrt{{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{B}}}}{{\ensuremath{\displaystyle{{\ensuremath{\left|{ b\cap B_\ell }\right|}}}}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8167}%
-$ \hat{b}_{j,k}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8169}%
-$ \hat{B}_\ell$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8172}%
-$ C_0$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8176}%
-$ \sqrt{C_0}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8178}%
-$ n$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8180}%
-$\displaystyle P(n)={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{C_0^n{\ensuremath{\mathrm{e}}}^{-C_0}
-}}}}{{\ensuremath{\displaystyle{
-n!}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8182}%
-$\displaystyle \mathop{\sum}_{n=0}^{+\infty}
-P(n)=1\ ;
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8184}%
-$\displaystyle \langle n\rangle=\mathop{\sum}_{n=0}^{+\infty}
-nP(n)=C_0\ ;
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8186}%
-$\displaystyle \langle n^2\rangle=\mathop{\sum}_{n=0}^{+\infty}
-n^2 P(n)=C_0^2+C_0\ ;
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8188}%
-$\displaystyle \sigma_{C_0}=\sqrt{\langle n^2\rangle-\langle n\rangle^2}=\sqrt{C_0}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8192}%
-$\displaystyle \chi^2 = \mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\left({F_j-O_j}\right)}}^2
-}}}}{{\ensuremath{\displaystyle{
-\sigma_j^2
-}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8194}%
-$ O_j$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8196}%
-$ F_j$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8198}%
-$ \sigma_j$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8200}%
-$\displaystyle \chi_{(0)}^2 = \mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\left({F_j-C_j}\right)}}^2
-}}}}{{\ensuremath{\displaystyle{
-C_j
-}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8202}%
-$\displaystyle \chi_{(1)}^2 = \mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\left({F_j-{\ensuremath{\left({C_j+\min{\ensuremath{\left({1,C_j}\right)}}}\right)}}}\right)}}^2
-}}}}{{\ensuremath{\displaystyle{
-C_j+1
-}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsection}
-\stepcounter{subsubsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8208}%
-$ N_{\mathrm{obs}}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8210}%
-$ C_j,\quad j=1\ldots N_{\mathrm{obs}}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8212}%
-$ x$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8216}%
-$\displaystyle x=\langle x\rangle={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{ N_{\mathrm{obs}}}}}}}}}
- \mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}C_j\ .
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8218}%
-$\displaystyle \sigma_x=\sqrt{\langle x^2\rangle-\langle x\rangle^2}=\sqrt{
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{ N_{\mathrm{obs}}}}}}}}}
- \mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}C_j^2-{\ensuremath{\left({
- {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{ N_{\mathrm{obs}}}}}}}}}
- \mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}C_j
- }\right)}}
- }
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8220}%
-$\displaystyle \sigma_x={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{ N_{\mathrm{obs}}}}}}}}}\sqrt{ \mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}C_j }
-=\sqrt{{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\langle x\rangle}}}}{{\ensuremath{\displaystyle{N_{\mathrm{obs}}}}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsubsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8223}%
-$ C_j=0$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8225}%
-$ N_{\mathrm{obs}}^*$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8227}%
-$\displaystyle x=\langle x\rangle^*={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{ N_{\mathrm{obs}}^*}}}}}}}
- \mathop{\sum}_ {\stackrel{1\leqslant j\leqslant N_{\mathrm{obs}}}{{C_j>0}}}
- C_j={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{ N_{\mathrm{obs}}^*}}}}}}}
- \mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}C_j = {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{N_{\mathrm{obs}}}}}}{{\ensuremath{\displaystyle{N_{\mathrm{obs}}^*}}}}}}}\langle x\rangle
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8229}%
-$\displaystyle \sigma_{x^*}= {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{N_{\mathrm{obs}}}}}}{{\ensuremath{\displaystyle{N_{\mathrm{obs}}^*}}}}}}}\sigma_x = \sqrt{{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{N_{\mathrm{obs}}}}}}{{\ensuremath{\displaystyle{N_{\mathrm{obs}}^*}}}}}}}}
-\sqrt{{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\langle x\rangle}}}}{{\ensuremath{\displaystyle{N_{\mathrm{obs}}^*}}}}}}}}=\sqrt{{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\langle x\rangle^*}}}}{{\ensuremath{\displaystyle{N_{\mathrm{obs}}^*}}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8231}%
-$ C_j$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsubsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8238}%
-$\displaystyle \chi^2 = \mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\left({x-O_j}\right)}}^2
-}}}}{{\ensuremath{\displaystyle{
-\sigma_j^2
-}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8240}%
-$\displaystyle x= \langle x \rangle_{\!\mathrm{w}}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-\mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{O_j
-}}}}{{\ensuremath{\displaystyle{
-\sigma_j^2
-}}}}}}}
-}}}}{{\ensuremath{\displaystyle{
-\mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1
-}}}}{{\ensuremath{\displaystyle{
-\sigma_j^2
-}}}}}}}
-}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8244}%
-$\displaystyle \sigma_{\langle x \rangle_{\!\mathrm{w}}} = {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-1
-}}}}{{\ensuremath{\displaystyle{\sqrt{
-\mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1
-}}}}{{\ensuremath{\displaystyle{
-\sigma_j^2
-}}}}}}}
-}}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8246}%
-$\displaystyle \mathsf{GoF}=
-\sqrt{
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-\mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{O_j^2
-}}}}{{\ensuremath{\displaystyle{
-\sigma_j^2
-}}}}}}}
--{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-{\ensuremath{\left[{
-\mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{O_j
-}}}}{{\ensuremath{\displaystyle{
-\sigma_j^2
-}}}}}}}
-}\right]}}^2
-}}}}{{\ensuremath{\displaystyle{ \mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1
-}}}}{{\ensuremath{\displaystyle{
-\sigma_j^2
-}}}}}}} }}}}}}}
-}}}}{{\ensuremath{\displaystyle{
-N_{\mathrm{obs}}-1
-}}}}}}}
-}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8248}%
-$\displaystyle {\sigma}_{\langle x \rangle_{\!\mathrm{w}}}^{\mathrm{corrected}} = \mathsf{GoF}\ \sigma_{\langle x \rangle_{\!\mathrm{w}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsubsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8251}%
-$ O_j=C_j$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8253}%
-$ \sigma_j^2=C_j$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8255}%
-$\displaystyle \langle x \rangle_{\!\mathrm{w(1)}}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-{N_{\mathrm{obs}}}
-}}}}{{\ensuremath{\displaystyle{
-\mathop{\sum}_{j=1}^{N_{\mathrm{obs}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1
-}}}}{{\ensuremath{\displaystyle{
-C_j
-}}}}}}}
-}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8263}%
-$\displaystyle \sigma_{\langle x \rangle_{\!\mathrm{w(1)}}} = {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-1
-}}}}{{\ensuremath{\displaystyle{\sqrt{
-\mathop{\sum}_{\stackrel{1\leqslant j\leqslant N_{\mathrm{obs}}}{{C_j>0}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1
-}}}}{{\ensuremath{\displaystyle{
-C_j
-}}}}}}}
-}}}}}}}}=\sqrt{{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\langle x \rangle_{\!\mathrm{w(1)}}}}}}{{\ensuremath{\displaystyle{
-N_{\mathrm{obs}}^*
-}}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8265}%
-$\displaystyle \mathsf{GoF}_{(1)}=
-\sqrt{
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-\mathop{\sum}_{\stackrel{1\leqslant j\leqslant N_{\mathrm{obs}}}{{C_j>0}}}
-\!\!\!\!C_j
--{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-{\ensuremath{\left[{
-N_{\mathrm{obs}}^*
-}\right]}}^2
-}}}}{{\ensuremath{\displaystyle{ \mathop{\sum}_{\stackrel{1\leqslant j\leqslant N_{\mathrm{obs}}}{{C_j>0}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1
-}}}}{{\ensuremath{\displaystyle{
-C_j
-}}}}}}} }}}}}}}
-}}}}{{\ensuremath{\displaystyle{
-N_{\mathrm{obs}}^*-1
-}}}}}}}
-}
-=\sqrt{
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{N_{\mathrm{obs}}^*}}}}{{\ensuremath{\displaystyle{N_{\mathrm{obs}}^*-1}}}}}}}
-{\ensuremath{\left({
-\langle x\rangle^*-\langle x \rangle_{\!\mathrm{w(1)}}
-}\right)}}
-}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8267}%
-$ \langle x\rangle^*$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8269}%
-$\displaystyle {\sigma}_{\langle x \rangle_{\!\mathrm{w(1)}}}^{\mathrm{corrected}} = \mathsf{GoF}_{(1)}\ \sigma_{\langle x \rangle_{\!\mathrm{w(1)}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsubsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8272}%
-$ O_j=C_j+\min{\ensuremath{\left({1,C_j}\right)}}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8274}%
-$ \sigma_j^2=C_j+1$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8276}%
-$\displaystyle \langle x \rangle_{\!\mathrm{w(2)}}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-{N_{\mathrm{obs}}^*}
-}}}}{{\ensuremath{\displaystyle{
-\mathop{\sum}_{\stackrel{1\leqslant j\leqslant N_{\mathrm{obs}}}{{C_j>0}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1
-}}}}{{\ensuremath{\displaystyle{
-C_j+1
-}}}}}}}
-}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8278}%
-$\displaystyle \sigma_{\langle x \rangle_{\!\mathrm{w(2)}}} = {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-1
-}}}}{{\ensuremath{\displaystyle{\sqrt{
-\mathop{\sum}_{\stackrel{1\leqslant j\leqslant N_{\mathrm{obs}}}{{C_j>0}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1
-}}}}{{\ensuremath{\displaystyle{
-C_j+1
-}}}}}}}
-}}}}}}}}=\sqrt{{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\langle x \rangle_{\!\mathrm{w(2)}}}}}}{{\ensuremath{\displaystyle{
-N_{\mathrm{obs}}^*
-}}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8280}%
-$\displaystyle \mathsf{GoF}_{(2)}=
-\sqrt{
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-\mathop{\sum}_{\stackrel{1\leqslant j\leqslant N_{\mathrm{obs}}}{{C_j>0}}}
-\!\!\!\!C_j+N_{\mathrm{obs}}^*
--{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-{\ensuremath{\left[{
-N_{\mathrm{obs}}^*
-}\right]}}^2
-}}}}{{\ensuremath{\displaystyle{ \mathop{\sum}_{\stackrel{1\leqslant j\leqslant N_{\mathrm{obs}}}{{C_j>0}}}
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1
-}}}}{{\ensuremath{\displaystyle{
-C_j+1
-}}}}}}} }}}}}}}
-}}}}{{\ensuremath{\displaystyle{
-N_{\mathrm{obs}}^*-1
-}}}}}}}
-}
-=\sqrt{
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{N_{\mathrm{obs}}^*}}}}{{\ensuremath{\displaystyle{N_{\mathrm{obs}}^*-1}}}}}}}
-{\ensuremath{\left({
-\langle x\rangle^*-\langle x \rangle_{\!\mathrm{w(2)}}+1
-}\right)}}
-}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8284}%
-$\displaystyle {\sigma}_{\langle x \rangle_{\!\mathrm{w(2)}}}^{\mathrm{corrected}} = \mathsf{GoF}_{(2)}\ \sigma_{\langle x \rangle_{\!\mathrm{w(2)}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsubsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8291}%
-$\displaystyle \epsilon_x = {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\sigma_x}}}}{{\ensuremath{\displaystyle{x}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8295}%
-$ O(\epsilon_x^2)$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8299}%
-$ \propto\epsilon_x$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8303}%
-$ O(\epsilon_x^3)$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsubsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8306}%
-$ N_{\mathrm{obs}}=2$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8308}%
-$ C_1$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8310}%
-$ C_2$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8312}%
-$\displaystyle \langle x \rangle={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{C_1+C_2}}}}{{\ensuremath{\displaystyle{2}}}}}}}; \qquad \sigma_x={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\sqrt{C_1+C_2}}}}}{{\ensuremath{\displaystyle{2}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8314}%
-$\displaystyle \langle x \rangle_{\mathrm{w(2)}}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{2(C_1+1)(C_2+1)}}}}{{\ensuremath{\displaystyle{C_1+C_2+2}}}}}}}; \qquad
-\sigma_{\langle x \rangle_{\mathrm{w(2)}}}=\sqrt{{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{(C_1+1)(C_2+1)}}}}{{\ensuremath{\displaystyle{C_1+C_2+2}}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8316}%
-$ C_1,C_2$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8318}%
-$ \lambda$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8320}%
-$\displaystyle E{\ensuremath{\left({\langle x \rangle}\right)}} = \mathop{\sum}_{m,n=0}^{+\infty}
- {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{n+m}}}}{{\ensuremath{\displaystyle{2}}}}}}}P(n)P(m)=\mathop{\sum}_{m=0}^{+\infty}
- {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{m}}}}{{\ensuremath{\displaystyle{2}}}}}}}{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\lambda^m{\ensuremath{\mathrm{e}}}^{-\lambda}}}}}{{\ensuremath{\displaystyle{m!}}}}}}}
- +\mathop{\sum}_{n=0}^{+\infty}
- {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{n}}}}{{\ensuremath{\displaystyle{2}}}}}}}{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\lambda^n{\ensuremath{\mathrm{e}}}^{-\lambda}}}}}{{\ensuremath{\displaystyle{n!}}}}}}}
- =\lambda
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8322}%
-$\displaystyle E{\ensuremath{\left({\sigma_x^2}\right)}} = \mathop{\sum}_{m,n=0}^{+\infty}
- {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{n+m}}}}{{\ensuremath{\displaystyle{4}}}}}}}P(n)P(m)={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
- \lambda}}}}{{\ensuremath{\displaystyle{2}}}}}}};\qquad E{\ensuremath{\left({\sigma_x}\right)}} =\sqrt{{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\lambda}}}}{{\ensuremath{\displaystyle{2}}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8324}%
-$\displaystyle \langle x \rangle_{\mathrm{w(2)}}=\langle x \rangle + 1 -{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{(C_1-C_2)^2}}}}{{\ensuremath{\displaystyle{4(\langle x \rangle+1)}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8326}%
-$\displaystyle E{\ensuremath{\left({{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{(C_1-C_2)^2}}}}{{\ensuremath{\displaystyle{4(\langle x \rangle+1)}}}}}}}}\right)}} =
- \mathop{\sum}_{m,n=0}^{+\infty}
- {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{(n-m)^2}}}}{{\ensuremath{\displaystyle{2(n+m+2) }}}}}}}P(n)P(m)={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\mathrm{e}}}^{-2\lambda}}}}}{{\ensuremath{\displaystyle{2}}}}}}}
- \mathop{\sum}_{m,n=0}^{+\infty}
- {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{(n-m)^2}}}}{{\ensuremath{\displaystyle{(n+m+2) }}}}}}}{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\lambda^{n+m}}}}}{{\ensuremath{\displaystyle{n!m!}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8328}%
-$ s=n+m$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8330}%
-$ s=0\ldots +\infty$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8332}%
-$ n-m=s-2k$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8334}%
-$ k=0\ldots s$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8336}%
-$\displaystyle E{\ensuremath{\left({{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{(C_1-C_2)^2}}}}{{\ensuremath{\displaystyle{4(\langle x \rangle+1)}}}}}}}}\right)}} =
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{{\ensuremath{\mathrm{e}}}^{-2\lambda}}}}}{{\ensuremath{\displaystyle{2}}}}}}}
- \mathop{\sum}_{s=0}^{+\infty}
- \mathop{\sum}_{k=0}^{s}
- {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{(s-2k)^2(s+1)}}}}{{\ensuremath{\displaystyle{(s+2)! }}}}}}}{\lambda^{s}}
- \binom{s}{k}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{2}}}}}}}-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{2\lambda}}}}}}}+{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1-{\ensuremath{\mathrm{e}}}^{-2\lambda}}}}}{{\ensuremath{\displaystyle{4\lambda^2}}}}}}}
- %{n!m!}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8338}%
-$\displaystyle {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{E{\ensuremath{\left({\langle x \rangle_{\mathrm{w(2)}}-\langle x \rangle}\right)}}}}}}{{\ensuremath{\displaystyle{E{\ensuremath{\left({\langle x \rangle}\right)}}}}}}}}}=
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{2\lambda}}}}}}}+{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{2\lambda^2}}}}}}}-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1-{\ensuremath{\mathrm{e}}}^{-2\lambda}}}}}{{\ensuremath{\displaystyle{4\lambda^3}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8340}%
-$ \langle x \rangle$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8342}%
-$\displaystyle \epsilon = {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\sigma_x}}}}{{\ensuremath{\displaystyle{\langle x \rangle}}}}}}} =
-{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\lambda^{1/2}}}}}{{\ensuremath{\displaystyle{\sqrt{2} \lambda}}}}}}}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{1}}}}{{\ensuremath{\displaystyle{\sqrt{2\lambda}}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8344}%
-$\displaystyle {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{E{\ensuremath{\left({\langle x \rangle_{\mathrm{w(2)}}-\langle x \rangle}\right)}}}}}}{{\ensuremath{\displaystyle{E{\ensuremath{\left({\langle x \rangle}\right)}}}}}}}}}=
-O(\epsilon^2)
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsubsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8349}%
-$ \lambda=1,10,100,\ldots,1000000$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8353}%
-$ N=10^8$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8359}%
-$ \xi_\lambda=\sqrt{\lambda/N}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8361}%
-$ \epsilon_\lambda=\sqrt{\lambda/N}/\lambda=1/\sqrt{N\lambda}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8363}%
-$ E_\lambda$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8367}%
-$ e_\lambda=E_\lambda/\lambda$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8369}%
-$ e_\lambda/\epsilon_\lambda$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8371}%
-$ \lambda =$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8373}%
-$ \xi_\lambda = $%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8375}%
-$ \epsilon_\lambda$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8377}%
-$ {\langle x \rangle_{\!\mathrm{w(1)}}}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8379}%
-$ {\langle x \rangle_{\!\mathrm{w(2)}}}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8387}%
-$ e_\lambda$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8731}%
-$ {\langle x \rangle_{\!\mathrm{w(1)}}}\ :$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8735}%
-$ {\langle x \rangle^*}\ $%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8737}%
-$ \lambda<100$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8739}%
-$ {\langle x \rangle}\ $%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{subsection}
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8764}%
-$\displaystyle X_0=\eta_0 C_0
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8766}%
-$ \eta_0$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8768}%
-$ X$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8770}%
-$\displaystyle P'(X)=P(X/\eta_0)=P(n)\qquad\Biggl|\Biggr.\qquad \frac{X}{\eta_0}\equiv n\in\mathbb{Z}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8774}%
-$\displaystyle \langle X\rangle=\mathop{\sum}_{n=0}^{+\infty}
-\eta_0 nP(n)=\eta_0 C_0=X_0\ ;
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8776}%
-$\displaystyle \langle X^2\rangle=\mathop{\sum}_{n=0}^{+\infty}
-\eta_0^2 n^2 P(n)=\eta_0^2(C_0^2+C_0)=X_0^2+\eta_0 X_0\ ;
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8778}%
-$\displaystyle \sigma_X=\sqrt{\langle X^2\rangle-\langle X\rangle^2}=\sqrt{\eta_0 X_0}=\eta_0\sqrt{C_0}=\sqrt{\eta_0}\sqrt{X_0}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8780}%
-$ \sigma_X=\sqrt{\langle X\rangle}=\sqrt{X_0}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8782}%
-$\displaystyle \sigma_X=\sqrt{\eta_0}\sqrt{X_0}=\eta_0\sqrt{C_0}=\eta_0\sigma_{C_0}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_inline8786}%
-$ \sigma_{\eta_0}$%
-\lthtmlinlinemathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8788}%
-$\displaystyle \widehat{P}(\eta)={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{
-{\ensuremath{\mathrm{e}}}^{
--\frac{1}{2}
-{\ensuremath{\left({
-\frac{\eta-\eta_0}{\sigma_{\eta_0}}
-}\right)}}^2
-}
-}}}}{{\ensuremath{\displaystyle{
-\sigma_{\eta_0}\sqrt{2\pi}
-}}}}}}}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8790}%
-$\displaystyle \int_{-\infty}^{+\infty}{\ensuremath{\mathrm{d}{\eta}\, }}\mathop{\sum}_{n=0}^{+\infty}
-P(n)\widehat{P}(\eta)=1\ ;
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8792}%
-$\displaystyle \langle X\rangle=\int_{-\infty}^{+\infty}{\ensuremath{\mathrm{d}{\eta}\, }}\mathop{\sum}_{n=0}^{+\infty}
-\widehat{P}(\eta)\eta nP(n)=
-\mathop{\sum}_{n=0}^{+\infty}
- nP(n)
-\int_{-\infty}^{+\infty}{\ensuremath{\mathrm{d}{\eta}\, }} \widehat{P}(\eta)\eta
- =
-\eta_0 C_0=X_0\ ;
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8794}%
-$\displaystyle \langle X^2\rangle=\int_{-\infty}^{+\infty}{\ensuremath{\mathrm{d}{\eta}\, }}\mathop{\sum}_{n=0}^{+\infty}
-\widehat{P}(\eta)\eta^2 n^2 P(n)=
-\int_{-\infty}^{+\infty}{\ensuremath{\mathrm{d}{\eta}\, }}\widehat{P}(\eta)\eta^2
-\mathop{\sum}_{n=0}^{+\infty}
- n^2 P(n)
-=
-(\eta_0^2+\sigma_{\eta_0}^2)(C_0^2+C_0)\ ;
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-{\newpage\clearpage
-\lthtmlinlinemathA{tex2html_wrap_indisplay8796}%
-$\displaystyle {\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\sigma_X}}}}{{\ensuremath{\displaystyle{\langle X\rangle}}}}}}}={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\sqrt{\langle X^2\rangle-\langle X\rangle^2}}}}}{{\ensuremath{\displaystyle{\langle X\rangle}}}}}}}
-={\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\sqrt{
-\eta_0^2 C_0+\sigma_{\eta_0}^2C_0^2+\sigma_{\eta_0}^2 C_0
-}}}}}{{\ensuremath{\displaystyle{\eta_0C_0}}}}}}}=
-\sqrt{
-{\ensuremath{\left({{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{ \sigma_{C_0}}}}}{{\ensuremath{\displaystyle{C_0}}}}}}}}\right)}}^2
-+{\ensuremath{\left({{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\sigma_{\eta_0}}}}}{{\ensuremath{\displaystyle{\eta_0}}}}}}}}\right)}}^2+{\ensuremath{\left({{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\sigma_{\eta_0}}}}}{{\ensuremath{\displaystyle{\eta_0}}}}}}}{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\sigma_{C_0}}}}}{{\ensuremath{\displaystyle{C_0}}}}}}}}\right)}}^2
-}\approx\sqrt{
-{\ensuremath{\left({{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{ \sigma_{C_0}}}}}{{\ensuremath{\displaystyle{C_0}}}}}}}}\right)}}^2
-+{\ensuremath{\left({{\ensuremath{\displaystyle{\frac{{\ensuremath{\displaystyle{\sigma_{\eta_0}}}}}{{\ensuremath{\displaystyle{\eta_0}}}}}}}}\right)}}^2
-}
-$%
-\lthtmlindisplaymathZ
-\lthtmlcheckvsize\clearpage}
-
-\stepcounter{section}
-
-\end{document}
diff --git a/manual/docs/html/slsDetectors-FAQ/img1.png b/manual/docs/html/slsDetectors-FAQ/img1.png
deleted file mode 100644
index b3782ca43..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img1.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img10.png b/manual/docs/html/slsDetectors-FAQ/img10.png
deleted file mode 100644
index 0f10a1d65..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img10.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img11.png b/manual/docs/html/slsDetectors-FAQ/img11.png
deleted file mode 100644
index 062161f8c..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img11.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img12.png b/manual/docs/html/slsDetectors-FAQ/img12.png
deleted file mode 100644
index 5a2c4b41e..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img12.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img13.png b/manual/docs/html/slsDetectors-FAQ/img13.png
deleted file mode 100644
index 0c7129068..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img13.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img14.png b/manual/docs/html/slsDetectors-FAQ/img14.png
deleted file mode 100644
index 485f30aa8..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img14.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img15.png b/manual/docs/html/slsDetectors-FAQ/img15.png
deleted file mode 100644
index dd9d71687..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img15.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img16.png b/manual/docs/html/slsDetectors-FAQ/img16.png
deleted file mode 100644
index 29b005381..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img16.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img17.png b/manual/docs/html/slsDetectors-FAQ/img17.png
deleted file mode 100644
index 77ca19e83..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img17.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img18.png b/manual/docs/html/slsDetectors-FAQ/img18.png
deleted file mode 100644
index 2c8a090c5..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img18.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img19.png b/manual/docs/html/slsDetectors-FAQ/img19.png
deleted file mode 100644
index 3d666e3eb..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img19.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img2.png b/manual/docs/html/slsDetectors-FAQ/img2.png
deleted file mode 100644
index 3c64b751f..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img2.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img20.png b/manual/docs/html/slsDetectors-FAQ/img20.png
deleted file mode 100644
index f3596cb7e..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img20.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img21.png b/manual/docs/html/slsDetectors-FAQ/img21.png
deleted file mode 100644
index 64d3a5e2d..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img21.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img22.png b/manual/docs/html/slsDetectors-FAQ/img22.png
deleted file mode 100644
index 3d6c03b5b..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img22.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img23.png b/manual/docs/html/slsDetectors-FAQ/img23.png
deleted file mode 100644
index 04166b530..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img23.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img24.png b/manual/docs/html/slsDetectors-FAQ/img24.png
deleted file mode 100644
index 3f6f99e7c..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img24.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img25.png b/manual/docs/html/slsDetectors-FAQ/img25.png
deleted file mode 100644
index c3b280d38..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img25.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img26.png b/manual/docs/html/slsDetectors-FAQ/img26.png
deleted file mode 100644
index b6de65457..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img26.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img27.png b/manual/docs/html/slsDetectors-FAQ/img27.png
deleted file mode 100644
index 3c67b42f3..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img27.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img28.png b/manual/docs/html/slsDetectors-FAQ/img28.png
deleted file mode 100644
index 4c204ab04..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img28.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img29.png b/manual/docs/html/slsDetectors-FAQ/img29.png
deleted file mode 100644
index 6ec9442e2..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img29.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img3.png b/manual/docs/html/slsDetectors-FAQ/img3.png
deleted file mode 100644
index 249cebaf1..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img3.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img30.png b/manual/docs/html/slsDetectors-FAQ/img30.png
deleted file mode 100644
index 7d75095cc..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img30.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img31.png b/manual/docs/html/slsDetectors-FAQ/img31.png
deleted file mode 100644
index 75bd6668e..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img31.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img32.png b/manual/docs/html/slsDetectors-FAQ/img32.png
deleted file mode 100644
index d0b65f192..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img32.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img33.png b/manual/docs/html/slsDetectors-FAQ/img33.png
deleted file mode 100644
index 6c99c1b5a..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img33.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img34.png b/manual/docs/html/slsDetectors-FAQ/img34.png
deleted file mode 100644
index 56b9408fa..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img34.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img35.png b/manual/docs/html/slsDetectors-FAQ/img35.png
deleted file mode 100644
index fb6eb7f09..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img35.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img36.png b/manual/docs/html/slsDetectors-FAQ/img36.png
deleted file mode 100644
index 97230c6d2..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img36.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img4.png b/manual/docs/html/slsDetectors-FAQ/img4.png
deleted file mode 100644
index 3b34cb9ec..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img4.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img5.png b/manual/docs/html/slsDetectors-FAQ/img5.png
deleted file mode 100644
index 77916ac9c..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img5.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img6.png b/manual/docs/html/slsDetectors-FAQ/img6.png
deleted file mode 100644
index 728ba17a8..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img6.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img7.png b/manual/docs/html/slsDetectors-FAQ/img7.png
deleted file mode 100644
index 96347d069..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img7.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img8.png b/manual/docs/html/slsDetectors-FAQ/img8.png
deleted file mode 100644
index d3f238a91..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img8.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/img9.png b/manual/docs/html/slsDetectors-FAQ/img9.png
deleted file mode 100644
index ca122242a..000000000
Binary files a/manual/docs/html/slsDetectors-FAQ/img9.png and /dev/null differ
diff --git a/manual/docs/html/slsDetectors-FAQ/index.html b/manual/docs/html/slsDetectors-FAQ/index.html
deleted file mode 100644
index 7146179fa..000000000
--- a/manual/docs/html/slsDetectors-FAQ/index.html
+++ /dev/null
@@ -1,250 +0,0 @@
-
-
-
-
-
-SLS Detectors
-Frequently Asked Questions
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: Contents
- Contents
-
-
-
-
-
-
-
SLS Detectors
-
-Frequently Asked Questions
-Anna Bergamaschi
-
-Date: November 28, 2017
-
-
-
-
-
-
-
-
-
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/internals.pl b/manual/docs/html/slsDetectors-FAQ/internals.pl
deleted file mode 100644
index be3c3b309..000000000
--- a/manual/docs/html/slsDetectors-FAQ/internals.pl
+++ /dev/null
@@ -1,134 +0,0 @@
-# LaTeX2HTML 2008 (1.71)
-# Associate internals original text with physical files.
-
-
-$key = q/sec:usersFunc/;
-$ref_files{$key} = "$dir".q|node12.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:merging/;
-$ref_files{$key} = "$dir".q|node32.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:timing/;
-$ref_files{$key} = "$dir".q|node10.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:gating/;
-$ref_files{$key} = "$dir".q|node10.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:improvetrimming/;
-$ref_files{$key} = "$dir".q|node21.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:multidet/;
-$ref_files{$key} = "$dir".q|node4.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/eq:acqflow/;
-$ref_files{$key} = "$dir".q|node9.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:autotiming/;
-$ref_files{$key} = "$dir".q|node10.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:3/;
-$ref_files{$key} = "$dir".q|node32.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:samplefluo/;
-$ref_files{$key} = "$dir".q|node19.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:settings/;
-$ref_files{$key} = "$dir".q|node18.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:2/;
-$ref_files{$key} = "$dir".q|node32.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:effidet/;
-$ref_files{$key} = "$dir".q|node15.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:11/;
-$ref_files{$key} = "$dir".q|node32.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:thrscanfluo/;
-$ref_files{$key} = "$dir".q|node19.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:dataFormat/;
-$ref_files{$key} = "$dir".q|node13.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:mythensett/;
-$ref_files{$key} = "$dir".q|node15.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:sync/;
-$ref_files{$key} = "$dir".q|node11.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:badff/;
-$ref_files{$key} = "$dir".q|node20.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:datareceiver/;
-$ref_files{$key} = "$dir".q|node5.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:effiback/;
-$ref_files{$key} = "$dir".q|node15.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:trig/;
-$ref_files{$key} = "$dir".q|node10.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:ffsetup/;
-$ref_files{$key} = "$dir".q|node20.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:thresholdscanuntrimmed/;
-$ref_files{$key} = "$dir".q|node21.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:trimdistribution/;
-$ref_files{$key} = "$dir".q|node21.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:angcal/;
-$ref_files{$key} = "$dir".q|node31.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:trimdir/;
-$ref_files{$key} = "$dir".q|node6.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:trimplot/;
-$ref_files{$key} = "$dir".q|node21.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:thresholdscantrimmed/;
-$ref_files{$key} = "$dir".q|node21.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:noisetrim/;
-$ref_files{$key} = "$dir".q|node21.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:encal/;
-$ref_files{$key} = "$dir".q|node22.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:thrscan/;
-$ref_files{$key} = "$dir".q|node19.html|;
-$noresave{$key} = "$nosave";
-
-1;
-
diff --git a/manual/docs/html/slsDetectors-FAQ/labels.pl b/manual/docs/html/slsDetectors-FAQ/labels.pl
deleted file mode 100644
index 1d18616cf..000000000
--- a/manual/docs/html/slsDetectors-FAQ/labels.pl
+++ /dev/null
@@ -1,269 +0,0 @@
-# LaTeX2HTML 2008 (1.71)
-# Associate labels original text with physical files.
-
-
-$key = q/sec:usersFunc/;
-$external_labels{$key} = "$URL/" . q|node12.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:merging/;
-$external_labels{$key} = "$URL/" . q|node32.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:timing/;
-$external_labels{$key} = "$URL/" . q|node10.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:gating/;
-$external_labels{$key} = "$URL/" . q|node10.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:improvetrimming/;
-$external_labels{$key} = "$URL/" . q|node21.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:multidet/;
-$external_labels{$key} = "$URL/" . q|node4.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/eq:acqflow/;
-$external_labels{$key} = "$URL/" . q|node9.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:autotiming/;
-$external_labels{$key} = "$URL/" . q|node10.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:3/;
-$external_labels{$key} = "$URL/" . q|node32.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:samplefluo/;
-$external_labels{$key} = "$URL/" . q|node19.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:settings/;
-$external_labels{$key} = "$URL/" . q|node18.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:2/;
-$external_labels{$key} = "$URL/" . q|node32.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:effidet/;
-$external_labels{$key} = "$URL/" . q|node15.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:11/;
-$external_labels{$key} = "$URL/" . q|node32.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:thrscanfluo/;
-$external_labels{$key} = "$URL/" . q|node19.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:dataFormat/;
-$external_labels{$key} = "$URL/" . q|node13.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:mythensett/;
-$external_labels{$key} = "$URL/" . q|node15.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:sync/;
-$external_labels{$key} = "$URL/" . q|node11.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:badff/;
-$external_labels{$key} = "$URL/" . q|node20.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:datareceiver/;
-$external_labels{$key} = "$URL/" . q|node5.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:effiback/;
-$external_labels{$key} = "$URL/" . q|node15.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:trig/;
-$external_labels{$key} = "$URL/" . q|node10.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:ffsetup/;
-$external_labels{$key} = "$URL/" . q|node20.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:thresholdscanuntrimmed/;
-$external_labels{$key} = "$URL/" . q|node21.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:trimdistribution/;
-$external_labels{$key} = "$URL/" . q|node21.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:angcal/;
-$external_labels{$key} = "$URL/" . q|node31.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:trimdir/;
-$external_labels{$key} = "$URL/" . q|node6.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:trimplot/;
-$external_labels{$key} = "$URL/" . q|node21.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:thresholdscantrimmed/;
-$external_labels{$key} = "$URL/" . q|node21.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:noisetrim/;
-$external_labels{$key} = "$URL/" . q|node21.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:encal/;
-$external_labels{$key} = "$URL/" . q|node22.html|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:thrscan/;
-$external_labels{$key} = "$URL/" . q|node19.html|;
-$noresave{$key} = "$nosave";
-
-1;
-
-
-# LaTeX2HTML 2008 (1.71)
-# labels from external_latex_labels array.
-
-
-$key = q/sec:usersFunc/;
-$external_latex_labels{$key} = q|1.10|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:merging/;
-$external_latex_labels{$key} = q|5.2|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:timing/;
-$external_latex_labels{$key} = q|1.8|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:gating/;
-$external_latex_labels{$key} = q|1.4|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:improvetrimming/;
-$external_latex_labels{$key} = q|3.4.1|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:multidet/;
-$external_latex_labels{$key} = q|1.1|;
-$noresave{$key} = "$nosave";
-
-$key = q/eq:acqflow/;
-$external_latex_labels{$key} = q|1.7|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:autotiming/;
-$external_latex_labels{$key} = q|1.3|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:3/;
-$external_latex_labels{$key} = q|5.2.6|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:samplefluo/;
-$external_latex_labels{$key} = q|3.4|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:settings/;
-$external_latex_labels{$key} = q|3.1|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:2/;
-$external_latex_labels{$key} = q|5.2.3|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:effidet/;
-$external_latex_labels{$key} = q|2.1|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:11/;
-$external_latex_labels{$key} = q|5.2.2|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:thrscanfluo/;
-$external_latex_labels{$key} = q|3.3|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:dataFormat/;
-$external_latex_labels{$key} = q|1.11|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:mythensett/;
-$external_latex_labels{$key} = q|2.3|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:sync/;
-$external_latex_labels{$key} = q|1.9|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:badff/;
-$external_latex_labels{$key} = q|3.5|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:datareceiver/;
-$external_latex_labels{$key} = q|1.2|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:effiback/;
-$external_latex_labels{$key} = q|2.2|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:trig/;
-$external_latex_labels{$key} = q|1.6|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:ffsetup/;
-$external_latex_labels{$key} = q|3.6|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:thresholdscanuntrimmed/;
-$external_latex_labels{$key} = q|3.7|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:trimdistribution/;
-$external_latex_labels{$key} = q|3.8|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:angcal/;
-$external_latex_labels{$key} = q|5.1|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:trimdir/;
-$external_latex_labels{$key} = q|1.4|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:trimplot/;
-$external_latex_labels{$key} = q|3.9|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:thresholdscantrimmed/;
-$external_latex_labels{$key} = q|3.10|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:noisetrim/;
-$external_latex_labels{$key} = q|3.4.1|;
-$noresave{$key} = "$nosave";
-
-$key = q/sec:encal/;
-$external_latex_labels{$key} = q|3.5|;
-$noresave{$key} = "$nosave";
-
-$key = q/fig:thrscan/;
-$external_latex_labels{$key} = q|3.2|;
-$noresave{$key} = "$nosave";
-
-1;
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node1.html b/manual/docs/html/slsDetectors-FAQ/node1.html
deleted file mode 100644
index 35fb1c515..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node1.html
+++ /dev/null
@@ -1,204 +0,0 @@
-
-
-
-
-
-Contents
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: SLS Detectors Software
- Up: SLS Detectors Frequently Asked
- Previous: SLS Detectors Frequently Asked
-
-
-
-
-
-
-
-
-
-
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node10.html b/manual/docs/html/slsDetectors-FAQ/node10.html
deleted file mode 100644
index ced61e7cf..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node10.html
+++ /dev/null
@@ -1,201 +0,0 @@
-
-
-
-
-
-How can I synchronize my detector with the experiment?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How can several controllers
- Up: SLS Detectors Software
- Previous: Which is the sequence
- Contents
-
-
-
-
-
-
-How can I synchronize my detector with the experiment?
-
-
-
-The timing of the detector is always defined by an active detection time followed by a dead time during which the detector is read out. This read out time as a fixed duration depending on the detector type and its configuration (e.g. dynamic range) which limits the maximum frame rate achievable.
-
-In the following is a list of the main parameters involved in the acquisition timing:
-
-Exposure time
-is the time during which the detector is detecting X-rays for each image (ignored is the timing mode is gating ).
-
-Period
-is the period of the images acquired. If it is shorter than the exposure time plus readout time, it will be ignored.
-
-Delay after trigger
-can be set as a delay between the trigger signal and the start of the detection time.
-
-Number of gates
-is used only in gating mode and is the number of times that the gate is toggled before the detector is read out. Useful for stroboscopic measurements with gate period shorter than the minim acquisition period of the detector, otherwise can be left to 1.
-
-Number of frames
-is the number of images to be acquired per cycle. Frames and cycles have the same meaning except in trigger mode, when frames means the number of images per trigger. The total number of images is frames time cycles.
-
-Number of cycles
-is the number of times that the frames are acquired. Frames and cycles have the same meaning except in trigger mode, when cycles means the number of triggers that will be accepted. The total number of images is frames time cycles.
-
-Number of probes
-is used in stoboscopic measurements when the period is longer than the minimum acquisition period, but shorter than the frame rate.
-
-In this case the data can be summed in firmware.
-
-Currently it is implemented for Mythen only. If probes is set to 0, works normallyreturning an image for each readout, otherwise set number of cycles to 1. The maximum number of probes that can be set is 3. The detector will return a number of image equal to the number of probes, where all frames are going to be accumulated. The total number of readouts is number of frames time probes and for probes=1 the detector will return one image where all frames have been summed, for probes=2 two images where every second frame has been summed (each image accumulates the number of frames), for probes=3 three images where every third image has been summed (each image accumulates the number of frames).
-
-The returned images will always have 32 bit dynamic range, while the dynamic range if the detector defines the bit depth of the counters in rder to limit the readout time, if necessary.
-
-The probes counter waorks also in trigger and gating modes.
-
-
-
-
-
-
-
-Figure 1.3:
-Auto timing: the detection time is defined by the exposure time and the period by period (if longer than exposure time plus readout time). The total number of images is frames (in the example 3) times cycles (in the example 2), and in this case there is no difference between the acquisition of the two.
-
-
-
-
-
-
-
-
-
-
-
-
-Figure 1.4:
-Gating mode: the detector acquires for a number of gates define by the user (in this case 4) before being read out, independently on the timing of the gates. The detector remains insensitive during the readout time and then starts being active again. External gates given during the readout time are ignored. The total number of images is frames (in the example 3) times cycles (in the example 2), and in this case there is no difference between the acquisition of the two. The polarity of the external gate signal can be defined by the user through the external signal flag (in the example active high).
-
-
-
-
-
-
-
-
-
-
-
-
-Figure 1.5:
-Trigger mode: the external trigger signal defines the start of the beginning of the acquisition, which starts after the delay set by the user. For each trigger, the number of frames is acquired (in the example 3) and all trigger signals ignored. The number of trigger accepted is given by the number of cycles (in the example 2). The polarity of the external trigger signal can be defined by the user through the external signal flag (in the example rising edge).
-
-
-
-
-
-
-
-
-
-
-
-
-Figure 1.6:
-Read Out Trigger mode: the external trigger signal defines the beginning of the readout. The exposure time works as a time out for the waiting time for the trigger signal. The number of trigger accepted is given by the number of cycles (in the example 3) and it does not make sense to program more than one frame. The polarity of the external trigger signal can be defined by the user through the external signal flag (in the example rising edge).
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How can several controllers
- Up: SLS Detectors Software
- Previous: Which is the sequence
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node11.html b/manual/docs/html/slsDetectors-FAQ/node11.html
deleted file mode 100644
index 2341f0e18..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node11.html
+++ /dev/null
@@ -1,109 +0,0 @@
-
-
-
-
-
-How can several controllers be synchronized?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How can the detector
- Up: SLS Detectors Software
- Previous: How can I synchronize
- Contents
-
-
-
-
-
-
-How can several controllers be synchronized?
-
-If you are not performing time resolved measurements, you will probably not need any synchronization of the controllers: they will be started sequentially by the software and their acquisition will have a jitter of a few ms.
-
-In the case you need a precise synchronization, on the other hand, hardware connection is required between the controllers through the external IO signals. The external signals used for this synchronization should be configured as sync with the extsig command.
-
-In this case a master controller should be defined for the acquisition which will the send the synchronization signal to the other controllers, while the other controllers will use them as inputs.
-
-The type of synchronization can begating or trigger depending if the synchronization signal will gate the slave detectors or trigegr the beginning of the acquisition. There are no particular reasons to chose one or the other method, except if the user finds out that one is more stable than the other.
-
-Normally the configuration of the synchronization is configured inside the configuration file and should not be changed dynamically by the user.
-
-
-After the configuration, the synchronization of the controllers will be completely transparent for the user, who will simply have to setup the timing parameters of the detector as a whole.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How can the detector
- Up: SLS Detectors Software
- Previous: How can I synchronize
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node12.html b/manual/docs/html/slsDetectors-FAQ/node12.html
deleted file mode 100644
index 2cb00c6f8..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node12.html
+++ /dev/null
@@ -1,109 +0,0 @@
-
-
-
-
-
-How can the detector movement and position and I0 readout be customized for my beamline?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: In which data format
- Up: SLS Detectors Software
- Previous: How can several controllers
- Contents
-
-
-
-
-
-
-How can the detector movement and position and I0 readout be customized for my beamline?
-
-
-
-The easiest way to allow the software to perform all the necessary normalization and angular conversion steps, is enable it to move your detector and read the encoder position and the value of the ionization chamber.
-
-These functions are defines as callbacks and can be redifined by registering your own functions. This is normally a good method if you use the API or are willing to write your main client program.
-
-Otherwise the simpleast way is to edit the file
-slsDetectorSoftware/usersFunctions/usersFunctions.cpp
-
-where the default functions performing these actions are implemented and modify them to interface with your beamline hardware. The functions are written in C and are very simple to implement for anyone with some programming knowledge.
-
-A simple high-level solution in case you need to maintain the software for several beamlines and don't want to recompile for all of them is to call external scripts.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: In which data format
- Up: SLS Detectors Software
- Previous: How can several controllers
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node13.html b/manual/docs/html/slsDetectors-FAQ/node13.html
deleted file mode 100644
index 2e99c04f7..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node13.html
+++ /dev/null
@@ -1,193 +0,0 @@
-
-
-
-
-
-In which data format are written the data?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: General questions about detectors
- Up: SLS Detectors Software
- Previous: How can the detector
- Contents
-
-
-
-
-Subsections
-
-
-
-
-
-
-
-In which data format are written the data?
-
-
-
-For MYTHEN the data are writen in ASCII fomat, one file per frame, in columns, either channel number - counts for the .raw files or angle (or channel number)-counts-error for the .dat files.
-
-
-For the other detectors the files are written in binary format, and must be decoded depending on the detector.
-
-
-
-
-Each file contains 100 frames.
-
-Normal mode
-Each frame is split into 2 packets of 1286 bytes each, where actual data is 1280 bytes each. Both the packets (incl header and footer) are written one after the other into the file.
-
-
-Representation of each packet:
-
-
-The first 4 bytes represents a number from which, the frame number and packet number can be derived.
-If the number was 108601, increment it by 1 to get 108602.
-
-Then this
-
- is the frame number
-and
-
- is the packet number.
-
-0 is the packet on the left and 1 is the packet on the right.
-
-On a side note, when you use the data call back, we also give you the derived frame number as an argument.
-
-
-
-Data of 1280 bytes. 16 bits per pixel.
-
-
-
-2 bytes of insignificant footer.
-
-
-
-
-
-Short Frame Mode
-One Frame has only one packet of 518 bytes, where actual data is 512 bytes.
-
-
-first 4 bytes is the frame number. There is no packet number or increment required herecompared to the normal mode.
-
-Data of 512 bytes.
-
-2 bytes of insignificant footer.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: General questions about detectors
- Up: SLS Detectors Software
- Previous: How can the detector
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node14.html b/manual/docs/html/slsDetectors-FAQ/node14.html
deleted file mode 100644
index 8692e1005..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node14.html
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
-
-General questions about detectors
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: In which X-ray energy
- Up: SLS Detectors Frequently Asked
- Previous: In which data format
- Contents
-
-
-
-
-
-
-
-
-
-Subsections
-
-
-
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node15.html b/manual/docs/html/slsDetectors-FAQ/node15.html
deleted file mode 100644
index 24e7d3e8d..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node15.html
+++ /dev/null
@@ -1,209 +0,0 @@
-
-
-
-
-
-In which X-ray energy range can I use the detector?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: What limits the maximum
- Up: General questions about detectors
- Previous: General questions about detectors
- Contents
-
-
-
-
-Subsections
-
-
-
-
-
-
-What limits the energy range in which the detector can be used is defined both by the sensors characteristics and the readout electronics.
-
-
-
-
-Most of the SLS detectors make use of silicon sensors.
-
-
-Since silicon is a relatively light for hard X-rays the only limitation at high energies is the acceptable absorption efficiency that can be achieved in the sensors thickness.
-
-Figure 2.1 shows the absorption efficiency as a function of the X-ray energy and detector thickness. Normally it is possible to use sensors up to 1 mm thick, while to achieve larger absorption thicknesses it is necessary tu assemble and control telescopic systems (possible up to a few mms).
-
-To achieve larger absorption thicknesses, the sensors can be oriented in edge-on configuration (in particular strip sensors). However in this case one should take into consideration the dead entrance window due to the cutting distance from the strips, which is normally several hundreds micron, or even up to mms and reduces the absorption efficiency at lower energies.
-
-
-
-
-
-Figure 2.1:
-Efficiency of a silicon sensor as a function of the sensors thickness and X-ray energy.
-
-
-
-
-
-In standard face-on orientation, the backplane of the sensor acts as the entrance window. It presents a think n+ doped layer, which is unsensitive to radiation and causes a loss of efficiency at low energies.
-Figure 2.2 shows the absorption efficiency of the sensors for different backplane thicknesses at low energies.
-
-The exact thickness of the backplane for standard SLS sensors is not exactly known but should be about 1-2
-m.
-
-
-
-
-
-Figure 2.2:
-Efficiency of a silicon sensor as a function of the X-ray energy for different thicknesses of the backplane.
-
-
-
-
-
-However for lower energies, the main limitation is normally given by the noise of the frontend electronics (if single photon resolution is required).
-
-For higher energies it is also possible to use different sesnor materials as CdTe or Ge, although up to now they cannot provide the same signal quality as silicon.
-
-
-
-
-
-
-The limitations on the energy range arising from the readout electronics come from the noise and from saturation.
-The electronic noise limits the minimum detectable energy for single photons, while saturation limits the maximum detectable signal either for single photons or in total.
-
-
-In single photon counting detectors , the minimum threshold cannot be set lower than 3-5 times the electronic noise.
-If the threshold is set at approximately half of the X-ray energy (see specific documentation about single photon counting detectors), the minimu detectable energy will be about 6-10 times the noise.
-
-In order to reduce the noise of the frontend electronics different settings can be chosen, but this puts a limit on the maximum incoming flux that can be detected without incurring in pileup (see specific documentation about single photon counting detectors). Figure 2.3 shows an example of the settings used for the MYTHEN detector for different energy ranges and fluxes.
-
-For state of the art single photon counting detectors, the minimum thrshold can be about 2-3 keV (details depend on the detector and can be further reduced using special settings).
-
-
-Concerning saturation, this imposes a maximum value for the comparator threshold. Normally photons of higher energies can still be detected, but without resolution concerning the threshold energy and eventually losing spatial resolution.
-By changing the settings it is possible to increase the maximum threshold value (normally also noise increases in this case).
-
-
-
-For charge integrating detectors the electronics noise puts a limit on the minimum detectable signal. Therefore if single photon resolution is required, the minimum detectable energy is defined as for single photon counting detectors at about 6-10 times the electronic noise. In case no single photon resolution is required, the electronic noise will put a limit on the sensitivity of the detector i.e. the total accumulated signal needs to be larger than 6-10 times the noise in order to be detected (also about 2-3 keV depending on the detector). It is important to point out that the acquisition time of charge integrating detectors is limited by the leakage current of the sesnors and the noise quadratically sums out. Therefore the signal for low energy photons should be strong enough to be acquired during single frames.
-
-
-Concerning saturation, this sets a limit on the total number of photons acquired during the acquistion slot and is normally much larger than the energy released by single X-rays. Dynamic gain switching can strongly increase the dynamic range of the detector up to 10E+4 12 keV photons.
-
-
-
-
-
-
-
-
-
-Figure 2.3:
-Settings to be chosen for the MYTHEN detector as a function of the X-ray energy and radiation intensity.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: What limits the maximum
- Up: General questions about detectors
- Previous: General questions about detectors
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node16.html b/manual/docs/html/slsDetectors-FAQ/node16.html
deleted file mode 100644
index 53c94be0e..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node16.html
+++ /dev/null
@@ -1,111 +0,0 @@
-
-
-
-
-
-What limits the maximum frame rate?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: Single photon counting detectors
- Up: General questions about detectors
- Previous: In which X-ray energy
- Contents
-
-
-
-
-
-
-
-In order to acquired the data, they should be:
-
-
-Transferred from readout electronics to readout board memory. This readou time is very dependent on the detector and on the dynamic range chose (for single photon counting detectors if configurable) and can range from hundreds or tens to few us.
-
-In case the board has some memory that can be accessed by the hardware, this is the only limitation on the maximum frame rate as long as the memory is not filled (burst mode). Frame rates as high as a few tens of kHz can be achieved for photon countign detectors (EIGER) or up to 1 MHz for charge integrating (GOTTHARD).
-
-
-
-Transferred from readout board to client PC or file server. In this case the main bottleneck is normally given by the data transfer rate on the network and on the performances of the receiver PC. This limits the frame rate in continous mode. However also the data writing capabilities and amount of data which are being acquired should be taken into consideration when setting up very fast acquisitions.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: Single photon counting detectors
- Up: General questions about detectors
- Previous: In which X-ray energy
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node17.html b/manual/docs/html/slsDetectors-FAQ/node17.html
deleted file mode 100644
index ea682d7dc..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node17.html
+++ /dev/null
@@ -1,115 +0,0 @@
-
-
-
-
-
-Single photon counting detectors
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: Which detector settings should
- Up: SLS Detectors Frequently Asked
- Previous: What limits the maximum
- Contents
-
-
-
-
-
-
-
-
-
-Subsections
-
-
-
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node18.html b/manual/docs/html/slsDetectors-FAQ/node18.html
deleted file mode 100644
index fa25ade2d..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node18.html
+++ /dev/null
@@ -1,152 +0,0 @@
-
-
-
-
-
-Which detector settings should I choose?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How do I chose
- Up: Single photon counting detectors
- Previous: Single photon counting detectors
- Contents
-
-
-
-
-Subsections
-
-
-
-
-
-
-
-
-The choice of the operation settings is very important in order to obtain good quality data.
-
-Normally slower settings will reduce the electronics noise and therefore it is possible to work at lower energies, but will saturate for high photon fluxes.
-
-On the other hand, faster settings will allow to work with higher photon intensities without pileup, but not to access lower energies because of an higher electronics noise.
-
-Therefore it is extremely important to chose adequate settings for the detector depending on the X-ray energy and expected maximum count rate.
-In the following is a description of the energy and intensity range coverd by the different settings for each detector.
-
-
-
-
-
-
-Normally the user can follow these rules:
-
-
-If the X-ray energy is lower than 8 keV the High gain setting should be used. Since it is a slow mode of operation it is necessary to take care that the maximum count rate is lower than 100 kcounts/s for all channels (use filters to reduce the beam intensisty).
-
-For energies higher than 8 keV, the Standard setting is normally fine if the count rate can be kept lower than 300 kcounts/s for all channels (use filters to reduce the beam intensisty).
-
-
-
-In case a larger count rate is required in order to keep the acquisition time shorter, the Fast setting must be selected. However the maximum count rate should never exceed 1 Mcounts/s for all channels.
-
-
-
-
-
-
-
-Figure 3.1:
-Plot indicating the reccomended choice of detector settings as a function of the X-ray energy and maximum count rate per channel..
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How do I chose
- Up: Single photon counting detectors
- Previous: Single photon counting detectors
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node19.html b/manual/docs/html/slsDetectors-FAQ/node19.html
deleted file mode 100644
index e4d5fa1a0..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node19.html
+++ /dev/null
@@ -1,311 +0,0 @@
-
-
-
-
-
-How do I chose the comparator threshold?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How does the flat
- Up: Single photon counting detectors
- Previous: Which detector settings should
- Contents
-
-
-
-
-
-
-
-
-
-
-Figure 3.2:
-Number of counts as a function of the threshold detected in an ideal case.
-
-
-
-
-
-
-
-
-
-
-
-
-Figure 3.3:
-Number of counts as a function of the threshold detected in presence of fluorescent radiation
-
-
-
-
-
-
-
-
-
-Once selected the settings, the threshold should be selected.
-Figure 3.2 shows the number of counts as a function of the threshold value in the ideal case of monoenergetix X-rays of energy
-=10 keV.
-For thresholds larger than the X-ray energy the detector should always count 0 and for lower thresholds it should always count all the photons. However the curve is smoothed around
- because of the electronic noise (ENC) and is not perfectly flat for lower energies because the photons absorbed in the region between two strips distribute their energy between them and it is not flully collected by a single channel (charge sharing).
-
-In order to count once al X-rays the threshold should be set at half of the X-ray energy
-: if the threshold would be higher some photons would not be counted, leading to a loss of efficiency, while if it would be lower some photons would be counted twice leading to a loss of spatial resolution.
-
-
-Since the detector threshold can't be precisely set at the same value for all channels but there will always be some spread of the order of 200 eV (threshold dispersion) there will always be some fluctuations on the number of counts between channels, which however should be corrected by the flat field correction.
-
-
-The choice of the threshold should also depend from considerations regarding the emission of fluorescent radiation from the sample.
-
-Figure 3.3 shows how the curve of the counts would look like for monochromatic X-rays of energy
- in presence of radiation of energy
- emitted by the sample. The curve would show a second step at
-.
-
-
-Since the fluorecence emission is not present in the flat field data, the difference of counts between the channels due to the fluorescent radiation cannot be corrected and the threshold
- should be set at an energy larger than
-. This also helps to cut down the background.
-
-The difference of counts between the channels will be particularly large if the threshold is set in some ``steep'' part of the curve i.e. close to
- or to
- (but in this case it would be corrected by the flat field, at cost of loss of efficiency).
-Because of the presence of the electronic noise,
- should be at least 3 keV larger than
-.
-
-
-Here is a short list of rules to select the appropriate working threshold in order of importance (and eventually modify the X-ray energy):
-
-
-List the fluorescent emission lines
- that you expect from your sample.
-
-If there is no fluorescent emission (
-)
-
-
-If there is fluorescent emission
-
-
-
- keV
-
-
- keV
-
-
-If the range where both requirements are satisfied is large, try to increase the distance of
- from
- up to 5 keV and then set
- as close as possible to the ideal value
-
-
-If it is not possible to satisfy the previous minimal requirements:
-
-
-If you need high quality data and you can sacrifice detector efficiency (a lot!)
- keV
-
-If you need fast measurments and you can sacrifice detector uniformity (difficult to say how much) and increase the background
- keV. Remember that
- is klimited by the electronic noise
- keV (3 keV for High gain settings).
-
-Consider to change
- to values lower than
- or at least 6-8 keV larger than
-
-
-
-
-
-
-
-
-
-
-Figure 3.4:
-Example of data from a sample emitting fluorescent light and detector threshold set at a value close to the emission line. The background data cannot be properly flat field corrected.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How does the flat
- Up: Single photon counting detectors
- Previous: Which detector settings should
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node2.html b/manual/docs/html/slsDetectors-FAQ/node2.html
deleted file mode 100644
index 93998fb12..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node2.html
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
-SLS Detectors Software
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: Which programs can I
- Up: SLS Detectors Frequently Asked
- Previous: Contents
- Contents
-
-
-
-
-
-
-
-
-
-Subsections
-
-
-
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node20.html b/manual/docs/html/slsDetectors-FAQ/node20.html
deleted file mode 100644
index 4aa9e7d1d..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node20.html
+++ /dev/null
@@ -1,177 +0,0 @@
-
-
-
-
-
-How does the flat field correction work?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: What happens when I
- Up: Single photon counting detectors
- Previous: How do I chose
- Contents
-
-
-
-
-Subsections
-
-
-
-
-
-
-
-
-
-
-
-
-The main reasons of a non flat flat-field can be:
-
-
-The scattering from the glass rod is not uniform over the angular range. In this case you should take the flat field dynamically i.e. scanning the detector in front of the cylinder with the small window, as we do at the SLS. In this case when you shift the detector, the shape of the illumination remains in the same angular position (and shifts in channel number). Of course it depends a lot on the energy and on the geometry of the flat field acquisition.
-
-
-
-Figure 3.5:
-Example of a very bad flat field data set with highlights of some of the reasons which can cause the non-flat behavior for the MYTHEN detector. Similar effects can be visible also in 2D.
-
-
-
-
-
-
-
-
-
-
-The entrance window for the X-rays is deformed (we also have this problem at the SLS). In this case when you move the detector the "mountain" moves with it in angle (And remains still in channel number). However this should correct without problems with the flat field correction, even in case of fluorescent emission. Should appear at all energies.
-
-Differences of efficiency between the modules i.e. mainly bad energy calibration. You normally see really steps at the transition between modules. Sometimes you have some groups of strips withing a module that are not properly trimmed and look as smallish peaks or valleys in the flat field. When you move the detector, these steps or peaks move in angle and remain still in channel number.
-These differences can slightly change as a function of the energy (probably more evident at lower energies) but should normally always be there for the same settings.
-These differences get much worse in presence of fluorescent emission, but normally correct properly with flat field correction.
-
-
-
-
-
-
-
-
-In case it is not possible to uniformely illuminate the detector due to its large dimensions, one of the solutions is to scan it in front of an illuminated are with a uniform speed such that the integrated number of counts during the exposure time is the same for all channels.
-
-
-To do that, at the SLS we have optimized the dynamic acquisition of the flat fiel with the MYTHEN detector using a setup similar to the one sketched in figure 3.6 .
-It is important that the scanning range of the detector is chose such that the detector is not illuminated both at the beginning and at the end of the acquisition. Moreover the movement of the detector should be as uniform as possible. To avoid this kind of systematic errors we normally sum two flat field images taken in the two opposite directions of translation.
-
-
-Also take care that your sample does not emit fluorescent light at the chosen energy (e.g. a glass rod works at all energies, but heavier materials can be chosen to increase the efficiency at higher energies taking care that the fluorescence emission is negligible).
-
-
-
-
-
-Figure 3.6:
-Sketch of the experimental setup for a dynamic acquisition of the flat field.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: What happens when I
- Up: Single photon counting detectors
- Previous: How do I chose
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node21.html b/manual/docs/html/slsDetectors-FAQ/node21.html
deleted file mode 100644
index 8e9e7b61d..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node21.html
+++ /dev/null
@@ -1,264 +0,0 @@
-
-
-
-
-
-What happens when I trim the detector?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: In what consists the
- Up: Single photon counting detectors
- Previous: How does the flat
- Contents
-
-
-
-
-Subsections
-
-
-
-
-
-
-
-
-General remarks about trimming.
-
-
-
-
-
-
-Trimming with noise
-
-
-The first step in the trimming procedure is to trim with noise (this is often sufficient). This has to be done for all the settings which are foreseen to be used (highgain, standard and fast).
-
-The procedure for the noise trimming is as follows:
-
-
-In the Initialization tab click on the settings for which you want to trim (e.g. standard)
-
-In the Initialization tab click on the advanced radio button to make the trimming accessible.
-
-In the Acquisition tab set the acquisition time to 100 ms, the repetion to 1 and the delay between frames to 0.
-
-For noise trimming usually the default parameters
-
-,
-
-,
-
- work.
-
-However, to verify the threshold setting it is best to make a threshold scan. To do this go to the Data tab, in the Data display section select the 2D color and type advanced option. In the Acquisition tab select your data directory. Set the number of positions to 0. Select Scan, Type threshold. Typical values for the range are 500 to 900 with a step size of 10. Then click on the start button to perform the threshold scan. After the threhold scan has finished an image similar to the one in 3.7 should be shown. Depending on the system the number of modules may vary. If the plot is similar to the one in 3.10 the noise trim files did already exist and have been loaded when selecting the settings. In this case you don't need to trim with noise again.
-
-Set the parameter Vthreshold in the Trimming box (Initialization tab ) 10-30 DAC units below the onset of the noise for the module with the lowest threshold offset. Since the modules have differences in the offset and gain the onset of the noise varies.
-
-You can usually leave the remaining parameters unchanged (Counts/pixel=500; Resolution=4).
-
-Select the directory where the noise trim files should be written and the filename, to wich will be attached the extension given by the module serial number (.snxxx). If you want the trimfiles to be loaded authomatically when the global settings are selected, select the default directory specified in the config file (or in the ``trimbits/beamline'' directory for the older software versions).
-Click on Trim to start the noise trimming process. After the trimming has finished look at the plot and the distribution of the trim bits. The distribution should be around 32
-5 and should look gaussian. An example distribution is shown in figure 3.8 and an example plot in 3.9 . If the distribution is too much off center change the counts/pixel, if it is too narrow reduce the resolution (set it to 3), if it is too wide increase it (set it to 5). Make sure not too many channels have a trim value of 0 or 63.
-
-Execute the treshold scan again to verify the trimming was done properly. A plot similar tho the one in figure 3.10 should appear.
-
-
-
-
-
-
-
-Figure 3.7:
-The untrimmed threshold scan.
-
-
-
-
-
-
-
-
-
-
-
-
-Figure 3.8:
-The distribution of the trimbits.
-
-
-
-
-
-
-
-
-
-
-
-
-Figure 3.9:
-The trimbits for all the channels.
-
-
-
-
-
-
-
-
-
-
-
-
-Figure 3.10:
-The trimmed threshold scan.
-
-
-
-
-
-
-
-
-
-Improve the trimming using X-rays
-
-
-The improvement of the trimming acquired with noise is not essential: at 12 keV an untrimmed module has a threshold dispersion which is about 1.4 keV and is already reduced to 200 eV at 12 keV by the noise trimming. At lower energies the noise trimming will be more effective, while the threshold dispesion will be still larger at higher energies. The trimming improvement reduces the threshold dispersion to 140 eV at 12 keV and is expected to be almost constant at all energies. For this reason it is suggested to perform the trimming improvement only when a small threshold dispersion is really important (e.g. to avoid flat field corrections or in presence of fluorescent lines close to the threshold value) and it will probably be not worthy at lower energies (i.e. threshold lower than 6 keV and X-ray energy lower than 12 keV).
-The procedure for the trimming improvement is as follows:
-
-
-Select the settings of the detector and load the noise trimming file
-
-Set the threshold at half of the X-ray energy (better if the detector has already been calibrated in energy like explained in 3.5 )
-
-Illuminate the detector with a flat field. This is very important to obtain a good trimming.
-
-Select the acquisition time in the acquisition tab so that there are at least 1000 counts/strip per frame (the more counts, the better trimming). Set the repetions to 1 and the delay between frames to 0.
-
-Go to expert mode by clicking on advanced in the initialization tab , settings box
-
-In the trimming box select the directory where the noise trim files should be written and the filename, to wich will be attached the extension given by the module serial number (.snxxx).
-
-Select the improve method
-S tart the trimming
-
-
-If the trimming is correctly performed and the illumination is flat enough, the same trimming can be used every time you will measure at this same energy.
-The authomatic loading of energy-specific trim files is not yet implemented.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: In what consists the
- Up: Single photon counting detectors
- Previous: How does the flat
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node22.html b/manual/docs/html/slsDetectors-FAQ/node22.html
deleted file mode 100644
index ef4f21488..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node22.html
+++ /dev/null
@@ -1,185 +0,0 @@
-
-
-
-
-
-In what consists the energy calibration of the detector?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: Why should I change
- Up: Single photon counting detectors
- Previous: What happens when I
- Contents
-
-
-
-
-Subsections
-
-
-
-
-
-
-
-In what consists the energy calibration of the detector?
-
-
-
-General remarks about DAC to energy conversion
-
-
-
-
-
-
-Since the conversion between the threshold DAC units and energy depends on the gain and offset of the channels the energy calibration has to be done for all settings (high gain, standard and fast). For each setting follow this procedure:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: Why should I change
- Up: Single photon counting detectors
- Previous: What happens when I
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node3.html b/manual/docs/html/slsDetectors-FAQ/node3.html
deleted file mode 100644
index 11733f1e5..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node3.html
+++ /dev/null
@@ -1,116 +0,0 @@
-
-
-
-
-
-Which programs can I use to control my detector?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How can I control
- Up: SLS Detectors Software
- Previous: SLS Detectors Software
- Contents
-
-
-
-
-
-
-
-The complete software package is composed of several programs which can be installed (or locally compiled) depending on the needs:
-
-
-
-
-The slsDetector shared and static libraries which are necessary for all user interfaces.
-
-The class slsDetectorUsers can be used as API from your acquisition software (see separate documentation).
-
-The command line interfaces (sls_detector_put, sls_detector_get, sls_detector_acquire, sls_detector_help) , which are provided to communicate with the detectors using the command line and eventually to the data receiver
-
-The data receiver (slsReceiver) , which can be run on a different machine, receives the data from the detector and interfaces to the control software via TCP/IP for defining e.g. the file name, output path and return status and progress of the acquisition
-
-The graphical user interface (slsDetectorGUI) which provides a user friendly way of operating the detectors with online data preview
-
-The calibration wizards (energyCalibrationWizard, angularCalibrationWizard) to analyze the data and produce the energy or angular calibration files
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How can I control
- Up: SLS Detectors Software
- Previous: SLS Detectors Software
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node4.html b/manual/docs/html/slsDetectors-FAQ/node4.html
deleted file mode 100644
index d66403b73..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node4.html
+++ /dev/null
@@ -1,164 +0,0 @@
-
-
-
-
-
-How can I control many detectors in parallel or independently?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How can I configure
- Up: SLS Detectors Software
- Previous: Which programs can I
- Contents
-
-
-
-
-Subsections
-
-
-
-
-
-
-
-
-For most users the detector will be composed by a single module. Therefore all configurations of the detector will refere to that single entity.
-
-
-However, for some experiments it is necessary to concatenate the data from several detector controllers, and sometimes (e.g. MYTHEN) each controller can control many modules. This should be transparent to the user since most parameters will be identical for all controllers (e.g. exposure time, energy threshold etc.), except for the configurations specific to the controller (e.g. hardware configuration).
-
-In principle it is possible to combine controllers of different type (e.g. MYTHEN, GOTTHARD, EIGER) but the user should then evaluate if it really makes sense to control such different systems in parallel.
-
-
-In other cases, several SLS detectors will independently acquire data during the same experiment. In this case it will be necessary to be able to seperately control them.
-
-
-The detectors can be controlled in parallel from several PCs (clients). However it is important the the configurations match on all of the them such that no conflict arise. Eventually a detector can be locked to a specific control PC, still different users interfaces (command line, GUI) can be used in parallel.
-
-
-A sketch of a possible complex detector configuration is shown in figure 1.1
-
-
-For this reason and index is assigned to each detector. If a single detector is used, as in most cases, the index will be omitted and defaults to 0.
-
-To control the other detectors the index cannot be omitted!
-
-
-An index will also be assigned to each controller within a detector. However the user normally will not need to address single controllers, except for the most advanced settings which can be left to configuration files.
-
-
-Finally each module within a controller has an internal index. However in general it is not required that the user is aware of the system architecture and, if needed (rarely), the modules can simply be addressed sequentially starting from controller 0.
-
-
-
-
-
-Figure 1.1:
-Scketch of a possible complex system architecture composed of several detector, each consisting in many controllers eventually controlling several modules.
-
-
-
-
-
-
-
-
-
-For MYTHEN, if one needs to control 6 modules, the system can either be composed by and MCS6 with 6 modules (1 detector, 1 controller, 6 modules), or by 6 MCS1 (1 detector, 6 controller, 1 module each). After apppropriate configuration of the system, the interface to the user will be the same for both systems.
-
-
-For GOTTHARD, one module corresponds to one controller. A detector will have the smae number of controllers and modules.
-
-
-For EIGER, one module consists in two controllers. Fo a multi-module system, the number of controllers will increase accordingly, but should be left to a configuration file.
-
-
-You will need to configure more than one detector, only in case you want to operate several detectors independently.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How can I configure
- Up: SLS Detectors Software
- Previous: Which programs can I
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node5.html b/manual/docs/html/slsDetectors-FAQ/node5.html
deleted file mode 100644
index 920847db9..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node5.html
+++ /dev/null
@@ -1,139 +0,0 @@
-
-
-
-
-
-How can I configure the data receiver?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: What are settings and
- Up: SLS Detectors Software
- Previous: How can I control
- Contents
-
-
-
-
-
-
-
-For slower acquisitions, the detector will return the data to the control PC over TCP/IP (e.g. MYTHEN).
-
-
-However, for faster frame rates (e.g. GOTTHARD, EIGER) the controllers will return the data to a data receiver i.e. a process specifically designed to receive the data from the controller over a GBit network and save them to disk.
-
-The data receiver can run on any machine (e.g. a file server) accessible by both the control PC and the detector controller, as sketched in figure 1.2 . A data receiver process must be configured for each controller. Normally, to avoid performance loss it is better if different data receivers run on different machines.
-
-
-
-
-
-Figure 1.2:
-Scketch of the communication between the control PC, the detector and the data receiver.
-
-
-
-
-
-To setup the system, you should configure:
-
-Client-Detector TCP/IP connection
-i.e. for each controller hostname or IP address (hostname ) and communication port (port , use default).
-
-Client-Receiver TCP/IP connection
-i.e. hostname or IP address of the data receiver (rx_hostname ) and communication port (textitrx_tcpport, use default).
-
-Detector-Receiver UDP connection
-i.e. for each controller IP address of the receiver network interface (rx_udpip ) and communication port (rx_udpport ) used for receiveing the data. By detfault the IP address of the TCP/IP receiver interface will be used also for the UDP conenction. Editing the UDP network interfaces and ports is useful if several controller are sending data to a single receiver (not reccomended to avoid performance loss).
-
-A MAC (detectormac ) and IP address (detectorudpip ) should also be assigned to the controller network interface used for the UDP communication, but the default values can normally be used unless firewalls are defined between the detectors and the receiver.
-
-
-All these configurations are normally left to the configuration file and should not be changed dynamically by the user.
-
-
-After starting the data receiver process and correctly configuring the client and the detector, this architecture should be completely transparent for the user, except that the output file path must be properly configured from the client for the data receiver machine (easiest is that the disk is mounted for both machines in the same location).
-
-The client will take care of communicating with the data receiver and the detector. A feedback about the progress of the acquisition and a preview of the data being acquired can also be obtained by the client from the data receiver.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: What are settings and
- Up: SLS Detectors Software
- Previous: How can I control
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node6.html b/manual/docs/html/slsDetectors-FAQ/node6.html
deleted file mode 100644
index 06861fb14..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node6.html
+++ /dev/null
@@ -1,149 +0,0 @@
-
-
-
-
-
-What are settings and calibration files for?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How should a configuration
- Up: SLS Detectors Software
- Previous: How can I configure
- Contents
-
-
-
-
-Subsections
-
-
-
-
-
-
-
-What are settings and calibration files for?
-
-
-
-The analog characteristics of the detector have to be initialized in order to define the noise and the dynamic range which need to be used for the measurements. These parameters have a different meaning for analog or digital detectors, but in both cases some predefined voltage levels and current (we call them settings ) must be laoded to the detector. Moreover, there are some parameters that are custom to single detectors or modules (e.g. the trimbits). All these settings are stored in some settings file, which are organized in a settingsdir with a definite architecture, where the software will look for the files to load to the detector whaen changing its settings.
-
-
-In addition to that, in a single photon counting detector the threshold is set as a voltage level for the comparator, but for the user it is useful to have a direct conversion to the energy level. For this, after a proper calibration of the detector (see specific documentation) calibration file are generated in order to convert threshold in volts to keV. Also in this case the directory caldir where the calibration files are stored must be defined ad organized with a proper architecture, suche that the software can find the calibration coefficients for settings the threshold.
-
-Normally settingsdir and caldir can be the same, but have been left separate for flexibility.
-
-
-The settingsdir and caldir should be properly configured for your detector either in a configuration file (for use with text clients, GUI or API) or dynamically (works only for the text clients).
-
-
-In the following, the architecture of the settingsdir and caldir is described for the different detectors.
-
-
-
-
-For mythen, an example of settingsdir and caldir is given in the software package by the directory trimdir
.
-Since these directories are customized by producing trimbit files and calibration for each detector, make sure not to overwrite yours every time you upgrade the software.
-
-
-settingsdir should contain three subdirectories standard
, fast
and highgain
containing respectively the trimfiles standard.trim
, fast.trim
and highgain.trim
which contain the correct voltage settings for the detector although all the individual channel thresholds set to 0. The original files contained in the package should be used, infact in case of error the detector would not recognize the correct settings.
-
-The default trimbit files for each file will be stored in the directory according to the settings with the name noise.snxxx
where xxx
is the module serial number.
-
-
-caldir should contain three subdirectories standard
, fast
and highgain
containing respectively the trimfiles standard.cal
, fast.cal
and highgain.cal
which contain an average calibration of the modules for the diffrent settings. However this can different from the correct one for each individual module even of several kev and therefore it is very important to perform an energy calibration on a module basis.
-
-The default calibration files for each file will be stored in the directory according to the settings with the name calibration.snxxx
where xxx
is the module serial number.
-
-
-
-
-A settingsdir should be configured, as the directory settings
in this software package.
-
-It must contain the subdirectories dynamicgain
, gain1
, gain2
, gain3
, highgain
, lowgain
, mediumgain
, and veryhighgain
in order to properly configure the GOTTHARD detector using the various gain settings.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How should a configuration
- Up: SLS Detectors Software
- Previous: How can I configure
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node7.html b/manual/docs/html/slsDetectors-FAQ/node7.html
deleted file mode 100644
index 3562917f5..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node7.html
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
-
-How should a configuration file look like?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: What is the meaning
- Up: SLS Detectors Software
- Previous: What are settings and
- Contents
-
-
-
-
-
-
-
-A configuration file is a list of command necessary to properly configure your detector systems, with default valuee for some parameters and other settings that the users should normally not change dinamically.
-For this reason most of the commands present in the configuration file cannot be modified when using the API.
-
-The syntax of the configuration file is exactly the same as in the comman line interface, therefore you can refere to that documentation to edit the files.
-
-The configuration files look different for the different detector types. Examples of configuration files can be found in the examples directory.
-
-
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node8.html b/manual/docs/html/slsDetectors-FAQ/node8.html
deleted file mode 100644
index 55848ca72..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node8.html
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-
-
-
-What is the meaning of the file name?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: Which is the sequence
- Up: SLS Detectors Software
- Previous: How should a configuration
- Contents
-
-
-
-
-
-The final file name will be:
-outdir/prefix [_d
-][_S
v0 ][_s
v1 ][_p
p ][_f
f ]_
i .
ext
-
-where:
-outdir is the output directory path;
-prefix is the chosen prefix for the file name;
-d is the detector index, in case of data receiver and more than one detector;
-v0 is the scan0 variable with the desired precision, if scan0 is enabled;
-v1 is the scan1 variable with the desired precision, if scan1 is enabled;
-p is the position index, if different positions are configured;
-f is the frame index of the first frame stored in the file, if many frames and cycles are configured;
-i is the file index;
-ext is the file extension e.g. .raw for MYTHEN raw data, .dat for MYTHEN processed data.
-
-
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/node9.html b/manual/docs/html/slsDetectors-FAQ/node9.html
deleted file mode 100644
index ad7367b10..000000000
--- a/manual/docs/html/slsDetectors-FAQ/node9.html
+++ /dev/null
@@ -1,343 +0,0 @@
-
-
-
-
-
-Which is the sequence of the acquisition flow?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How can I synchronize
- Up: SLS Detectors Software
- Previous: What is the meaning
- Contents
-
-
-
-
-
-
-
-The software gives the possibility to setup several loops, actions and scan utilities which are then handled during the acquisition.
-The software will also take care to generate the file names and increment the indexes accordingly.
-
-
-Figure 1.7 shows in which sequence the various scripts and loops are executed when calling the acquire command. The loops are drawn using the
-
- symbol, while the scripts using the
-
-.
-
-
-
-
-
-
-
-
-
-
-If you prefere to handle the acquisition from your acquisition enviroment, simply leave al scripts and scans disabled and call the acquition from your acquisition enviroment.
-
-Only the frames and cycles loops are defined in firmware and guarantee a precise timing of the acquisition which cannot replaced by any other method (you can synchronize to your beamline by hardware connection of the IO signals as described in 1.8 ).
-
-
-Hereafter a description of the meaning of the various loops:
-
-Measurement loop
-executes offline several times the entire sequence of the acquisition. At the end of each measurement the file index is incremented.
-
-
-
-Scan 0 loop
-is a high level scan loop which can be used e.g to loop on an enviroment variable (temperature, humidity...) or even to change sample.
-
-The list of steps or range of the scan0 variable must be set as scan0steps or scan0range. For small steps of the scan variable, avoid overwriting of the files specifying all the necessary digits in the filename by properly setting the precision with scan0prec.
-
-
-
-Scan 1 loop
-is a low level scan loop which can be used e.g to loop on an enviroment variable (temperature, humidity...) or to move the sample in case of radiation damage.
-
-The list of steps or range of the scan1 variable must be set as scan1steps or scan1range. For small steps of the scan variable, avoid overwriting of the files specifying all the necessary digits in the filename by properly setting the precision with scan1prec.
-
-
-
-Position loop
-The detector is moved in the angular positions specified by the positions command.
-
-The command for moving the detector should be defined as described in 1.10 .
-
-All data acquired during a position loop will be merged together, unless the number of positions is set to 0. In this case single frames will be converted to angle without merging.
-
-Avoid using the position loop together with many frames/cycles.
-
-
-
-Cycles loop
-is executed in real time and defines e.g. the number of triggers that will be accepted. The total number of images will be given by frames times cycles.
-
-
-
-Frames loop
-is executed in real time and defines e.g. the images acquired per trigger. The total number of images will be given by frames times cycles.
-
-
-
-
-Executing a script simply consists in a system call with the arguments specified below. The various scripts are executed only if they are enabled and different than none .
-
-The scripts must be executable and the capability of parsing the arguments passed by the acquition program is left to the user writing the scripts. some example scripts writte in awk can be found in the examples directory.
-
-Hereafter a short description of how the scripts are called and with which options:
-
-Start script
-is executed at the very beginning of the measurement and can be used e.g. to initialize all the devices needed for the acquisition or open the beamline valves. The script is executed as:
-
-script nrun=i par=p
-
-where i is the file index and p is the start script parameter .
-
-
-
-Scan0 script
-There are a few predefined scan modes i.e. threshold changing the detector threshold in DAC units, energy chaning the calibrated detector threshold in eV, trimbits chaning the trimbits of the detector (advanced: do not use) and position changing the detector position (if the motor movement is correctly setup as described in 1.10 ). Otherwise the scan0script is executed as:
-
-script nrun=i fn=fn var=v par=p
-
-where i is the file index , fn is the file name , v is the value of the scan0 variable at the present step of the scan0 loop and p is the scan 0 script parameter .
-
-
-
-Scan1 script
-There are a few predefined scan modes i.e. threshold changing the detector threshold in DAC units, energy chaning the calibrated detector threshold in eV, trimbits chaning the trimbits of the detector (advanced: do not use) and position changing the detector position (if the motor movement is correctly setup as described in 1.10 ). Otherwise the scan1script is executed as:
-
-script nrun=i fn=fn var=v par=p
-
-where i is the file index , fn is the file name , v is the value of the scan1 variable at the present step of the scan1 loop and p is the scan 1 script parameter .
-
-
-
-Script before
-is called just before the beginning of the data taking and can be used e.g. to open the shutter.
- The script is executed as:
-
-script nrun=i fn=fn par=p sv0=v0 sv1=v1 p0=p0 p1=p1
-
-where i is the file index , fn is the file name , p is the script before parameter , v0 and v1 are the values of the scan0 and scan1 variables at the present step of the scan loops and p0 and p1 are the scan0 and scan1 script parameters .
-
-
-
-Header before script
-is called before every step of the data taking (i.e. for each position, but at the beginning of the frames train if several acquisition have been programmed in real time) and can e.g. be used to dump the exact settings of the detector and beamline to reproduce or analyze the data offline.
- The script is executed as:
-
-script nrun=i fn=fn par=p
-
-where i is the file index , fn is the file name , and p is the header before parameter .
-
-
-
-Header after script
-is called after every step of the data taking (i.e. for each position, but at the end of the frames train if several acquisition have been programmed in real time) and can e.g. be used to dump the exact settings of the detector and beamline to reproduce or analyze the data offline.
- The script is executed as:
-
-script nrun=i fn=fn par=p
-
-where i is the file index , fn is the file name , and p is the header after parameter .
-
-
-
-Script after
-is called just after the end of the data taking and can be used e.g. to close the shutter.
- The script is executed as:
-
-script nrun=i fn=fn par=p sv0=v0 sv1=v1 p0=p0 p1=p1
-
-where i is the file index , fn is the file name , p is the script after parameter , v0 and v1 are the values of the scan0 and scan1 variables at the present step of the scan loops and p0 and p1 are the scan0 and scan1 script parameters .
-
-
-
-Stop script
-is executed at the very end of the measurement and can be used e.g. to switch off all devices. The script is executed as:
-
-script nrun=i par=p
-
-where i si the file index and p is the stop script parameter .
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: How can I synchronize
- Up: SLS Detectors Software
- Previous: What is the meaning
- Contents
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/html/slsDetectors-FAQ/slsDetectors-FAQ.css b/manual/docs/html/slsDetectors-FAQ/slsDetectors-FAQ.css
deleted file mode 100644
index d1824aff4..000000000
--- a/manual/docs/html/slsDetectors-FAQ/slsDetectors-FAQ.css
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Century Schoolbook font is very similar to Computer Modern Math: cmmi */
-.MATH { font-family: "Century Schoolbook", serif; }
-.MATH I { font-family: "Century Schoolbook", serif; font-style: italic }
-.BOLDMATH { font-family: "Century Schoolbook", serif; font-weight: bold }
-
-/* implement both fixed-size and relative sizes */
-SMALL.XTINY { font-size : xx-small }
-SMALL.TINY { font-size : x-small }
-SMALL.SCRIPTSIZE { font-size : smaller }
-SMALL.FOOTNOTESIZE { font-size : small }
-SMALL.SMALL { }
-BIG.LARGE { }
-BIG.XLARGE { font-size : large }
-BIG.XXLARGE { font-size : x-large }
-BIG.HUGE { font-size : larger }
-BIG.XHUGE { font-size : xx-large }
-
-/* heading styles */
-H1 { }
-H2 { }
-H3 { }
-H4 { }
-H5 { }
-
-/* mathematics styles */
-DIV.displaymath { } /* math displays */
-TD.eqno { } /* equation-number cells */
-
-
-/* document-specific styles come next */
diff --git a/manual/docs/html/slsDetectors-FAQ/slsDetectors-FAQ.html b/manual/docs/html/slsDetectors-FAQ/slsDetectors-FAQ.html
deleted file mode 100644
index 7146179fa..000000000
--- a/manual/docs/html/slsDetectors-FAQ/slsDetectors-FAQ.html
+++ /dev/null
@@ -1,250 +0,0 @@
-
-
-
-
-
-SLS Detectors
-Frequently Asked Questions
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Next: Contents
- Contents
-
-
-
-
-
-
-
SLS Detectors
-
-Frequently Asked Questions
-Anna Bergamaschi
-
-Date: November 28, 2017
-
-
-
-
-
-
-
-
-
-
-
-Thattil Dhanya
-2017-11-28
-
-
-
diff --git a/manual/docs/pdf/slsDetectorInstall.pdf b/manual/docs/pdf/slsDetectorInstall.pdf
deleted file mode 100644
index df1e25a00..000000000
Binary files a/manual/docs/pdf/slsDetectorInstall.pdf and /dev/null differ
diff --git a/manual/docs/pdf/slsDetectors-FAQ.pdf b/manual/docs/pdf/slsDetectors-FAQ.pdf
deleted file mode 100644
index d893cd25d..000000000
Binary files a/manual/docs/pdf/slsDetectors-FAQ.pdf and /dev/null differ
diff --git a/manual/manual-main/Makefile b/manual/manual-main/Makefile
index a87cf09e1..130ddea50 100644
--- a/manual/manual-main/Makefile
+++ b/manual/manual-main/Makefile
@@ -4,28 +4,34 @@ DESTDIR=../docs
TEX=latex
-MAINTEXS= slsDetectorInstall.tex slsDetectors-FAQ.tex
+MAINTEXS2= slsDetectorInstall.tex
+MAINTEXS=slsDetectors-FAQ.tex
TEXS=slsDetector-softFAQ.tex singlePhotonCounting-FAQ.tex angConv-FAQ.tex generalDet-FAQ.tex
DVIS = $(MAINTEXS:.tex=.dvi)
PSS = $(MAINTEXS:.tex=.ps)
PDFS = $(MAINTEXS:.tex=.pdf)
+PDFS2 = $(MAINTEXS2:.tex=.pdf)
HTMLS = $(MAINTEXS:%.tex=%)
+HTMLS2 = $(MAINTEXS2:%.tex=%)
all: pdf html
echo $(PWD)
echo $(PDFS)
+ echo $(PDFS2)
echo $(HTMLS)
+ echo $(HTMLS2)
-pdf: $(PDFS)
+pdf: $(PDFS) $(PDFS2)
$(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR))
$(shell test -d $(DESTDIR)/pdf || mkdir -p $(DESTDIR)/pdf)
- mv $(PDFS) $(DESTDIR)/pdf
+ mv $(PDFS) $(DESTDIR)/pdf
+ mv $(PDFS2) $(DESTDIR)/pdf
-html: $(HTMLS)
+html: $(HTMLS) $(HTMLS2)
$(HTMLS): $(TEXS) $(MAINTEXS)
@@ -34,7 +40,18 @@ $(HTMLS): $(TEXS) $(MAINTEXS)
$(shell test -d $(DESTDIR)/html/$@ && rm -fr $(DESTDIR)/html/$@)
echo "***************************** $@"
latex $@.tex
- latex2html -split 4 $@.tex
+ latex2html $@.tex
+ mv $@ $(DESTDIR)/html
+
+$(HTMLS2): $(MAINTEXS2)
+ $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR))
+ $(shell test -d $(DESTDIR)/html || mkdir -p $(DESTDIR)/html)
+ $(shell test -d $(DESTDIR)/html/$@ && rm -fr $(DESTDIR)/html/$@)
+ echo "***************************** $@"
+ latex $@.tex
+ latex2html -split 16 -no_navigation -info "" -address "" -long_titles 5 -link 0 $@.tex
+ #-show_section_numbers $@.tex
+ # -local_icons
mv $@ $(DESTDIR)/html
@@ -51,7 +68,7 @@ $(HTMLS): $(TEXS) $(MAINTEXS)
clean:
- rm -rf *.aux *.log *.toc *.out $(DVIS) $(PSS) $(PDFS) $(HTMLS)
+ rm -rf *.aux *.log *.toc *.out $(DVIS) $(PSS) $(PDFS) $(PDFS2) $(HTMLS) $(HTMLS2)
rm -rf $(DESTDIR)/html/slsDetectors-FAQ
rm -rf $(DESTDIR)/html/slsDetectorInstall
rm -rf $(DESTDIR)/pdf/slsDetectors-FAQ.pdf
diff --git a/manual/manual-main/slsDetectorInstall.tex b/manual/manual-main/slsDetectorInstall.tex
index 4b73977ec..0df430fdd 100644
--- a/manual/manual-main/slsDetectorInstall.tex
+++ b/manual/manual-main/slsDetectorInstall.tex
@@ -3,135 +3,299 @@
\usepackage[dvips]{graphicx}
\usepackage{verbatim}
\usepackage{hyperref}
+\usepackage{color}
+
+
+
\begin{document}
\title{SLS Detectors software installation}
-\author{Anna Bergamaschi}
+\author{Anna Bergamaschi, Dhanya Thattil}
\date{\today}
\maketitle
\tableofcontents
\clearpage
+%setcounter{tocdepth}{4} and \setcounter{secnumdepth}{4}
-The SLS detectors software is intended to control the detectors developed by the SLS Detectors group.
-
-It provides a command line interface (text client), a graphical user interface (GUI) as well as an API that can be embedded in your acquisitions system, some tools for detector calibration and the software to receive the data from detector with high data throughput (e.g. GOTTHARD, EIGER).
-\section{The software package}
+
+\section{The Software Package}
+The SLS detectors software is intended to control the detectors developed by
+the SLS Detectors group. The detectors currently supported are:
+
+\indent MYTHEN, GOTTHARD, EIGER and JUNGFRAU.
-The complete software package is composed of several programs which can be installed (or locally compiled) depending on the needs:
+The package provides software for the distributed system that comprises of
+detectors, data receivers (to process detector data), and the client (to control
+or monitor the system). The client and data receivers can be embedded in
+the user's acquisitions system. Furthermore, the package also provides some
+tools for detector calibration.
+
+\subsection{Binaries}
+\noindent The complete software package is composed of several programs which
+can be installed (or locally compiled) depending on one's requirements:
\begin{itemize}
-\item The \textbf{slsDetector shared and static libraries} which are necessary for all user interfaces. \\
- The class slsDetectorUsers can be used as API from your acquisition software (see separate documentation).
-\item The \textbf{command line interfaces (sls\_detector\_put, sls\_detector\_get, sls\_detector\_acquire, sls\_detector\_help)}, which are provided to communicate with the detectors using the command line and eventually to the data receiver
-\item The \textbf{data receiver (slsReceiver)}, which can be run on a different machine, receives the data from the detector and interfaces to the control software via TCP/IP for defining e.g. the file name, output path and return status and progress of the acquisition
-\item The \textbf{graphical user interface (slsDetectorGUI)} which provides a user friendly way of operating the detectors with online data preview
-\item The \textbf{calibration wizards (energyCalibrationWizard, angularCalibrationWizard)} to analyze the data and produce the energy or angular calibration files
-\item The \textbf{GOTTHARD and MYTHEN virtual servers} to simulate the detectors behavior (however only control commands work, not the data acquisition itself)
+
+\item \textcolor{blue}{libSlsDetector.so, libSlsReceiver.so}:\\
+The \textit{slsDetector shared and static libraries}, which are
+necessary for all user interfaces. The \textit{C++ API} via the class
+\textit{slsDetectorUsers} (installed with the default package) or the
+\textit{Python API} via the class \textit{sls\_detector} (installed with the
+package including Python API), which can be used from the user's acquisition
+software to control the detectors and the data receivers.
+
+\item \textcolor{blue}{sls\_detector\_put, sls\_detector\_get,
+sls\_detector\_acquire, sls\_detector\_help}: \\
+The \textit{command line interfaces}, which are provided to communicate with the
+detectors and data receivers using the command line.
+
+\item \textcolor{blue}{slsReceiver}: \\
+The \textit{data receiver}, which can be run on a different machine than the
+client, receives the data from the detector and processes it. The receiver can
+be configured, controlled and monitored by the client.
+
+\item \textcolor{blue}{slsDetectorGUI}: \\
+The \textit{graphical user interface}, which provides a user friendly way
+of operating the detectors and data receivers with online data preview.
+
+\item \textcolor{blue}{energyCalibrationWizard,angularCalibrationWizard}: \\
+The \textit{calibration wizards} to analyze the data and produce the energy or
+angular calibration files.
+
+\item The \textit{virtual Detector servers} to simulate the detectors behavior.
+However, only control commands work, not the data acquisition itself.
\end{itemize}
-Please refere to the SLS Detectors FAQ for additional documentation.
-\section{Requirements}
-The software is written in C/C++.\\
-It needs to be able to access the shared memeory of the control PC and communicate to the detectors over TCP/IP. Therefore the detector should receive a proper IP address (either DHCP or static) and no firewall should be present between th control PC and the detector.
-For installing the slsDetector shared and static libraries and the slsDetectorClient software, any Linux installation with a working gcc should be fine.
+\section{Install Binaries via Conda}
+This section is useful only if one wants to download only the binaries for
+specific distribution and use the package via command line. Please refer later
+sections to download source code and compile them.
-The slsDetectorGUI is based on Qt4 with Qwt libraries.
-The calibration wizards are based on the CERN Root data analysis framework.
+One can download and install Miniconda via
-To compile the software you will need the whole Qt4, Qwt and Root installation, including the header files.\\
-To run the software, it is enough to have the Qt4, Qwt or Root libraries appended to the \verb=LD_LIBRARY_PATH=.
+\url{https://conda.io/miniconda.html}
-\subsection{Qt4 installation}
-A Qt version equal or higher than 4.6 is required.
+The conda package uses Travis CI for continuous integration with
+automatic deployment to Anaconda Cloud. One can download only the package or the
+package including the python interface.
+
+
+After the installation, the binaries will be available in your path.
+
+Please remember to clear shared memory after installation.
+\begin{verbatim}
+#displays list of shared memeory segments
+ipcs -m
+#remove segments that have nattach equal to zero. They key is the first column
+ipcrm -M [key]
+\end{verbatim}
+
+\begin{itemize}
+ \item Only the package
+\begin{verbatim}
+#Add conda channels
+conda config --add channels conda-forge
+conda config --add channels slsdetectorgroup
+
+#Install latest version
+conda install sls_detector_software
+
+#Install specific release (GLIBC2.14)
+conda install sls_detector_software=3.1.0
+
+#Scientific Linux 6 version (GLIBC2.12)
+conda install sls_detector_software=SL6_3.1.0
+\end{verbatim}
+ \item The package including Python interface
+\begin{verbatim}
+#Add conda channels
+conda config --add channels conda-forge
+conda config --add channels sls_detector
+
+#Install latest version
+conda install sls_detector
+
+#Install specific release (GLIBC2.14)
+conda install sls_detector=3.1.0
+
+#Scientific Linux 6 version (GLIBC2.12)
+conda install sls_detector=SL6_3.1.0
+\end{verbatim}
+\end{itemize}
+
+
+\clearpage
+\section{Install via Source Code}
+This section is useful if one wants to use the API and embed it in their
+acquisition system, or if one wants to download the source code and compile.
+
+\subsection{Download Source Code}
+
+\begin{itemize}
+ \item Only the package
+\begin{verbatim}
+#Clone source code with specific release
+git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git --branch
+3.1.0
+\end{verbatim}
+ \item The package including Python interface
+\begin{verbatim}
+#Clone source code with specific release
+git clone https://github.com/slsdetectorgroup/sls_detector.git --branch
+3.1.0
+\end{verbatim}
+\end{itemize}
+
+
+
+\subsection{Requirements}
+These are the basic requirements to install and use the software. Fine Tuning
+the system will be discussed in other documentation provided.
+\begin{itemize}
+
+ \item \emph{C/C++}:\\
+The software is written in C/C++. If Python API is used, it is a wrap around
+to the C++ software. Any Linux installation with working libgcc should be
+sufficient.
+
+ \item \emph{Shared Memory}:\\
+Access to the shared memory of the control PC is required for the client.
+
+ \item \emph{Network}:\\
+The control PC communicates to the detectors and data receivers over TCP/IP.
+Therefore, the detector should receive a proper IP address (either DHCP or
+static) and no firewall should be present between the control PC and the
+detector.
+
+\item \emph{Compilation}:\\
+cmake is required to compile. make is also possible, but is harder to find
+dependencies.
+
+\item \emph{GUI}:\\
+To use the GUI, one requires atleast Qt4.8.2 and Qwt6.0. Installation of these
+are discussed in the next sections.
+
+\item \emph{Calibration Wizards}:\\
+They are based on the CERN Root data analysis framework. Installation of it is
+discussed in the next sections.
+
+\end{itemize}
+
+
+\subsubsection{Qt4 Installation for GUI}
+It must be installed before Qwt. A Qt version equal or higher than 4.6 is
+required. One can install it:
+\begin{itemize}
+ \item via YUM:
+\begin{verbatim}
+ yum install qt-devel
+\end{verbatim}
+ \item via download from:\\
+\url{
+https://download.qt.io/archive/qt/4.8/4.8.2/qt-everywhere-opensource-src-4.8.2.t
+ar.gz}
-You can retrieve the Qt4 libraries using YUM or download the open source version from e.g. \url{ftp://ftp.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.8.1.tar.gz}
To install:
\begin{verbatim}
-> gunzip qt-everywhere-opensource-src-4.6.2.tar.gz
-> tar xvf qt-everywhere-opensource-src-4.6.2.tar
+> gunzip qt-everywhere-opensource-src-4.8.2.tar.gz
+> tar xvf qt-everywhere-opensource-src-4.8.2.tar
> ./configure
> make
> make install
\end{verbatim}
+By default Qt4 will be installed in /usr/local/Trolltech/Qt-4.8.2/.
+\end{itemize}
-By default Qt4 will be installed int /usr/local/Trolltech/Qt-4.8.1/
-Edit your .bashrc to define the enviroment variable \verb=QTDIR= and add the libraries and exacutables to your \verb=LD_LIBRARY_PATH= and \verb=PATH=:
+
+\textbf{Setup Environment}
+
+
+One has to ensure that \verb=PATH= and \verb=LD_LIBRARY_PATH= have
+been updated to include Qt4 install path, binaries and libraries.
+Confirm by executing \verb=qmake -v= and ensuring the result points to Qt4 (not
+Qt3 or Qt5).
+
+
+If the environment is not set up, one can add the libraries and
+executables to the .bashrc by adding
+\verb=LD_LIBRARY_PATH= and \verb=PATH=:
\begin{verbatim}
-export QTDIR=/usr/local/Trolltech/Qt-4.8.1
+export QTDIR=/usr/local/Trolltech/Qt-4.8.2
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
\end{verbatim}
-If your system also have Qt3 installed, make sure that \verb=QTDIR=, \verb=PATH= and \verb=LD_LIBRARY_PATH= point to Qt4 before installing Qwt (and of course compiling and running the GUI).
-\subsection{Qwt installation}
-A Qwt version equal or higher than 5 is required.\\
-Before installing it, make sure that your \verb=QTDIR=, \verb=LD_LIBRARY_PATH= and \verb=PATH= point to the correct Qt4 version.
+\subsubsection{Qwt Installation for GUI}
+Before installing Qwt, one must install Qt
+and ensure that \verb=QTDIR=, \verb=LD_LIBRARY_PATH= and \verb=PATH= point to
+the correct Qt4
+version.
-You can retrieve the Qwt libraries using YUM or download the open source version via svn:
+
+A Qwt version equal or higher than 6 is required. One can
+install it:
+\begin{itemize}
+ \item via YUM:
\begin{verbatim}
-> svn co https://qwt.svn.sourceforge.net/svnroot/qwt/branches/qwt-6.0
+ yum install qwt-devel
\end{verbatim}
+ \item via download from:\\
+\url{
+https://sourceforge.net/projects/qwt/files/qwt/6.0.0/qwt-6.0.0.zip/download}
+
To install:
\begin{verbatim}
-> cd qwt-6.0
+> cd qwt-6.0.0
> qmake
> make
> make install
\end{verbatim}
+By default Qwt will be installed int /usr/local/qwt-6.0.0
+\end{itemize}
-By default Qwt will be installed in /usr/local/qwt-6.0
-Edit your .bashrc to define the enviroment variable \verb=QWTDIR= and add the libraries to the \verb=LD_LIBRARY_PATH=:
+\textbf{Setup Environment}
+
+
+One has to ensure that \verb=QWTDIR= and \verb=LD_LIBRARY_PATH= have
+been updated to include Qwt install path and libraries.
+
+
+If the environment is not set up, one can add the libraries to the
+.bashrc by adding \verb=LD_LIBRARY_PATH=:
\begin{verbatim}
-export QWTDIR=/usr/local/qwt-6.0-svn/
+export QWTDIR=/usr/local/qwt-6.0.0/
export LD_LIBRARY_PATH=$QWTDIR/lib:$LD_LIBRARY_PATH
\end{verbatim}
-\subsection{Installation with YUM}
-
-You must install the qt4 and qwt development package i.e.
-\begin{verbatim}
-> yum install qt-devel qwt-devel
-\end{verbatim}
- and then edit edit your .bashrc as follows
-\begin{verbatim}
-export ROOTSYS=/opt/root/5.28.00
-export QTDIR=/usr/lib64/qt4
-export QWTDIR=/usr/include/qwt
-export PATH=$QTDIR:bin:$PATH
-\end{verbatim}
-
-You should then continue with the root installation.
-
-To compile, you should edit the file slsDetectorGui/slsDetectorGui.pro as follows.\\
-All lines containing \verb=$QTDIR= and \verb=$QWTDIR= should be commented, except in the INCLUDEPATH (\verb=$QWTDIR \=).\\
-Moreover the \verb=LIBS= line should be changed \verb=-L$(QWTDIR)/lib= to \verb=-L$(QWTDIR)/lib64=.
-\subsection{Root installation}
-The software has been developed and tested with root 5.20, but any version should work.
-Download the sources via svn:
+
+
+\subsubsection{Root Installation for Calibration Wizards}
+The software has been developed and tested with root 5.20, but any version
+should work. One can download it from:
\begin{verbatim}
> svn co https://root.cern.ch/svn/root/trunk root
\end{verbatim}
-To install:
+\noindent To install:
\begin{verbatim}
> cd root
> ./configure --enable-qt
@@ -139,120 +303,212 @@ To install:
> make install
\end{verbatim}
-Edit your .bashrc to define the ROOTSYS enviroment variable and annd the libraries and executables to the \verb=LD_LIBRARY_PATH= and \verb=PATH=:
+Edit your .bashrc to define the ROOTSYS enviroment variable and annd
+the libraries and executables to the \verb=LD_LIBRARY_PATH= and \verb=PATH=:
\begin{verbatim}
-export ROOTSYS=/usr/local/root
+export ROOTSYS=/usr/local/root-5.34
export PATH=$ROOTSYS/bin:$PATH
export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH
\end{verbatim}
-You can also download the binaries, assuming that your linuc and gcc versions match:
+You can also download the binaries, assuming that your linux and gcc versions
+match as in:
\begin{verbatim}
http://root.cern.ch/drupal/content/production-version-534
\end{verbatim}
-\section{Compilation}
-If you simply want to install the software in the working directory you can:
+\subsection{Compilation}
+One requires \verb=cmake= to compile and can be done in two ways:
+
+\subsubsection{Using script cmk.sh}
+The script uses \verb=cmake=. After compiling, the libraries and executables
+will be found in `slsDetectorPackage/build/bin` directory.
+Usage: [-c] [-b] [-h] [-d HDF5 directory] [-j]
\begin{itemize}
-\item[make] compile the library, the command line interface and the receiver
-
-\item[make lib] compile only the library
-
-\item[make textclient] compile the command line interface (and the library, since it is required)
-
-\item[make stextclient] compile the command line interface statically linking the library (and the library, since it is required)
-
-\item[make receiver] compile the data reciever (and the library, since it is required)
-
-\item[make sreceiver] compile the data reciever statically linking the library (and the library, since it is required)
-
-\item[make gui] compile slsDetectorGUI - requires a working Qt4 and Qwt installation
-
-\item[make calWiz] compile the calibration wizards - requires a working root installation
-
-\item[make doc] compile documentation in pdf format
-
-\item[make htmldoc] compile documentation in html format
-
-\item[make install\_lib] installs the libraries, the text clients, the documentation and the includes for the API
-
-\item[make install] installs all software, including the gui, the cal wizards and the includes for the API
-
-\item[make confinstall] installs all software, including the gui, the cal wizards and the includes for the API, prompting for the install paths
-
-\item[make clean] remove object files and executables
-
-\item[make help] lists possible targets
-
-\item[make mythen\_virtual] compile a virtual MYTHEN detector server (works for control commands, not for data taking)
-
-\item[make gotthard\_virtual] compile a virtual GOTTHARD detector server (works for control commands, not for data taking)
+ \item -[no option]: only make
+ \item -c: Clean
+ \item -b: Builds/Rebuilds CMake files normal mode
+ \item -h: Builds/Rebuilds Cmake files with HDF5 package
+ \item -d: HDF5 Custom Directory
+ \item -t: Build/Rebuilds only text client
+ \item -r: Build/Rebuilds only receiver
+ \item -g: Build/Rebuilds only gui
+ \item -j: Number of threads to compile through
\end{itemize}
-The path where the files binaries, libraries, documentation and includes will be installed can either be defined interactively by sourcing the \verb=configure= script (not executing!) or during compilation using \verb=make confinstall= or defined on the command line deifning one (or all) the following variables (normally \verb=INSTALLROOT= is enough:
-\begin{itemize}
-\item[INSTALLROOT] Directory where you want to install the software. Defaults to \verb=PWD=
-\item[BINDIR] Directory where you want to install the binaries. Defaults to bin/
-\item[INCDIR] Directory where you want to pute the header files. Defaults to include
-\item[LIBDIR] Directory where you want to install the libraries. Defaults to bin/
-\item[DOCDIR] Directory where you want to copy the documentation. Defaults to doc/
-\end{itemize}
+Some example options for compilation:
+
+Most basic option: \verb=./cmk.sh -b=
+
+For only make: \verb=./cmk.sh=
+
+For make clean;make: \verb=./cmk.sh -c=
+
+For using hdf5 without custom dir /blabla: \verb=./cmk.sh -h -d /blabla=
+
+For rebuilding cmake without hdf5: \verb=./cmk.sh -b=
+
+For using multiple cores to compile faster: \verb=./cmk.sh -j9=
+
+For rebuilding only certain parts: \verb=./cmk.sh -tg= (only text client and
+gui)
+
+
+\subsubsection{Directly using cmake}
+
+Use cmake to create out-of-source builds, by creating a build folder parallel to
+source directory.
+\begin{verbatim}
+ $ cd ..
+ $ mkdir slsDetectorPackage-build
+ $ cd slsDetectorPackage-build
+ $ cmake ../slsDetectorPackage -DCMAKE_BUILD_TYPE=Debug -DUSE_HDF5=OFF
+ $ make
+\end{verbatim}
+
+Use the following as an example to compile statically and using specific hdf5
+folder
+\begin{verbatim}
+ $ HDF5_ROOT=/opt/hdf5v1.10.0 cmake ../slsDetectorPackage
+-DCMAKE_BUILD_TYPE=Debug -DUSE_HDF5=ON
+\end{verbatim}
+
+After compiling, the libraries and executables will be found at `bin` directory
+\begin{verbatim}
+ $ ls bin/
+ gui_client libSlsDetector.a libSlsDetector.so libSlsReceiver.a
+libSlsReceiver.so sls_detector_acquire sls_detector_get slsDetectorGui
+sls_detector_help sls_detector_put slsReceiver
+\end{verbatim}
-To be able to run the executables, append the \verb=BINDIR= directory to your \verb=PATH= and \verb=LIBDIR= to the \verb=LD_LIBRARY_PATH=.
-To run the GUI, you also need to add to your \verb=LD_LIBRARY_PATH= the Qt4 and Qwt libraries, without the need to install the whole Qt and Qwt developer package:
-\begin{itemize}
-\item libqwt.so.6
-\item libQtGui.so.4
-\item libQtCore.so.4
-\item libQtSvg.so.4
-\end{itemize}
+\subsection{Setting environment variables}
+One can set up the environment variables in the following ways.
-To run the calibration wizards it is preferrable to have a complete Root installation (binaries), with \verb=ROOTSYS= defined and the libraries added to the \verb=LD_LIBRARY_PATH=.
-
-
-\section{Detector upgrade}
-
-Sometimes the upgarde of the communication software, can require an upgrade of the software and/or firmware running on the detector as well.\\
-In these cases, the users are not expected to compile teh software themselves (which would require dedicated softwares) but only to download on the detector board the programming files and/or communication program provided by the SLS Detectors group.
-
-
-\subsection{MYTHEN upgrade}
-\subsubsection{Firmware upgrade}
-
-To upgrade the firmware you need either a working version of the Altera Quartus software or of the Quartus programmer, which can easly be downloade from \\
-\verb=https://www.altera.com/download/programming/quartus2/pq2-index.jsp= \\
-Normally installation of the software and of the driver for the USB-Blaster (provided together with the MYTHEN detector) are simpler under Windows.\\
-Under Windows, the first time that you connect the USB-Blasterto one of your USB ports, you will be asked to install new hardware. Set the path to search
-for the driver to: \verb=C:\altera\80sp1\qprogrammer\drivers\usb-blasterp= (where \verb=C:\altera\80sp1\qprogrammer\= is assumed to be ther path where your Quartus version is installed).\\
+\subsubsection{Using .bashrc file}
\begin{enumerate}
-\item After starting the Quartus programmer, click on Hardware Setup and in the "Currently selected hardware" window select USB-Blaster.
-\item In the Mode combo box select "Active Serial Programming".
-\item Plug the end of your USB-Blaster WITH THE ADAPTER PROVIDED in the connector ASMI on the MCS board taking care that pin1 corresponds to the one indexed and with the rectangualr pad.
-\item Click on add file and from select the programming file provided when the upgrade has been reccomended.
-\item Check "Program/Configure" and "Verify".
-\item Push the start button and wait until the programming process is finished (progress bar top left).
-\item In case the programmer gives you error messages, check the polarity of your cable (pin1 corresponds) and that you have selected the correct programming connector.
+ \item \verb=emacs ~/.bashrc=
+ \item Add the following function \verb=setup_slsdet= and replace \verb=path=
+with absolute path of installed directory
+\begin{verbatim}
+function setup_slsdet
+{
+export PKGPATH=[path]
+export LD_LIBRARY_PATH=$PKGPATH/slsDetectorPackage/build/bin:$LD_LIBRARY_PATH
+export PATH=$PKGPATH/slsDetectorPackage/build/bin:$PATH
+cd $PKGPATH/slsDetectorPackage/build/bin
+}
+\end{verbatim}
+ \item \verb=source ~/.bashrc=
+ \item Next time, just run \verb=setup_slsdet= to load the environment
+variables.
\end{enumerate}
-\subsubsection{Software upgrade}
-First telent to the board:
+
+One can also add the GUI environment variables if installed locally by adding
+the following in the function \verb=setup_sldet= \\
+\begin{verbatim}
+export QTDIR=/path-where-it-is/Qt-4.8.2
+export QWTDIR=/path-where-it-is/qwt-6.0.1
+export QWT3D=/path-where-it-is/qwtplot3d
+export QMAKESPEC=$QTDIR/mkspecs/linux-g++
+export LD_LIBRARY_PATH=$QTDIR/lib:$QWTDIR/lib:$QWT3D/lib:$LD_LIBRARY _PATH
+export PATH=$QTDIR/bin:$PATH
+\end{verbatim}
+
+\subsubsection{Without .bashrc file}
+Go to binaries folder slsDetectorPackage/build/bin and execute the following:
+\begin{verbatim}
+export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH
+export PATH=$PWD:$PATH
+\end{verbatim}
+
+
+\subsection{Clean Shared Memory}
+It is very crucial to clean the shared memory, before using a new version of
+the SLS Detector Package or a different detector type.
+
+One can use the \verb=cleansharedmemory.sh= script available under the
+slsDetector Package.
+
+One can also just use the following commands to clean the shared memory
+segments one by one.
+\begin{verbatim}
+#displays list of shared memeory segments
+ipcs -m
+#remove segments that have nattach equal to zero. They key is the first column
+ipcrm -M [key]
+\end{verbatim}
+
+\section{Software Upgrade}
+
+The upgrade of the package could require an upgrade of the on-board detector
+server and/or firmware running on the detector as well.
+
+
+\subsection{MYTHEN}
+In such cases, the users are not expected to compile the software
+themselves (which would require dedicated softwares) but only to download on the
+detector board the programming files and/or software package provided by
+the SLS Detectors group.
+
+\subsubsection{MYTHEN Firmware}
+
+To upgrade the firmware you need either a working version of the Altera
+Quartus software or of the Quartus programmer, which can easily be downloaded
+from: \\
+\url{https://www.altera.com/download/programming/quartus2/pq2-index.jsp}
+\medskip
+
+\noindent Normally, installation of the software and of the driver for the
+USB-Blaster (provided together with the MYTHEN detector) are simpler under
+Windows.
+
+
+Under Windows, the first time that you connect the USB-Blaster to one
+of your USB ports, you will be asked to install new hardware. Set the path to
+search for the driver to:
+\verb=C:\altera\80sp1\qprogrammer\drivers\usb-blasterp= (where
+\verb=C:\altera\80sp1\qprogrammer\= is assumed to be ther path where your
+Quartus version is installed).
+\begin{enumerate}
+\item After starting the Quartus programmer, click on Hardware Setup and in the
+"Currently selected hardware" window select USB-Blaster.
+\item In the Mode combo box select "Active Serial Programming".
+\item Plug the end of your USB-Blaster WITH THE ADAPTER PROVIDED in the
+connector ASMI on the MCS board taking care that pin1 corresponds to the one
+indexed and with the rectangualr pad.
+\item Click on add file and from select the programming file provided when
+the upgrade has been reccomended.
+\item Check "Program/Configure" and "Verify".
+\item Push the start button and wait until the programming process is
+finished (progress bar top left).
+\item In case the programmer gives you error messages, check the polarity of
+your cable (pin1 corresponds) and that you have selected the correct programming
+connector.
+\end{enumerate}
+
+\subsubsection{MYTHEN On-board Software}
+\begin{enumerate}
+ \item Connect to the board using telnet:
\begin{verbatim}
telnet mymcs.mydomain.com
username: root
password: pass
+\end{verbatim}
+ \item Kill currently running servers and ensure \verb=/mnt/flash/root= exists.
+\begin{verbatim}
killall mythenDetectorServer
ls /mnt/flash/root
#if the directory does not exist mkdir /mnt/flash/root
\end{verbatim}
-
-To upgrade the software on the detector board transfer the provided software by ftp to the MCS:
+ \item Transfer the provided software by ftp to the MCS.
\begin{verbatim}
ftp mymcs.mydomain.com
username: root
@@ -262,14 +518,312 @@ put mythenDetectorServer
quit
\end{verbatim}
-After pressing reset on the board, the board should reboot.\\
+\item After pressing reset on the board, the board should reboot.
+
+\item If the program does not correctly start
+ \begin{enumerate}
+ \item Check by using the http interface that it is started by the inittab
+(check that the file \verb=/mnt/etc/inittab= ends with the line \\
+\verb=myid2:3:once:/mnt/flash/root/mythenDetectorServer=).
+ \item If program has not started, make the program executable by telnetting to
+the MCS and executing: \\
+\verb=chmod a+xrw /mnt/flash/root/mythenDetectorServer=
+ \item After pressing reset on the board, the board should reboot and the
+acqusition program correctly start.
+ \end{enumerate}
+\end{enumerate}
+
+
+
+
+\subsection{GOTTHARD}
+
+In such cases, the users are not expected to compile the software
+themselves (which would require dedicated softwares) but only to download on the
+detector board the programming files and/or software package provided by
+the SLS Detectors group.
+
+\subsubsection{GOTTHARD Firmware}
+\textit{For SLS Detector Package v3.1.0} \\
+\indent Minimum compatible version: \\
+\indent \indent 11.01.2013 \\
+\indent Latest version: \\
+\indent \indent 08.02.2018 (50um and 25um Master) \\
+\indent \indent 09.02.2018 (25 um Slave) \\
+
+
+Normally, the firmware will be upgraded by us as it requires programming the
+FPGA via the USB-Blaster.
+
+
+To upgrade the firmware you need either a working version of the Altera
+Quartus software or of the Quartus programmer, which can easily be downloaded
+from: \\
+\url{https://www.altera.com/download/programming/quartus2/pq2-index.jsp}
+
+
+Normally, installation of the software and of the driver for the
+USB-Blaster (provided together with the MYTHEN detector) are simpler under
+Windows.
+
+
+Under Windows, the first time that you connect the USB-Blaster to one
+of your USB ports, you will be asked to install new hardware. Set the path to
+search for the driver to:
+\verb=C:\altera\80sp1\qprogrammer\drivers\usb-blasterp= (where
+\verb=C:\altera\80sp1\qprogrammer\= is assumed to be ther path where your
+Quartus version is installed).
+\begin{enumerate}
+\item After starting the Quartus programmer, click on Hardware Setup and in the
+"Currently selected hardware" window select USB-Blaster.
+\item In the Mode combo box select "Active Serial Programming".
+\item Plug the end of your USB-Blaster WITH THE ADAPTER PROVIDED in the
+connector ASMI on the MCS board taking care that pin1 corresponds to the one
+indexed and with the rectangualr pad.
+\item Click on add file and from select the programming file provided when
+the upgrade has been reccomended.
+\item Check "Program/Configure" and "Verify".
+\item Push the start button and wait until the programming process is
+finished (progress bar top left).
+\item In case the programmer gives you error messages, check the polarity of
+your cable (pin1 corresponds) and that you have selected the correct programming
+connector.
+\end{enumerate}
+
+\subsubsection{GOTTHARD On-board Software}
+Every SLS Detector package release will have its coresponding matching on-board
+server under \textbf{slsDetectorPackage/serverBin}.
+
+\begin{enumerate}
+ \item Install tftp if the pc does not have it.
+ \item Copy the server from serverBin folder to /tftpboot (or equivalent tftp
+folder) of the pc
+ \item Copy the server to the detector by:
+ \begin{enumerate}
+ \item Connect to the blackfin on the detector\\
+\verb=telnet bchipxxx=
+ \item Prevent existing on-board server from respawning by:
+ \begin{enumerate}
+ \item Edit \verb=/etc/inittab=
+ \item Comment out the line
+\verb=#ttyS0::respawn:/gotthardDetectorServervxxx=
+ \item Reboot blackfin using \verb=reboot=
+ \item Run \verb=ps= to ensure no gotthardDetectorServers are running
+ \end{enumerate}
+ \item Copy new on-board server from pc to the blackfin using: \\
+\verb=tftp pcxxx -r gotthardDetectorServerxxx -g=
+ \item Respawn the new server (server starts at detector statup):
+ \begin{enumerate}
+ \item Edit \verb=/etc/inittab=
+ \item Uncomment out the line
+\verb=ttyS0::respawn:/gotthardDetectorServervxxx=
+ \item Reboot blackfin using \verb=reboot=
+ \item Run \verb=ps= to ensure that both the gotthardDetectorServers are
+running.\\
+\verb=gotthardDetectorServerxxx= \\
+\verb=gotthardDetectorServerxxx 1953=
+ \end{enumerate}
+ \end{enumerate}
+\end{enumerate}
+
+
+
+\subsection{EIGER}
+
+In such cases, the users are not expected to compile the software
+themselves (which would require dedicated softwares) but only to download on the
+detector board the programming files and/or software package provided by
+the SLS Detectors group.
+
+\subsubsection{EIGER Firmware}
+\textit{For SLS Detector Package v3.1.0} \\
+\indent Minimum compatible version: 16 \\
+\indent Latest version: 20 \\
+
+
+\begin{enumerate}
+ \item One must get the latest package's corresponding bit files from the SLS
+Detector Group.
+ \item If one does not have the bcp script, that should also be obtained from
+the SLS Detector Group. It is required to program the bit files and requires
+that tftp be installed on the pc.
+ \item Run the following to update firmware
+\begin{verbatim}
+ #update back end fpga
+bcp download.bit bebxxx:/fw0
+
+ #update front left fpga
+bcp download.bit bebxxx:/febl
+
+ #update front right fpga
+bcp download.bit bebxxx:/febr
+
+ #update kernel
+bcp download.bit bebxxx:/kernel
+\end{verbatim}
+Please update bit files with great caution as it could make your board
+inaccessible, if done incorrectly.
+\end{enumerate}
+
+
+
+\subsubsection{EIGER On-board Software}
+Every SLS Detector package release will have its coresponding matching on-board
+server under \textbf{slsDetectorPackage/serverBin}.
+
+
+Update the on-board software without connecting to the detector
+\begin{verbatim}
+#password for the boards: root
+
+#Kill existing servers that are running on the detector
+ssh root@beb031 killall eigerDetectorServer;
+
+#Copy on-board server to detector inside executables folder
+scp ~/path-where-it-is/eigerDetectorServerxxx root@bebxxx:~/executables;
+
+#Overwrite the actual eigerDetectorServer on board
+scp ~/path-where-it-is/eigerDetectorServerxxx
+root@bebxxx:~/executables/eigerDetectorServer;
+
+#sync
+ssh root@bebxxx sync;
+
+#reboot the eiger board
+\end{verbatim}
+
+
+\bigskip One can connect to the detector by:
+\begin{verbatim}
+ssh root@bebxxx
+password: root
+\end{verbatim}
+
+
+The on-board server is in ~/executables folder and respawned at startup in \\
+\verb=/etc/rc5.d/S50board_com.sh=
+
+
+
+
+
+\subsection{JUNGFRAU}
+
+In such cases, the users are not expected to compile the software
+themselves (which would require dedicated softwares) but only to download on the
+detector board the programming files and/or software package provided by
+the SLS Detectors group.
+
+\subsubsection{JUNGFRAU Firmware}
+\textit{For SLS Detector Package v3.1.0} \\
+\indent Minimum compatible version: 13.11.2017 \\
+\indent Latest version: 13.11.2017 \\
+
+
+At times, one has to update the firmware, which then also requires updating the
+on-board software.
+
+
+\textbf{\textit{Jungfrau firmware can be upgraded via the SLS Detector Package
+binaries from the command line.}}
+
+\begin{enumerate}
+ \item One must get the latest package's corresponding POF file from the SLS
+Detector Group.
+ \item Update the latest SLS Detector package installed.
+ \item Update the on-board software as per the instructions in the next
+section.
+ \item Start the on-board server in debug mode:
+ \begin{enumerate}
+ \item Connect to the blackfin on the detector\\
+\verb=telnet bchipxxx=
+ \item Prevent existing on-board server from respawning by:
+ \begin{enumerate}
+ \item Edit \verb=/etc/inittab=
+ \item Comment out the line
+\verb=#ttyS0::respawn:/jungfrauDetectorServervxxx=
+ \item Reboot blackfin using \verb=reboot=
+ \item Run \verb=ps= to ensure no gotthardDetectorServers are running
+ \end{enumerate}
+ \item Start the server in debug mode using: \\
+\verb=./jungfrauDetectorServerxxx -debug= \\
+ Leave this console on to come back to it later.
+ \end{enumerate}
+ \item From the command line of the pc, clear shared memory \\
+\verb=./sls_detector_get free= \\
+ If one gets shmget error, please clean the shared memory properly using the
+script in \verb=slsDetectorPackage/cleansharedmemory.sh=
+ \item Add the detector to shared memory using \\
+\verb=./sls_detector_put hostname bchipxxx=
+ \item Program the FPGA using \\
+\verb=./sls_detector_put programfpga xxx.pof=
+ \item Once the programming is done:
+ \begin{enumerate}
+ \item Switch to the console that has the debug server running and kill it
+using Ctrl+C and ensure no jungfrauDetectorServers are
+running
+ \item Restart the new server to see if it runs with the new firmware \\
+\verb=./jungfrauDetectorServerxxx= \\
+If the server didn't start properly, please contact us with the error message
+shown when starting the server up, else continue with the following steps.
+ \item Respawn the new server (server starts at detector statup):
+ \begin{enumerate}
+ \item Edit \verb=/etc/inittab=
+ \item Uncomment out the line
+\verb=ttyS0::respawn:/jungfrauDetectorServervxxx=
+ \item Reboot blackfin using \verb=reboot=
+ \item Run \verb=ps= to ensure that both the gotthardDetectorServers are
+running.\\
+\verb=jungfrauDetectorServervxxx= \\
+\verb=jungfrauDetectorServervxxx 1953=
+ \end{enumerate}
+ \end{enumerate}
+
+\end{enumerate}
+
+
+
+\subsubsection{JUNGFRAU On-board Software}
+Every SLS Detector package release will have its coresponding matching on-board
+server under \textbf{slsDetectorPackage/serverBin}.
+
+
+\begin{enumerate}
+ \item Install tftp if the pc does not have it.
+ \item Copy the server from serverBin folder to /tftpboot (or equivalent tftp
+folder) of the pc
+ \item Copy the server to the detector by:
+ \begin{enumerate}
+ \item Connect to the blackfin on the detector\\
+\verb=telnet bchipxxx=
+ \item Prevent existing on-board server from respawning by:
+ \begin{enumerate}
+ \item Edit \verb=/etc/inittab=
+ \item Comment out the line
+\verb=#ttyS0::respawn:/jungfrauDetectorServervxxx=
+ \item Reboot blackfin using \verb=reboot=
+ \item Run \verb=ps= to ensure no gotthardDetectorServers are running
+ \end{enumerate}
+ \item Copy new on-board server from pc to the blackfin using: \\
+\verb=tftp pcxxx -r jungfrauDetectorServervxxx -g=
+ \item Respawn the new server (server starts at detector statup):
+ \begin{enumerate}
+ \item Edit \verb=/etc/inittab=
+ \item Uncomment out the line
+\verb=ttyS0::respawn:/jungfrauDetectorServervxxx=
+ \item Reboot blackfin using \verb=reboot=
+ \item Run \verb=ps= to ensure that both the gotthardDetectorServers are
+running.\\
+\verb=jungfrauDetectorServervxxx= \\
+\verb=jungfrauDetectorServervxxx 1953=
+ \end{enumerate}
+ \end{enumerate}
+\end{enumerate}
+
+
-If the program does not correctly start either check by using the http interface that it is started by the inittab (check that the file \verb=/mnt/etc/inittab= ends with the line \verb=myid2:3:once:/mnt/flash/root/mythenDetectorServer= ). \\
-Otherwise make the program executable by telnetting to the MCS and executing:
-\verb=chmod a+xrw /mnt/flash/root/mythenDetectorServer=\\
-After pressing reset on the board, the board should reboot and the acqusition program correctly start.
\begin{comment}
\section{Detector system architecture}
@@ -346,7 +900,11 @@ The \textit{settingsdir} and \textit{caldir} should be properly configured for y
\subsection{GOTTHARD}
A \textit{settingsdir} should be configured, as the directory \verb=settings= in this software package.\\
-It must contain the subdirectories \verb=dynamicgain=, \verb=gain1=, \verb=gain2=, \verb=gain3=, \verb=highgain=, \verb=lowgain=, \verb=mediumgain=, and \verb=veryhighgain= in order to properly configure the GOTTHARD detector using the various gain settings.
+It must contain the subdirectories \verb=dynamicgain=, \verb=gain1=,
+\verb=gain2=, \verb=gain3=, \verb=highgain=, \verb=lowgain=,
+\verb=mediumgain=, and \verb=veryhighgain= in order to properly configure the
+GOTTHARD detector using the various gain settings.
+
\end{comment}
\end{document}
diff --git a/serverBin/eigerDetectorServer_virtualMaster b/serverBin/eigerDetectorServer_virtualMaster
new file mode 120000
index 000000000..8bab52260
--- /dev/null
+++ b/serverBin/eigerDetectorServer_virtualMaster
@@ -0,0 +1 @@
+../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualMaster
\ No newline at end of file
diff --git a/serverBin/eigerDetectorServer_virtualSlave b/serverBin/eigerDetectorServer_virtualSlave
new file mode 120000
index 000000000..fb644ed5c
--- /dev/null
+++ b/serverBin/eigerDetectorServer_virtualSlave
@@ -0,0 +1 @@
+../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualSlave
\ No newline at end of file
diff --git a/serverBin/eigerDetectorServerv3.1.0.16.1 b/serverBin/eigerDetectorServerv3.1.0.16.1
new file mode 120000
index 000000000..2c90d8002
--- /dev/null
+++ b/serverBin/eigerDetectorServerv3.1.0.16.1
@@ -0,0 +1 @@
+../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.1.0.16.1
\ No newline at end of file
diff --git a/serverBin/gotthardDetectorServer_virtual b/serverBin/gotthardDetectorServer_virtual
new file mode 120000
index 000000000..e0f7013b5
--- /dev/null
+++ b/serverBin/gotthardDetectorServer_virtual
@@ -0,0 +1 @@
+../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_virtual
\ No newline at end of file
diff --git a/serverBin/gotthardDetectorServerv3.0.0.6 b/serverBin/gotthardDetectorServerv3.0.0.6
deleted file mode 120000
index ca005a699..000000000
--- a/serverBin/gotthardDetectorServerv3.0.0.6
+++ /dev/null
@@ -1 +0,0 @@
-../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv3.0.0.6
\ No newline at end of file
diff --git a/serverBin/gotthardDetectorServerv3.1.0.1 b/serverBin/gotthardDetectorServerv3.1.0.1
new file mode 120000
index 000000000..499ae8c21
--- /dev/null
+++ b/serverBin/gotthardDetectorServerv3.1.0.1
@@ -0,0 +1 @@
+../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv3.1.0.1
\ No newline at end of file
diff --git a/serverBin/jungfrauDetectorServer_virtual b/serverBin/jungfrauDetectorServer_virtual
new file mode 120000
index 000000000..cbb38b3d6
--- /dev/null
+++ b/serverBin/jungfrauDetectorServer_virtual
@@ -0,0 +1 @@
+../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_virtual
\ No newline at end of file
diff --git a/serverBin/jungfrauDetectorServerv3.1.0.2 b/serverBin/jungfrauDetectorServerv3.1.0.2
new file mode 120000
index 000000000..e5ad646f3
--- /dev/null
+++ b/serverBin/jungfrauDetectorServerv3.1.0.2
@@ -0,0 +1 @@
+../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.1.0.2
\ No newline at end of file
diff --git a/serverBin/moenchDetectorServerv2.0.3 b/serverBin/moenchDetectorServerv2.0.3
deleted file mode 120000
index 0e78f92a3..000000000
--- a/serverBin/moenchDetectorServerv2.0.3
+++ /dev/null
@@ -1 +0,0 @@
-../slsDetectorSoftware/moenchDetectorServer/moenchDetectorServerv2.0.3
\ No newline at end of file
diff --git a/settingsdir/gotthard/dynamicgain/settings.sn b/settingsdir/gotthard/dynamicgain/settings.sn
index 324a9774c..12aef34b2 100755
--- a/settingsdir/gotthard/dynamicgain/settings.sn
+++ b/settingsdir/gotthard/dynamicgain/settings.sn
@@ -4,5 +4,5 @@ VcascP 1480
Vout 1520
Vcasc 1320
Vin 1350
-Vref_comp 887
+Vref_comp 350
Vib_test 2001
diff --git a/settingsdir/gotthard/highgain/settings.sn b/settingsdir/gotthard/highgain/settings.sn
index 324a9774c..12aef34b2 100644
--- a/settingsdir/gotthard/highgain/settings.sn
+++ b/settingsdir/gotthard/highgain/settings.sn
@@ -4,5 +4,5 @@ VcascP 1480
Vout 1520
Vcasc 1320
Vin 1350
-Vref_comp 887
+Vref_comp 350
Vib_test 2001
diff --git a/settingsdir/gotthard/lowgain/settings.sn b/settingsdir/gotthard/lowgain/settings.sn
index 324a9774c..12aef34b2 100644
--- a/settingsdir/gotthard/lowgain/settings.sn
+++ b/settingsdir/gotthard/lowgain/settings.sn
@@ -4,5 +4,5 @@ VcascP 1480
Vout 1520
Vcasc 1320
Vin 1350
-Vref_comp 887
+Vref_comp 350
Vib_test 2001
diff --git a/settingsdir/gotthard/mediumgain/settings.sn b/settingsdir/gotthard/mediumgain/settings.sn
index 324a9774c..12aef34b2 100644
--- a/settingsdir/gotthard/mediumgain/settings.sn
+++ b/settingsdir/gotthard/mediumgain/settings.sn
@@ -4,5 +4,5 @@ VcascP 1480
Vout 1520
Vcasc 1320
Vin 1350
-Vref_comp 887
+Vref_comp 350
Vib_test 2001
diff --git a/settingsdir/gotthard/veryhighgain/settings.sn b/settingsdir/gotthard/veryhighgain/settings.sn
index 324a9774c..12aef34b2 100644
--- a/settingsdir/gotthard/veryhighgain/settings.sn
+++ b/settingsdir/gotthard/veryhighgain/settings.sn
@@ -4,5 +4,5 @@ VcascP 1480
Vout 1520
Vcasc 1320
Vin 1350
-Vref_comp 887
+Vref_comp 350
Vib_test 2001
diff --git a/slsDetectorGui/CMakeLists.txt b/slsDetectorGui/CMakeLists.txt
index 0178b9536..55c68ca60 100644
--- a/slsDetectorGui/CMakeLists.txt
+++ b/slsDetectorGui/CMakeLists.txt
@@ -119,6 +119,11 @@ target_link_libraries(slsDetectorGui
pthread
zmq
rt
+ png
+ z
+ Qt4::QtOpenGL
+ Qt4::QtSvg
+
)
add_executable(gui_client
@@ -128,3 +133,6 @@ add_executable(gui_client
set_target_properties(gui_client PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
+
+install(TARGETS slsDetectorGui gui_client
+ RUNTIME DESTINATION bin)
diff --git a/slsDetectorGui/gitInfo.txt b/slsDetectorGui/gitInfo.txt
index 1eeaeed15..4ded3c165 100644
--- a/slsDetectorGui/gitInfo.txt
+++ b/slsDetectorGui/gitInfo.txt
@@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorGui
-URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
-Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
-Repsitory UUID: c4a242e10a4aafd102cc9a2a7ddae4ac92b8ba99
-Revision: 439
-Branch: 3.0.1
-Last Changed Author: Dhanya_Maliakal
-Last Changed Rev: 3187
-Last Changed Date: 2017-12-06 08:45:14.000000002 +0100 ./src/qTabSettings.cpp
+URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
+Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
+Repsitory UUID: b58c3e8951625ed9124669404f6b68aca340a1b8
+Revision: 491
+Branch: developer
+Last Changed Author: Dhanya_Thattil
+Last Changed Rev: 3727
+Last Changed Date: 2018-03-14 15:24:03.000000002 +0100 ./src/qTabMeasurement.cpp
diff --git a/slsDetectorGui/include/gitInfoGui.h b/slsDetectorGui/include/gitInfoGui.h
index 61d748cf1..997240797 100644
--- a/slsDetectorGui/include/gitInfoGui.h
+++ b/slsDetectorGui/include/gitInfoGui.h
@@ -1,6 +1,6 @@
-#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git"
-#define GITREPUUID "c4a242e10a4aafd102cc9a2a7ddae4ac92b8ba99"
-#define GITAUTH "Dhanya_Maliakal"
-#define GITREV 0x3187
-#define GITDATE 0x20171206
-#define GITBRANCH "3.0.1"
+#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
+#define GITREPUUID "b58c3e8951625ed9124669404f6b68aca340a1b8"
+#define GITAUTH "Dhanya_Thattil"
+#define GITREV 0x3727
+#define GITDATE 0x20180314
+#define GITBRANCH "developer"
diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp
index c9661348c..83be041bf 100644
--- a/slsDetectorGui/src/qDetectorMain.cpp
+++ b/slsDetectorGui/src/qDetectorMain.cpp
@@ -111,7 +111,7 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, int& ret,
+ "Usage: " + string(argv[0]) + " [arguments]\n"
+ "Possible arguments are:\n"
+ "\t-d, --developer : Enables the developer tab\n"
- + "\t-f, --f, --config : Loads config from file\n"
+ + "\t-f, --config : Loads config from file\n"
+ "\t-i, --id : Sets the multi detector id to i. Default: 0. Required \n"
+ "\t only when more than one multi detector object is needed.\n\n";
cout << help_message << endl;
@@ -306,11 +306,8 @@ void qDetectorMain::SetUpDetector(const string fName){
cout << endl << "Type : " << slsDetectorBase::getDetectorType(detType) << "\nDetector : " << host << endl;
//#endif
myDet->setOnline(slsDetectorDefs::ONLINE_FLAG);
- if(detType != slsDetectorDefs::MYTHEN) {
- if(myDet->setReceiverOnline(slsDetectorDefs::GET_ONLINE_FLAG) == slsDetectorDefs::ONLINE_FLAG) {
- myDet->setReceiverOnline(slsDetectorDefs::ONLINE_FLAG);
- }else cprintf(RED,"is not online!\n");
- }
+ if(detType != slsDetectorDefs::MYTHEN)
+ myDet->setReceiverOnline(slsDetectorDefs::ONLINE_FLAG);
qDefs::checkErrorMessage(myDet,"qDetectorMain::SetUpDetector");
}
diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp
index 0280c03b8..f5226957b 100644
--- a/slsDetectorGui/src/qTabAdvanced.cpp
+++ b/slsDetectorGui/src/qTabAdvanced.cpp
@@ -377,7 +377,7 @@ void qTabAdvanced::SetOutputFile(){
//gets the clean absolute path
dirPath = dir.absoluteFilePath(dirPath);
dirPath = dir.cleanPath(dirPath);
- QString trimdir = QString(myDet->getSettingsFile()).section('/',0,-2,QString::SectionIncludeLeadingSep);
+ QString trimdir = QString::fromStdString(myDet->getSettingsFile()).section('/',0,-2,QString::SectionIncludeLeadingSep);
trimdir = dir.absoluteFilePath(trimdir);
trimdir = dir.cleanPath(trimdir);
if(!dirPath.compare(trimdir)){
diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp
index eb81cf40c..1f38edb5e 100644
--- a/slsDetectorGui/src/qTabDataOutput.cpp
+++ b/slsDetectorGui/src/qTabDataOutput.cpp
@@ -535,8 +535,10 @@ void qTabDataOutput::GetOutputDir(){
dispOutputDir->setText(QString(myDet->getFilePath().c_str()));
//multi file path blank means sls file paths are different
if (dispOutputDir->text().isEmpty()) {
+#ifdef VERYVERBOSE
qDefs::Message(qDefs::INFORMATION,"The file path for individual units are different.\n"
"Hence, leaving the common field blank.","qTabDataOutput::GetOutputDir");
+#endif
#ifdef VERBOSE
cout << "The file path for individual units are different.\n"
"Hence, leaving the common field blank." << endl;
diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp
index de5ea2065..b6e28ce0e 100644
--- a/slsDetectorGui/src/qTabMeasurement.cpp
+++ b/slsDetectorGui/src/qTabMeasurement.cpp
@@ -843,28 +843,14 @@ void qTabMeasurement::Refresh(){
cout << "Getting delay after trigger, number of triggers and number of gates" << endl;
#endif
//delay
- //delay
- if (detType == slsDetectorDefs::EIGER) {
- lblDelay->setEnabled(false);
- spinDelay->setEnabled(false);
- comboDelayUnit->setEnabled(false);
- } else {
- lblDelay->setEnabled(true);
- spinDelay->setEnabled(true);
- comboDelayUnit->setEnabled(true);
- time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9))));
- spinDelay->setValue(time);
- comboDelayUnit->setCurrentIndex((int)unit);
- }
+ if (detType != slsDetectorDefs::EIGER)
+ time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9))));
+
//gates
- if ((detType == slsDetectorDefs::EIGER) || (detType == slsDetectorDefs::JUNGFRAU) || (detType == slsDetectorDefs::JUNGFRAUCTB)) {
- lblNumGates->setEnabled(false);
- spinNumGates->setEnabled(false);
- } else {
- lblNumGates->setEnabled(true);
- spinNumGates->setEnabled(true);
- spinNumGates->setValue((int)myDet->setTimer(slsDetectorDefs::GATES_NUMBER,-1));
- }
+ if ((detType != slsDetectorDefs::EIGER) && (detType != slsDetectorDefs::JUNGFRAU) && (detType != slsDetectorDefs::JUNGFRAUCTB) )
+ spinNumGates->setValue((int)myDet->setTimer(slsDetectorDefs::GATES_NUMBER,-1));
+
+
//Number of Triggers
spinNumTriggers->setValue((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1));
diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt
index 69f395cc9..6513b012d 100644
--- a/slsDetectorSoftware/CMakeLists.txt
+++ b/slsDetectorSoftware/CMakeLists.txt
@@ -58,11 +58,37 @@ add_library(slsDetectorShared SHARED
${SOURCES}
${HEADERS}
)
+
+set(PUBLICHEADERS
+ commonFiles/sls_detector_defs.h
+ commonFiles/sls_detector_funcs.h
+ commonFiles/error_defs.h
+ slsDetector/slsDetectorUtils.h
+ slsDetector/slsDetector.h
+ slsDetector/slsDetectorActions.h
+ slsDetector/slsDetectorBase.h
+ slsDetector/slsDetectorUsers.h
+ slsDetectorAnalysis/postProcessing.h
+ slsDetectorAnalysis/detectorData.h
+ slsDetectorAnalysis/angularConversion.h
+ slsDetectorAnalysis/angularConversionStatic.h
+ slsDetectorAnalysis/angleConversionConstant.h
+ slsDetectorAnalysis/badChannelCorrections.h
+ slsDetectorAnalysis/energyConversion.h
+ slsDetectorAnalysis/fileIO.h
+ slsDetectorAnalysis/fileIOStatic.h
+ multiSlsDetector/multiSlsDetector.h
+ slsReceiverInterface/receiverInterface.h
+
+)
set_target_properties(slsDetectorShared PROPERTIES
LIBRARY_OUTPUT_NAME SlsDetector
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+ PUBLIC_HEADER "${PUBLICHEADERS}"
)
+
+
add_subdirectory(slsDetectorClient)
if(DOXYGEN_FOUND)
@@ -74,3 +100,7 @@ if(DOXYGEN_FOUND)
)
endif()
+install(TARGETS slsDetectorShared slsDetectorStatic
+ LIBRARY DESTINATION lib
+ PUBLIC_HEADER DESTINATION include
+ ARCHIVE DESTINATION lib)
diff --git a/slsDetectorSoftware/commonFiles/communication_funcs.c b/slsDetectorSoftware/commonFiles/communication_funcs.c
index 1d30887dc..487b2c66e 100755
--- a/slsDetectorSoftware/commonFiles/communication_funcs.c
+++ b/slsDetectorSoftware/commonFiles/communication_funcs.c
@@ -316,6 +316,8 @@ int receiveData(int file_des, void* buf,int length, intType itype){
int sendDataOnly(int file_des, void* buf,int length) {
+ if (!length)
+ return 0;
int ret = write(file_des, buf, length); //value of -1 is other end socket crash as sigpipe is ignored
if (ret < 0) cprintf(BG_RED, "Error writing to socket. Possible socket crash\n");
return ret;
@@ -415,19 +417,14 @@ int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) {
ts+=sendData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32);
ts+=sendData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32);
ts+=sendData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32);
- ts+=sendData(file_des,myMod->dacs,sizeof(myMod->ndac),OTHER);
- if(sendAll){
- ts+=sendData(file_des,myMod->adcs,sizeof(myMod->nadc),OTHER);
- }else{
- uint32_t k = 0;
- ts+=sendData(file_des,&k,sizeof(k),OTHER);
- }
- /*some detectors dont require sending all trimbits etc.*/
- if(sendAll){
- ts+=sendData(file_des,myMod->chipregs,sizeof(myMod->nchip),OTHER);
- ts+=sendData(file_des,myMod->chanregs,sizeof(myMod->nchan),OTHER);
+#ifdef MYTHEND
+ ts+=sendData(file_des,myMod->dacs,sizeof(myMod->ndac),OTHER);
+ ts+=sendData(file_des,myMod->adcs,sizeof(myMod->nadc),OTHER);
+ ts+=sendData(file_des,myMod->chipregs,sizeof(myMod->nchip),OTHER);
+ ts+=sendData(file_des,myMod->chanregs,sizeof(myMod->nchan),OTHER);
}
+#endif
ts+=sendData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER);
ts+=sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER);
@@ -437,16 +434,11 @@ int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) {
ts+= sendData(file_des,myMod->dacs,sizeof(dacs_t)*nDacs,INT32);
#ifdef VERBOSE
printf("dacs %d of size %d sent\n",myMod->module, ts);
+ int idac;
for (idac=0; idac< nDacs; idac++)
printf("dac %d is %d\n",idac,(int)myMod->dacs[idac]);
#endif
- if(sendAll)
- ts+= sendData(file_des,myMod->adcs,sizeof(dacs_t)*nAdcs,INT32);
- else {
- uint32_t k = 0;
- ts+= sendData(file_des,&k,sizeof(k),INT32);
- }
-
+ ts+= sendData(file_des,myMod->adcs,sizeof(dacs_t)*nAdcs,INT32);
#ifdef VERBOSE
printf("adcs %d of size %d sent\n",myMod->module, ts);
#endif
@@ -547,18 +539,12 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA
ts+=receiveData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32);
ts+=receiveData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32);
ts+=receiveData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32);
+#ifdef MYTHEND
ts+=receiveData(file_des,myMod->dacs,sizeof(myMod->ndac),INT32);
- if(receiveAll){ // temporary fix
- ts+=receiveData(file_des,myMod->adcs,sizeof(myMod->nadc),INT32);
- }else {
- uint32_t k;ts+=receiveData(file_des,&k,sizeof(k),INT32);//nadc is 0
- }
-
- /*some detectors dont require sending all trimbits etc.*/
- if(receiveAll){
- ts+=receiveData(file_des,myMod->chipregs,sizeof(myMod->nchip),INT32);
- ts+=receiveData(file_des,myMod->chanregs,sizeof(myMod->nchan),INT32);
- }
+ ts+=receiveData(file_des,myMod->adcs,sizeof(myMod->nadc),INT32);
+ ts+=receiveData(file_des,myMod->chipregs,sizeof(myMod->nchip),INT32);
+ ts+=receiveData(file_des,myMod->chanregs,sizeof(myMod->nchan),INT32);
+#endif
ts+=receiveData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER);
ts+=receiveData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER);
diff --git a/slsDetectorSoftware/commonFiles/error_defs.h b/slsDetectorSoftware/commonFiles/error_defs.h
index 98d3a8fc3..01a73ae7d 100644
--- a/slsDetectorSoftware/commonFiles/error_defs.h
+++ b/slsDetectorSoftware/commonFiles/error_defs.h
@@ -50,9 +50,9 @@ using namespace std;
#define PREPARE_ACQUISITION 0x0000100000000000ULL
#define CLEANUP_ACQUISITION 0x0000080000000000ULL
#define REGISER_WRITE_READ 0x0000040000000000ULL
-// 0xFFFFFFF000000000ULL
+// 0xFFFFFF0000000000ULL
-// 0x0000000FFFFFFFFFULL
+// 0x000000FFFFFFFFFFULL
#define COULDNOT_SET_NETWORK_PARAMETER 0x0000000000000001ULL
#define COULDNOT_SET_ROI 0x0000000000000002ULL
#define RECEIVER_READ_FREQUENCY 0x0000000000000004ULL
@@ -89,7 +89,10 @@ using namespace std;
#define RECEIVER_TIMER_NOT_SET 0x0000000200000000ULL
#define RECEIVER_ENABLE_GAPPIXELS_NOT_SET 0x0000000400000000ULL
#define RESTREAM_STOP_FROM_RECEIVER 0x0000000800000000ULL
-// 0x0000000FFFFFFFFFULL
+#define TEMPERATURE_CONTROL 0x0000001000000000ULL
+#define AUTO_COMP_DISABLE 0x0000002000000000ULL
+// 0x000000FFFFFFFFFFULL
+
/** @short class returning all error messages for error mask */
class errorDefs {
@@ -280,7 +283,11 @@ public:
if(slsErrorMask&RESTREAM_STOP_FROM_RECEIVER)
retval.append("Could not restream stop from receiver.\n");
+ if(slsErrorMask&TEMPERATURE_CONTROL)
+ retval.append("Could not set/get threshold temperature, temp control or temp event.\n");
+ if(slsErrorMask&AUTO_COMP_DISABLE)
+ retval.append("Could not set/get auto comparator disable\n");
//------------------------------------------------------ length of message
diff --git a/slsDetectorSoftware/commonFiles/sls_detector_defs.h b/slsDetectorSoftware/commonFiles/sls_detector_defs.h
index b0d960f62..1d8d993bb 100755
--- a/slsDetectorSoftware/commonFiles/sls_detector_defs.h
+++ b/slsDetectorSoftware/commonFiles/sls_detector_defs.h
@@ -371,6 +371,18 @@ enum dacIndex {
TEMPERATURE_SODR, /**< temperature sensor (close to SODR) */
TEMPERATURE_FPGA2, /**< temperature sensor (fpga2 (eiger:febl) */
TEMPERATURE_FPGA3, /**< temperature sensor (fpga3 (eiger:febr) */
+ M_vIpre, /**< mythen 3 >*/
+ M_vIbias, /**< mythen 3 >*/
+ M_vIinSh, /**< mythen 3 >*/
+ M_VdcSh, /**< mythen 3 >*/
+ M_Vth2, /**< mythen 3 >*/
+ M_VPL, /**< mythen 3 >*/
+ M_Vth3, /**< mythen 3 >*/
+ M_casSh, /**< mythen 3 >*/
+ M_cas, /**< mythen 3 >*/
+ M_vIbiasSh, /**< mythen 3 >*/
+ M_vIcin, /**< mythen 3 >*/
+ M_vIpreOut, /**< mythen 3 >*/
V_POWER_A = 100, /**new chiptest board */
V_POWER_B = 101, /**new chiptest board */
V_POWER_C = 102, /**new chiptest board */
diff --git a/slsDetectorSoftware/commonFiles/sls_detector_funcs.h b/slsDetectorSoftware/commonFiles/sls_detector_funcs.h
index 12ddb896f..c4d2f5c5a 100644
--- a/slsDetectorSoftware/commonFiles/sls_detector_funcs.h
+++ b/slsDetectorSoftware/commonFiles/sls_detector_funcs.h
@@ -112,6 +112,12 @@ enum detFuncs{
F_ACTIVATE, /** < activate */
F_PREPARE_ACQUISITION, /** < prepare acquisition */
F_CLEANUP_ACQUISITION, /** < clean up after acquisition */
+
+ F_THRESHOLD_TEMP, /** < set threshold temperature */
+ F_TEMP_CONTROL, /** < set temperature control */
+ F_TEMP_EVENT, /** < set temperature event */
+
+ F_AUTO_COMP_DISABLE, /** < auto comp disable mode */
/* Always append functions hereafter!!! */
/* Always append functions before!!! */
diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.1.0.21.0 b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_developer
similarity index 52%
rename from slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.1.0.21.0
rename to slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_developer
index 14a1b6b5e..5e0f545e2 100755
Binary files a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.1.0.21.0 and b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_developer differ
diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualMaster b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualMaster
index 934f86b70..0167b8fd3 100755
Binary files a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualMaster and b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualMaster differ
diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualSlave b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualSlave
index b92f53b65..2a735216d 100755
Binary files a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualSlave and b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualSlave differ
diff --git a/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt b/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt
index 1d3358f1c..bfe91ab6f 100644
--- a/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt
+++ b/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt
@@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
-URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
-Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
-Repsitory UUID: 2f3dc8d109de8607f3217cf429619073dc9cc60e
-Revision: 315
+URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
+Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
+Repsitory UUID: 06cdf8ad9204fd306cb1017b91e67452c61715d4
+Revision: 323
Branch: developer
-Last Changed Author: Dhanya_Maliakal
-Last Changed Rev: 3397
-Last Changed Date: 2017-12-06 19:05:42.000000002 +0100 ./FebRegisterDefs.h
+Last Changed Author: Erik_Frojdh
+Last Changed Rev: 3671
+Last Changed Date: 2018-03-13 10:28:12.000000002 +0100 ./FebRegisterDefs.h
diff --git a/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h b/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h
index 1f135dd30..00181c6cb 100644
--- a/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h
+++ b/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h
@@ -1,6 +1,6 @@
-#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git"
-#define GITREPUUID "2f3dc8d109de8607f3217cf429619073dc9cc60e"
-#define GITAUTH "Dhanya_Maliakal"
-#define GITREV 0x3397
-#define GITDATE 0x20171206
+#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
+#define GITREPUUID "06cdf8ad9204fd306cb1017b91e67452c61715d4"
+#define GITAUTH "Erik_Frojdh"
+#define GITREV 0x3671
+#define GITDATE 0x20180313
#define GITBRANCH "developer"
diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c
index 898c13a85..83caa23c9 100644
--- a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c
@@ -136,10 +136,7 @@ int64_t getDetectorId(enum idMode arg){
case SOFTWARE_FIRMWARE_API_VERSION:
return (int64_t)Beb_GetFirmwareSoftwareAPIVersion();
case DETECTOR_SOFTWARE_VERSION:
- retval= GITREV;
- retval= (retval <<32) | GITDATE;
- //cprintf(BLUE,"git date:%x, git rev:%x\n",GITDATE,GITREV);
- break;
+ return (GITDATE & 0xFFFFFF);
default:
break;
}
@@ -834,23 +831,6 @@ enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){
/* configure mac */
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival) {
- if (sourcemac != getDetectorMAC()){
- printf("*************************************************\n");
- printf("WARNING: actual detector mac address %llx does not match the one from client %llx\n",getDetectorMAC(),sourcemac);
- sourcemac = getDetectorMAC();
- printf("WARNING: Matched detectormac to the hardware mac now\n");
- printf("*************************************************\n");
- }
- //only for 1Gbe
- if(!send_to_ten_gig){
- if (sourceip != getDetectorIP()){
- printf("*************************************************\n");
- printf("WARNING: actual detector ip address %x does not match the one from client %x\n",getDetectorIP(),sourceip);
- sourceip = getDetectorIP();
- printf("WARNING: Matched detector ip to the hardware ip now\n");
- printf("*************************************************\n");
- }
- }
char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50];
int src_port = 0xE185;
diff --git a/slsDetectorSoftware/gitInfo.txt b/slsDetectorSoftware/gitInfo.txt
index 82b2afd33..e94fe0436 100644
--- a/slsDetectorSoftware/gitInfo.txt
+++ b/slsDetectorSoftware/gitInfo.txt
@@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware
-URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
-Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
-Repsitory UUID: c4a242e10a4aafd102cc9a2a7ddae4ac92b8ba99
-Revision: 1629
-Branch: 3.0.1
-Last Changed Author: Dhanya_Maliakal
-Last Changed Rev: 3187
-Last Changed Date: 2017-12-06 19:00:50.000000002 +0100 ./threadFiles/ThreadPool.o
+URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
+Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
+Repsitory UUID: b58c3e8951625ed9124669404f6b68aca340a1b8
+Revision: 1842
+Branch: developer
+Last Changed Author: Dhanya_Thattil
+Last Changed Rev: 3727
+Last Changed Date: 2018-03-14 16:10:22.000000002 +0100 ./multiSlsDetector/multiSlsDetector.cpp
diff --git a/slsDetectorSoftware/gotthardDetectorServer/Makefile.virtual b/slsDetectorSoftware/gotthardDetectorServer/Makefile.virtual
index 4f563e2a0..d36e90b8e 100755
--- a/slsDetectorSoftware/gotthardDetectorServer/Makefile.virtual
+++ b/slsDetectorSoftware/gotthardDetectorServer/Makefile.virtual
@@ -5,7 +5,7 @@ CC = gcc
CFLAGS += -Wall -DGOTTHARDD -DMCB_FUNCS -DDACS_INT -DDEBUG -DVIRTUAL
-PROGS= $(DESTDIR)/gotthardVirtualServer
+PROGS= $(DESTDIR)/gotthardDetectorServer_virtual
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
diff --git a/slsDetectorSoftware/gotthardDetectorServer/config.txt b/slsDetectorSoftware/gotthardDetectorServer/config.txt
index a3e58af5b..721434a75 100644
--- a/slsDetectorSoftware/gotthardDetectorServer/config.txt
+++ b/slsDetectorSoftware/gotthardDetectorServer/config.txt
@@ -17,4 +17,7 @@ slavepatternphase 0
slaveadcphase 0
#rst to sw1 delay
-rsttosw1delay 2
\ No newline at end of file
+rsttosw1delay 2
+
+#start acquisition delay
+startacqdelay 1
\ No newline at end of file
diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c
index c6ed49d63..52a25b8bd 100755
--- a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c
+++ b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c
@@ -4,8 +4,6 @@
#include "mcb_funcs.h"
#include "registers_g.h"
-#include "AD9257.h" // include "commonServerFunctions.h"
-
#ifdef SHAREDMEMORY
#include "sharedmemory.h"
#endif
@@ -15,7 +13,7 @@
#include
#include
-
+#include
//for memory mapping
@@ -53,7 +51,7 @@ int ififostart, ififostop, ififostep, ififo;
int masterMode=NO_MASTER, syncMode=NO_SYNCHRONIZATION, timingMode=AUTO_TIMING;
-enum externalSignalFlag signals[4]={EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF};
+enum externalSignalFlag signalMode=EXT_SIG_OFF;
//for the 25um detectors
@@ -64,6 +62,7 @@ int adcphase = 0;
int slavepatternphase = 0;
int slaveadcphase = 0;
int rsttosw1delay = 2;
+int startacqdelay = 1;
#ifdef MCB_FUNCS
@@ -295,6 +294,8 @@ void setMasterSlaveConfiguration(){
slaveadcphase = ival;
else if (!strcasecmp(key,"rsttosw1delay"))
rsttosw1delay = ival;
+ else if (!strcasecmp(key,"startacqdelay"))
+ startacqdelay = ival;
else {
cprintf(RED,"could not scan parameter name %s from config file\n",key);
exit(EXIT_FAILURE);
@@ -309,13 +310,15 @@ void setMasterSlaveConfiguration(){
"slavepatternphase:%d\n"
"slaveadcphase:%d\n"
"rsttosw1delay:%d\n",
+ "startacqdelay:%d\n",
masterflags,
masterdefaultdelay,
patternphase,
adcphase,
slavepatternphase,
slaveadcphase,
- rsttosw1delay);
+ rsttosw1delay,
+ startacqdelay);
@@ -343,16 +346,24 @@ void setMasterSlaveConfiguration(){
val = (val & (~(PLL_CLK_SEL_MSK))) | PLL_CLK_SEL_SLAVE_ADC_VAL;
bus_w(MULTI_PURPOSE_REG,val);
setPhaseShift(slaveadcphase);
+ /* Set start acq delay */
+ val=bus_r(MULTI_PURPOSE_REG);
+#ifdef VERBOSE
+ printf("Multipurpose reg:0x%x\n",bus_r(MULTI_PURPOSE_REG));
+#endif
+ val = (val & (~(START_ACQ_DELAY_MSK))) | ((startacqdelay << START_ACQ_DELAY_OFFSET) & (START_ACQ_DELAY_MSK));
+ bus_w(MULTI_PURPOSE_REG,val);
+ printf("Start acq delay set. Multipurpose reg: 0x%x\n",bus_r(MULTI_PURPOSE_REG));
}
/* Set RST to SW1 delay */
val=bus_r(MULTI_PURPOSE_REG);
- //#ifdef VERBOSE
- printf("Value of multipurpose reg:%d\n",bus_r(MULTI_PURPOSE_REG));
- //#endif
+#ifdef VERBOSE
+ printf("Multipurpose reg:0x%x\n",bus_r(MULTI_PURPOSE_REG));
+#endif
val = (val & (~(RST_TO_SW1_DELAY_MSK))) | ((rsttosw1delay << RST_TO_SW1_DELAY_OFFSET) & (RST_TO_SW1_DELAY_MSK));
bus_w(MULTI_PURPOSE_REG,val);
-
+ printf("RST to SW1 delay set. Multipurpose reg:0x%x\n",bus_r(MULTI_PURPOSE_REG));
fclose(fd);
}
@@ -544,259 +555,109 @@ u_int32_t getTotDutyCycle() {
}
-u_int32_t setExtSignal(int d, enum externalSignalFlag mode) {
+u_int32_t setExtSignal(enum externalSignalFlag mode) {
- //int modes[]={EXT_SIG_OFF, EXT_GATE_IN_ACTIVEHIGH, EXT_GATE_IN_ACTIVELOW,EXT_TRIG_IN_RISING,EXT_TRIG_IN_FALLING,EXT_RO_TRIG_IN_RISING, EXT_RO_TRIG_IN_FALLING,EXT_GATE_OUT_ACTIVEHIGH, EXT_GATE_OUT_ACTIVELOW, EXT_TRIG_OUT_RISING, EXT_TRIG_OUT_FALLING, EXT_RO_TRIG_OUT_RISING, EXT_RO_TRIG_OUT_FALLING};
- // int off=d*SIGNAL_OFFSET;
+ u_int32_t c;
+ c = bus_r(EXT_SIGNAL_REG);
- u_int32_t c;
- c=bus_r(EXT_SIGNAL_REG);
-
- if (d>=0 && d<4) {
- signals[d]=mode;
#ifdef VERBOSE
- printf("settings signal variable number %d to value %04x\n", d, signals[d]);
+ printf("settings signal variable number %d to value %04x\n", d, signals[d]);
#endif
- // if output signal, set it!
+ switch (mode) {
+ case TRIGGER_IN_RISING_EDGE:
+ case TRIGGER_IN_FALLING_EDGE:
- switch (mode) {
- case GATE_IN_ACTIVE_HIGH:
- case GATE_IN_ACTIVE_LOW:
- if (timingMode==GATE_FIX_NUMBER || timingMode==GATE_WITH_START_TRIGGER)
- setFPGASignal(d,mode);
- else
- setFPGASignal(d,SIGNAL_OFF);
- break;
- case TRIGGER_IN_RISING_EDGE:
- case TRIGGER_IN_FALLING_EDGE:
- if (timingMode==TRIGGER_EXPOSURE || timingMode==GATE_WITH_START_TRIGGER)
- setFPGASignal(d,mode);
- else
- setFPGASignal(d,SIGNAL_OFF);
- break;
- case RO_TRIGGER_IN_RISING_EDGE:
- case RO_TRIGGER_IN_FALLING_EDGE:
- if (timingMode==TRIGGER_READOUT)
- setFPGASignal(d,mode);
- else
- setFPGASignal(d,SIGNAL_OFF);
- break;
- case MASTER_SLAVE_SYNCHRONIZATION:
- setSynchronization(syncMode);
- break;
- default:
- setFPGASignal(d,mode);
- break;
- }
+ // set variable
+ signalMode = mode;
- setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
- }
+ // set signal only if trigger mode
+ if (timingMode==TRIGGER_EXPOSURE)
+ setFPGASignal(mode);
+ // switch off if not trigger mode, but variable remembers value
+ else
+ setFPGASignal(SIGNAL_OFF);
+ break;
+
+ default:
+ mode = SIGNAL_OFF;
+ signalMode = mode;
+ setFPGASignal(mode);
+ break;
+ }
+
+ return getExtSignal();
+}
-// if (mode<=RO_TRIGGER_OUT_FALLING_EDGE && mode>=0)
-// bus_w(EXT_SIGNAL_REG,((modes[mode])<=0) {
-#ifdef VERBOSE
- printf("writing signal register number %d mode %04x\n",d, modes[mode]);
+ // check and then update variable
+ if ((mode == SIGNAL_OFF) || (mode == TRIGGER_IN_RISING_EDGE) || (mode == TRIGGER_IN_FALLING_EDGE)) {
+ #ifdef VERYVERBOSE
+ printf("gettings signal register number %d value %04x\n", d, (int)mode);
#endif
- bus_w(EXT_SIGNAL_REG,((modes[mode])<>off);
-
- if (mode=0 && d<4) {
-#ifdef VERBOSE
- printf("gettings signal variable number %d value %04x\n", d, signals[d]);
-#endif
- return signals[d];
- } else
- return -1;
-
-
-}
-
-
-int getFPGASignal(int d) {
-
- int modes[]={SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW,TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE,RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE,RO_TRIGGER_OUT_FALLING_EDGE};
-
- int off=d*SIGNAL_OFFSET;
- int mode=((bus_r(EXT_SIGNAL_REG)&(SIGNAL_MASK<>off);
-
- if (mode<=RO_TRIGGER_OUT_FALLING_EDGE) {
- if (modes[mode]!=SIGNAL_OFF && signals[d]!=MASTER_SLAVE_SYNCHRONIZATION)
- signals[d]=modes[mode];
-#ifdef VERYVERBOSE
- printf("gettings signal register number %d value %04x\n", d, modes[mode]);
-#endif
- return modes[mode];
+ return (int)mode;
} else
- return -1;
-
+ return -1;
}
-/*
-enum externalCommunicationMode{
- GET_EXTERNAL_COMMUNICATION_MODE,
- AUTO,
- TRIGGER_EXPOSURE_SERIES,
- TRIGGER_EXPOSURE_BURST,
- TRIGGER_READOUT,
- TRIGGER_COINCIDENCE_WITH_INTERNAL_ENABLE,
- GATE_FIX_NUMBER,
- GATE_FIX_DURATION,
- GATE_WITH_START_TRIGGER,
- GATE_COINCIDENCE_WITH_INTERNAL_ENABLE
-};
-*/
-
-
int setTiming(int ti) {
+ // set
+ if (ti != GET_EXTERNAL_COMMUNICATION_MODE) {
- int ret=GET_EXTERNAL_COMMUNICATION_MODE;
+ // trigger
+ if (ti == TRIGGER_EXPOSURE) {
+ timingMode = ti;
+ if ((signalMode == TRIGGER_IN_RISING_EDGE) || (signalMode == TRIGGER_IN_FALLING_EDGE))
+ setFPGASignal(signalMode);
+ else
+ setFPGASignal(SIGNAL_OFF); // only if both (timing & extsig) configured, its set to trigger, else off
+ }
- int g=-1, t=-1, rot=-1;
-
- int i;
-
- switch (ti) {
- case AUTO_TIMING:
- timingMode=ti;
- // disable all gates/triggers in except if used for master/slave synchronization
- for (i=0; i<4; i++) {
- if (getFPGASignal(i)>0 && getFPGASignal(i)=0 && t>=0 && rot<0) {
- ret=GATE_WITH_START_TRIGGER;
- } else if (g<0 && t>=0 && rot<0) {
- ret=TRIGGER_EXPOSURE;
- } else if (g>=0 && t<0 && rot<0) {
- ret=GATE_FIX_NUMBER;
- } else if (g<0 && t<0 && rot>0) {
- ret=TRIGGER_READOUT;
- } else if (g<0 && t<0 && rot<0) {
- ret=AUTO_TIMING;
- }
-
- // timingMode=ret;
-
- return ret;
+ // get
+ int s = getFPGASignal();
+ if ((s == TRIGGER_IN_RISING_EDGE) || (s == TRIGGER_IN_FALLING_EDGE))
+ return TRIGGER_EXPOSURE;
+ return AUTO_TIMING;
}
@@ -1158,13 +1019,13 @@ int64_t getActualTime(){
int64_t getMeasurementTime(){
int64_t v=get64BitReg(GET_MEASUREMENT_TIME_LSB_REG, GET_MEASUREMENT_TIME_MSB_REG);
- u_int64_t mask=0x8000000000000000;
+ /* u_int64_t mask=0x8000000000000000;
if (v & mask ) {
#ifdef VERBOSE
printf("no measurement time left\n");
#endif
return -1E+9;
- } else
+ } else*/
return v/(1E-9*CLK_FREQ);
}
@@ -1613,6 +1474,7 @@ int configureMAC(int ipad,long long int macad,long long int detectormacad, int d
#endif
// if(val!=0x2820) return -1;
+ usleep(1000 * 1000);
return adcConfigured;
}
@@ -1675,12 +1537,8 @@ int startStateMachine(){
int stopStateMachine(){
//#ifdef VERBOSE
- printf("*******Stopping State Machine*******\n");
+ cprintf(BG_RED,"*******Stopping State Machine*******\n");
//#endif
-#ifdef SHAREDMEMORY
- write_stop_sm(1);
- write_status_sm("Stopped");
-#endif
bus_w16(CONTROL_REG, STOP_ACQ_BIT);
bus_w16(CONTROL_REG, 0x0);
usleep(500);
@@ -2139,239 +1997,13 @@ int clearRAM() {
int setMaster(int f) {
-
- int i;
- switch(f) {
- case NO_MASTER:
- // switch of gates or triggers
- masterMode=NO_MASTER;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- setFPGASignal(i,SIGNAL_OFF);
- }
- }
- break;
- case IS_MASTER:
- // configure gate or trigger out
- masterMode=IS_MASTER;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- switch (syncMode) {
- case NO_SYNCHRONIZATION:
- setFPGASignal(i,SIGNAL_OFF);
- break;
- case MASTER_GATES:
- setFPGASignal(i,GATE_OUT_ACTIVE_HIGH);
- break;
- case MASTER_TRIGGERS:
- setFPGASignal(i,TRIGGER_OUT_RISING_EDGE);
- break;
- case SLAVE_STARTS_WHEN_MASTER_STOPS:
- setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE);
- break;
- default:
- ;
- }
- }
- }
- break;
- case IS_SLAVE:
- // configure gate or trigger in
- masterMode=IS_SLAVE;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- switch (syncMode) {
- case NO_SYNCHRONIZATION:
- setFPGASignal(i,SIGNAL_OFF);
- break;
- case MASTER_GATES:
- setFPGASignal(i,GATE_IN_ACTIVE_HIGH);
- break;
- case MASTER_TRIGGERS:
- setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
- break;
- case SLAVE_STARTS_WHEN_MASTER_STOPS:
- setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
- break;
- default:
- ;
- }
- }
- }
- break;
- default:
- //do nothing
- break;
- }
-
- switch(masterMode) {
- case NO_MASTER:
- return NO_MASTER;
-
-
- case IS_MASTER:
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- switch (syncMode) {
- case NO_SYNCHRONIZATION:
- return IS_MASTER;
- case MASTER_GATES:
- if (getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH)
- return IS_MASTER;
- else
- return NO_MASTER;
- case MASTER_TRIGGERS:
- if (getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE)
- return IS_MASTER;
- else
- return NO_MASTER;
- case SLAVE_STARTS_WHEN_MASTER_STOPS:
- if (getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE)
- return IS_MASTER;
- else
- return NO_MASTER;
- default:
- return NO_MASTER;
- }
-
- }
- }
- break;
-
- case IS_SLAVE:
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- switch (syncMode) {
- case NO_SYNCHRONIZATION:
- return IS_SLAVE;
- case MASTER_GATES:
- if (getFPGASignal(i)==GATE_IN_ACTIVE_HIGH)
- return IS_SLAVE;
- else
- return NO_MASTER;
- case MASTER_TRIGGERS:
- case SLAVE_STARTS_WHEN_MASTER_STOPS:
- if (getFPGASignal(i)==TRIGGER_IN_RISING_EDGE)
- return IS_SLAVE;
- else
- return NO_MASTER;
- default:
- return NO_MASTER;
- }
- }
- }
- break;
- }
- return masterMode;
+ return NO_MASTER;
}
int setSynchronization(int s) {
-
- int i;
-
- switch(s) {
- case NO_SYNCHRONIZATION:
- syncMode=NO_SYNCHRONIZATION;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- setFPGASignal(i,SIGNAL_OFF);
- }
- }
- break;
- // disable external signals?
- case MASTER_GATES:
- // configure gate in or out
- syncMode=MASTER_GATES;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- if (masterMode==IS_MASTER)
- setFPGASignal(i,GATE_OUT_ACTIVE_HIGH);
- else if (masterMode==IS_SLAVE)
- setFPGASignal(i,GATE_IN_ACTIVE_HIGH);
- }
- }
-
- break;
- case MASTER_TRIGGERS:
- // configure trigger in or out
- syncMode=MASTER_TRIGGERS;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- if (masterMode==IS_MASTER)
- setFPGASignal(i,TRIGGER_OUT_RISING_EDGE);
- else if (masterMode==IS_SLAVE)
- setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
- }
- }
- break;
-
-
- case SLAVE_STARTS_WHEN_MASTER_STOPS:
- // configure trigger in or out
- syncMode=SLAVE_STARTS_WHEN_MASTER_STOPS;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- if (masterMode==IS_MASTER)
- setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE);
- else if (masterMode==IS_SLAVE)
- setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
- }
- }
- break;
-
-
- default:
- //do nothing
- break;
- }
-
- switch (syncMode) {
-
- case NO_SYNCHRONIZATION:
- return NO_SYNCHRONIZATION;
-
- case MASTER_GATES:
-
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- if (masterMode==IS_MASTER && getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH)
- return MASTER_GATES;
- else if (masterMode==IS_SLAVE && getFPGASignal(i)==GATE_IN_ACTIVE_HIGH)
- return MASTER_GATES;
- }
- }
- return NO_SYNCHRONIZATION;
-
- case MASTER_TRIGGERS:
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- if (masterMode==IS_MASTER && getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE)
- return MASTER_TRIGGERS;
- else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE)
- return MASTER_TRIGGERS;
- }
- }
- return NO_SYNCHRONIZATION;
-
- case SLAVE_STARTS_WHEN_MASTER_STOPS:
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- if (masterMode==IS_MASTER && getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE)
- return SLAVE_STARTS_WHEN_MASTER_STOPS;
- else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE)
- return SLAVE_STARTS_WHEN_MASTER_STOPS;
- }
- }
- return NO_SYNCHRONIZATION;
-
- default:
- return NO_SYNCHRONIZATION;
-
- }
- return NO_SYNCHRONIZATION;
-
+ return NO_SYNCHRONIZATION;
}
diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h
index 3149a3546..50b143c70 100755
--- a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h
+++ b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h
@@ -47,11 +47,11 @@ u_int32_t getTotClockDivider();
u_int32_t setTotDutyCycle(int d);
u_int32_t getTotDutyCycle();
-u_int32_t setExtSignal(int d, enum externalSignalFlag mode);
-int getExtSignal(int d);
+u_int32_t setExtSignal(enum externalSignalFlag mode);
+int getExtSignal();
-u_int32_t setFPGASignal(int d, enum externalSignalFlag mode);
-int getFPGASignal(int d);
+u_int32_t setFPGASignal(enum externalSignalFlag mode);
+int getFPGASignal();
int setTiming(int t);
diff --git a/slsDetectorSoftware/gotthardDetectorServer/gitInfo.txt b/slsDetectorSoftware/gotthardDetectorServer/gitInfo.txt
index ee5115894..68b17f2ed 100644
--- a/slsDetectorSoftware/gotthardDetectorServer/gitInfo.txt
+++ b/slsDetectorSoftware/gotthardDetectorServer/gitInfo.txt
@@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/gotthardDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
-Repsitory UUID: 0649626842512b772ab660c36dece505f3244aee
-Revision: 212
-Branch: 3.0.1
-Last Changed Author: Dhanya_Maliakal
-Last Changed Rev: 3318
-Last Changed Date: 2017-12-19 17:45:11.000000002 +0100 ./server_funcs.c
+Repsitory UUID: 675d69392a6497d42b23057c7c8783c8dad768d0
+Revision: 223
+Branch: 3.1.0-rc
+Last Changed Author: Dhanya_Thattil
+Last Changed Rev: 3447
+Last Changed Date: 2018-02-27 14:04:08.000000002 +0100 ./server_funcs.c
diff --git a/slsDetectorSoftware/gotthardDetectorServer/gitInfoGotthard.h b/slsDetectorSoftware/gotthardDetectorServer/gitInfoGotthard.h
index 25844d8df..6c3fb814c 100644
--- a/slsDetectorSoftware/gotthardDetectorServer/gitInfoGotthard.h
+++ b/slsDetectorSoftware/gotthardDetectorServer/gitInfoGotthard.h
@@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
-#define GITREPUUID "0649626842512b772ab660c36dece505f3244aee"
-#define GITAUTH "Dhanya_Maliakal"
-#define GITREV 0x3318
-#define GITDATE 0x20171219
-#define GITBRANCH "3.0.1"
+#define GITREPUUID "675d69392a6497d42b23057c7c8783c8dad768d0"
+#define GITAUTH "Dhanya_Thattil"
+#define GITREV 0x3447
+#define GITDATE 0x20180227
+#define GITBRANCH "3.1.0-rc"
diff --git a/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_developer b/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_developer
new file mode 100755
index 000000000..916668eda
Binary files /dev/null and b/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_developer differ
diff --git a/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_virtual b/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_virtual
new file mode 100755
index 000000000..2dcd81447
Binary files /dev/null and b/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_virtual differ
diff --git a/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv3.0.0.7 b/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv3.0.0.7
deleted file mode 100755
index bc5c03120..000000000
Binary files a/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv3.0.0.7 and /dev/null differ
diff --git a/slsDetectorSoftware/gotthardDetectorServer/gotthardVirtualServer b/slsDetectorSoftware/gotthardDetectorServer/gotthardVirtualServer
deleted file mode 100755
index 00f509290..000000000
Binary files a/slsDetectorSoftware/gotthardDetectorServer/gotthardVirtualServer and /dev/null differ
diff --git a/slsDetectorSoftware/gotthardDetectorServer/registers_g.h b/slsDetectorSoftware/gotthardDetectorServer/registers_g.h
index ddb29bedf..bda9a7bbf 100755
--- a/slsDetectorSoftware/gotthardDetectorServer/registers_g.h
+++ b/slsDetectorSoftware/gotthardDetectorServer/registers_g.h
@@ -287,11 +287,12 @@
#define INT_RSTN_OFFSET 12
#define DIGITAL_TEST_BIT 0x00004000
#define DIGITAL_TEST_OFFSET 14
-//#define CHANGE_AT_POWER_ON_BIT 0x00008000
-//#define CHANGE_AT_POWER_ON_OFFSET 15
+//#define CHANGE_AT_POWER_ON_BIT 0x00008000
+//#define CHANGE_AT_POWER_ON_OFFSET 15
#define RST_TO_SW1_DELAY_MSK 0x000F0000
#define RST_TO_SW1_DELAY_OFFSET 16
-
+#define START_ACQ_DELAY_MSK 0x00F00000
+#define START_ACQ_DELAY_OFFSET 20
/* settings/conf gain register */
#define GAIN_MASK 0x000000ff
diff --git a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c
index b2fe9cec5..b3dee5d5d 100755
--- a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c
+++ b/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c
@@ -10,6 +10,7 @@
#include "trimming_funcs.h"
#include "registers_g.h"
#include "gitInfoGotthard.h"
+#include "AD9257.h" // include "commonServerFunctions.h"
#define FIFO_DATA_REG_OFF 0x50<<11
#define CONTROL_REG 0x24<<11
@@ -460,24 +461,21 @@ int set_external_signal_flag(int file_des) {
break;
default:
- if (differentClients==0 || lockStatus==0) {
- retval=setExtSignal(signalindex,flag);
- } else {
- if (lockStatus!=0) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n", lastClientIP);
- }
- }
-
+ if (lockStatus && differentClients) {
+ ret=FAIL;
+ sprintf(mess,"Detector locked by %s\n", lastClientIP);
+ } else if (signalindex > 0) {
+ ret=FAIL;
+ sprintf(mess,"Signal index %d is reserved. Only index 0 can be configured.\n", signalindex);
+ } else {
+ retval=setExtSignal(flag);
+ }
}
-
#ifdef VERBOSE
printf("Setting external signal %d to flag %d\n",signalindex,flag );
printf("Set to flag %d\n",retval);
#endif
- } else {
- ret=FAIL;
}
if (ret==OK && differentClients!=0)
@@ -581,19 +579,17 @@ int get_id(int file_des) {
#ifdef VERBOSE
printf("Getting id %d\n", arg);
-#endif
+#endif
switch (arg) {
case DETECTOR_SERIAL_NUMBER:
retval=getDetectorNumber();
break;
case DETECTOR_FIRMWARE_VERSION:
- retval=getFirmwareSVNVersion();
- retval=(retval <<32) | getFirmwareVersion();
+ retval = (getFirmwareVersion() & 0xFFFFFF);
break;
case DETECTOR_SOFTWARE_VERSION:
- retval= GITREV;
- retval= (retval <<32) | GITDATE;
+ retval = (GITDATE & 0xFFFFFF);
break;
default:
printf("Required unknown id %d \n", arg);
@@ -1731,12 +1727,10 @@ int stop_acquisition(int file_des) {
int ret=OK;
int n;
-
sprintf(mess,"can't stop acquisition\n");
-#ifdef VERBOSE
- printf("Stopping acquisition\n");
-#endif
+ cprintf(BG_RED,"Client command received to stop acquisition\n");
+
if (differentClients==1 && lockStatus==1) {
diff --git a/slsDetectorSoftware/jctbDetectorServer/gitInfo.txt b/slsDetectorSoftware/jctbDetectorServer/gitInfo.txt
index 89ecb57ba..b25adf0e5 100644
--- a/slsDetectorSoftware/jctbDetectorServer/gitInfo.txt
+++ b/slsDetectorSoftware/jctbDetectorServer/gitInfo.txt
@@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/jctbDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
-Repsitory UUID: 7602ffc5ac94c36e326a3bf939e85746e708c2ad
-Revision: 19
+Repsitory UUID: 3da6a6df6556312f7467407a8b5691bdc478424e
+Revision: 21
Branch: developer
-Last Changed Author: Anna_Bergamaschi
-Last Changed Rev: 3554
-Last Changed Date: 2017-12-15 10:38:26.000000002 +0100 ./firmware_funcs.c
+Last Changed Author: Dhanya_Thattil
+Last Changed Rev: 3597
+Last Changed Date: 2018-02-07 10:44:13.000000002 +0100 ./server_funcs.h
diff --git a/slsDetectorSoftware/jctbDetectorServer/gitInfoMoench.h b/slsDetectorSoftware/jctbDetectorServer/gitInfoMoench.h
index 5fdb541b6..826314e3a 100644
--- a/slsDetectorSoftware/jctbDetectorServer/gitInfoMoench.h
+++ b/slsDetectorSoftware/jctbDetectorServer/gitInfoMoench.h
@@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
-#define GITREPUUID "7602ffc5ac94c36e326a3bf939e85746e708c2ad"
-#define GITAUTH "Anna_Bergamaschi"
-#define GITREV 0x3554
-#define GITDATE 0x20171215
+#define GITREPUUID "3da6a6df6556312f7467407a8b5691bdc478424e"
+#define GITAUTH "Dhanya_Thattil"
+#define GITREV 0x3597
+#define GITDATE 0x20180207
#define GITBRANCH "developer"
diff --git a/slsDetectorSoftware/jctbDetectorServer/jctbDetectorServer b/slsDetectorSoftware/jctbDetectorServer/jctbDetectorServer
deleted file mode 100755
index 699af6a51..000000000
Binary files a/slsDetectorSoftware/jctbDetectorServer/jctbDetectorServer and /dev/null differ
diff --git a/slsDetectorSoftware/jctbDetectorServer/jctbDetectorServer_developer b/slsDetectorSoftware/jctbDetectorServer/jctbDetectorServer_developer
new file mode 100755
index 000000000..f0c79de23
Binary files /dev/null and b/slsDetectorSoftware/jctbDetectorServer/jctbDetectorServer_developer differ
diff --git a/slsDetectorSoftware/jungfrauDetectorServer/Makefile.virtual b/slsDetectorSoftware/jungfrauDetectorServer/Makefile.virtual
index 8ee348341..b3c6ce7f8 100644
--- a/slsDetectorSoftware/jungfrauDetectorServer/Makefile.virtual
+++ b/slsDetectorSoftware/jungfrauDetectorServer/Makefile.virtual
@@ -1,24 +1,26 @@
CC = gcc
-CFLAGS += -Wall -DJUNGFRAUD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
+CFLAGS += -Wall -DJUNGFRAUD -DVIRTUAL -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
LDLIBS += -lm -lstdc++
-PROGS = jungfrauDetectorServer
+PROGS = jungfrauDetectorServer_virtual
DESTDIR ?= bin
INSTMODE = 0777
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c
OBJS = $(SRC_CLNT:.c=.o)
-all: clean $(PROGS)
+all: clean versioning $(PROGS)
boot: $(OBJS)
+versioning:
+ @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;`
+
$(PROGS): $(OBJS)
- echo $(OBJS)
+# echo $(OBJS)
mkdir -p $(DESTDIR)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR)
- rm *.gdb
clean:
rm -rf $(DESTDIR)/$(PROGS) *.o
diff --git a/slsDetectorSoftware/jungfrauDetectorServer/RegisterDefs.h b/slsDetectorSoftware/jungfrauDetectorServer/RegisterDefs.h
index 45a9761dc..697f0eaf5 100644
--- a/slsDetectorSoftware/jungfrauDetectorServer/RegisterDefs.h
+++ b/slsDetectorSoftware/jungfrauDetectorServer/RegisterDefs.h
@@ -4,7 +4,7 @@
/* Definitions for FPGA*/
/* FPGA Version register */
-#define FPGA_VERSION_REG (0x00 << 11)
+#define FPGA_VERSION_REG (0x00 << MEM_MAP_SHIFT)
#define BOARD_REVISION_OFST (0)
#define BOARD_REVISION_MSK (0x00FFFFFF << BOARD_REVISION_OFST)
@@ -14,10 +14,10 @@
/* Fix pattern register */
-#define FIX_PATT_REG (0x01 << 11)
+#define FIX_PATT_REG (0x01 << MEM_MAP_SHIFT)
/* Status register */
-#define STATUS_REG (0x02 << 11)
+#define STATUS_REG (0x02 << MEM_MAP_SHIFT)
#define RUN_BUSY_OFST (0)
#define RUN_BUSY_MSK (0x00000001 << RUN_BUSY_OFST)
@@ -34,10 +34,10 @@
/* Look at me register */
-#define LOOK_AT_ME_REG (0x03 << 11) //Not used in firmware or software
+#define LOOK_AT_ME_REG (0x03 << MEM_MAP_SHIFT) //Not used in firmware or software
/* System Status register */
-#define SYSTEM_STATUS_REG (0x04 << 11) //Not used in software
+#define SYSTEM_STATUS_REG (0x04 << MEM_MAP_SHIFT) //Not used in software
#define DDR3_CAL_DONE_OFST (0) //Not used in software
#define DDR3_CAL_DONE_MSK (0x00000001 << DDR3_CAL_DONE_OFST) //Not used in software
@@ -54,7 +54,7 @@
/* Module Control Board Serial Number Register */
-#define MOD_SERIAL_NUM_REG (0x0A << 11) //Not used in software
+#define MOD_SERIAL_NUM_REG (0x0A << MEM_MAP_SHIFT) //Not used in software
#define HARDWARE_SERIAL_NUM_OFST (0) //Not used in software
#define HARDWARE_SERIAL_NUM_MSK (0x000000FF << HARDWARE_SERIAL_NUM_OFST) //Not used in software
@@ -62,28 +62,36 @@
#define HARDWARE_VERSION_NUM_MSK (0x0000003F << HARDWARE_VERSION_NUM_OFST) //Not used in software
+/* API Version Register */
+#define API_VERSION_REG (0x0F << MEM_MAP_SHIFT)
+
+#define API_VERSION_OFST (0)
+#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST)
+#define API_VERSION_DETECTOR_TYPE_OFST (24) //Not used in software
+#define API_VERSION_DETECTOR_TYPE_MSK (0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) //Not used in software
+
/* Time from Start 64 bit register */
-#define TIME_FROM_START_LSB_REG (0x10 << 11)
-#define TIME_FROM_START_MSB_REG (0x11 << 11)
+#define TIME_FROM_START_LSB_REG (0x10 << MEM_MAP_SHIFT)
+#define TIME_FROM_START_MSB_REG (0x11 << MEM_MAP_SHIFT)
/* Get Delay 64 bit register */
-#define GET_DELAY_LSB_REG (0x12 << 11)
-#define GET_DELAY_MSB_REG (0x13 << 11)
+#define GET_DELAY_LSB_REG (0x12 << MEM_MAP_SHIFT)
+#define GET_DELAY_MSB_REG (0x13 << MEM_MAP_SHIFT)
/* Get Cycles 64 bit register */
-#define GET_CYCLES_LSB_REG (0x14 << 11)
-#define GET_CYCLES_MSB_REG (0x15 << 11)
+#define GET_CYCLES_LSB_REG (0x14 << MEM_MAP_SHIFT)
+#define GET_CYCLES_MSB_REG (0x15 << MEM_MAP_SHIFT)
/* Get Frames 64 bit register */
-#define GET_FRAMES_LSB_REG (0x16 << 11)
-#define GET_FRAMES_MSB_REG (0x17 << 11)
+#define GET_FRAMES_LSB_REG (0x16 << MEM_MAP_SHIFT)
+#define GET_FRAMES_MSB_REG (0x17 << MEM_MAP_SHIFT)
/* Get Period 64 bit register */
-#define GET_PERIOD_LSB_REG (0x18 << 11)
-#define GET_PERIOD_MSB_REG (0x19 << 11)
+#define GET_PERIOD_LSB_REG (0x18 << MEM_MAP_SHIFT)
+#define GET_PERIOD_MSB_REG (0x19 << MEM_MAP_SHIFT)
/** Get Temperature Carlos, incorrectl as get gates */
-#define GET_TEMPERATURE_TMP112_REG (0x1c << 11) // (after multiplying by 625) in 10ths of millidegrees of TMP112
+#define GET_TEMPERATURE_TMP112_REG (0x1c << MEM_MAP_SHIFT) // (after multiplying by 625) in 10ths of millidegrees of TMP112
#define TEMPERATURE_POLARITY_BIT (15)
#define TEMPERATURE_POLARITY_MSK (0x00000001 << TEMPERATURE_POLARITY_BIT)
@@ -92,15 +100,15 @@
/* Get Frames from Start 64 bit register (frames from start Run Control) */
-#define FRAMES_FROM_START_PG_LSB_REG (0x24 << 11)
-#define FRAMES_FROM_START_PG_MSB_REG (0x25 << 11)
+#define FRAMES_FROM_START_PG_LSB_REG (0x24 << MEM_MAP_SHIFT)
+#define FRAMES_FROM_START_PG_MSB_REG (0x25 << MEM_MAP_SHIFT)
/* Measurement Time 64 bit register (timestamp at a frame start until reset)*/
-#define START_FRAME_TIME_LSB_REG (0x26 << 11)
-#define START_FRAME_TIME_MSB_REG (0x27 << 11)
+#define START_FRAME_TIME_LSB_REG (0x26 << MEM_MAP_SHIFT)
+#define START_FRAME_TIME_MSB_REG (0x27 << MEM_MAP_SHIFT)
/* SPI (Serial Peripheral Interface) Register */
-#define SPI_REG (0x40 << 11)
+#define SPI_REG (0x40 << MEM_MAP_SHIFT)
#define DAC_SERIAL_DIGITAL_OUT_OFST (0)
#define DAC_SERIAL_DIGITAL_OUT_MSK (0x00000001 << DAC_SERIAL_DIGITAL_OUT_OFST)
@@ -117,7 +125,7 @@
/* ADC SPI (Serial Peripheral Interface) Register */
-#define ADC_SPI_REG (0x41 << 11)
+#define ADC_SPI_REG (0x41 << MEM_MAP_SHIFT)
#define ADC_SERIAL_CLK_OUT_OFST (0)
#define ADC_SERIAL_CLK_OUT_MSK (0x00000001 << ADC_SERIAL_CLK_OUT_OFST)
@@ -127,16 +135,16 @@
#define ADC_SERIAL_CS_OUT_MSK (0x0000000F << ADC_SERIAL_CS_OUT_OFST)
/* ADC offset Register */
-#define ADC_OFST_REG (0x42 << 11)
+#define ADC_OFST_REG (0x42 << MEM_MAP_SHIFT)
/* ADC Port Invert Register */
-#define ADC_PORT_INVERT_REG (0x43 << 11)
+#define ADC_PORT_INVERT_REG (0x43 << MEM_MAP_SHIFT)
/* Receiver IP Address Register */
-#define RX_IP_REG (0x45 << 11)
+#define RX_IP_REG (0x45 << MEM_MAP_SHIFT)
/* UDP Port */
-#define UDP_PORT_REG (0x46 << 11)
+#define UDP_PORT_REG (0x46 << MEM_MAP_SHIFT)
#define UDP_PORT_RX_OFST (0)
#define UDP_PORT_RX_MSK (0x0000FFFF << UDP_PORT_RX_OFST)
@@ -144,8 +152,8 @@
#define UDP_PORT_TX_MSK (0x0000FFFF << UDP_PORT_TX_OFST)
/* Receiver Mac Address 64 bit Register */
-#define RX_MAC_LSB_REG (0x47 << 11)
-#define RX_MAC_MSB_REG (0x48 << 11)
+#define RX_MAC_LSB_REG (0x47 << MEM_MAP_SHIFT)
+#define RX_MAC_MSB_REG (0x48 << MEM_MAP_SHIFT)
#define RX_MAC_LSB_OFST (0)
#define RX_MAC_LSB_MSK (0xFFFFFFFF << RX_MAC_LSB_OFST)
@@ -153,8 +161,8 @@
#define RX_MAC_MSB_MSK (0x0000FFFF << RX_MAC_MSB_OFST)
/* Detector/ Transmitter Mac Address 64 bit Register */
-#define TX_MAC_LSB_REG (0x49 << 11)
-#define TX_MAC_MSB_REG (0x4A << 11)
+#define TX_MAC_LSB_REG (0x49 << MEM_MAP_SHIFT)
+#define TX_MAC_MSB_REG (0x4A << MEM_MAP_SHIFT)
#define TX_MAC_LSB_OFST (0)
#define TX_MAC_LSB_MSK (0xFFFFFFFF << TX_MAC_LSB_OFST)
@@ -162,16 +170,16 @@
#define TX_MAC_MSB_MSK (0x0000FFFF << TX_MAC_MSB_OFST)
/* Detector/ Transmitter IP Address Register */
-#define TX_IP_REG (0x4B << 11)
+#define TX_IP_REG (0x4B << MEM_MAP_SHIFT)
/* Detector/ Transmitter IP Checksum Register */
-#define TX_IP_CHECKSUM_REG (0x4C << 11)
+#define TX_IP_CHECKSUM_REG (0x4C << MEM_MAP_SHIFT)
#define TX_IP_CHECKSUM_OFST (0)
#define TX_IP_CHECKSUM_MSK (0x0000FFFF << TX_IP_CHECKSUM_OFST)
/* Configuration Register */
-#define CONFIG_REG (0x4D << 11)
+#define CONFIG_REG (0x4D << MEM_MAP_SHIFT)
#define CONFIG_OPERATION_MODE_OFST (16)
#define CONFIG_OPERATION_MODE_MSK (0x00000001 << CONFIG_OPERATION_MODE_OFST)
@@ -188,16 +196,16 @@
#define CONFIG_TDMA_ENABLE_VAL ((0x1 << CONFIG_TDMA_OFST) & CONFIG_TDMA_MSK)
#define CONFIG_TDMA_TIMESLOT_OFST (25)
#define CONFIG_TDMA_TIMESLOT_MSK (0x0000001F << CONFIG_TDMA_TIMESLOT_OFST)
-#define CONFIG_TDMA_TIMESLOT_0_VAL ((0x0 << CONFIG_TDMA_TIMESLOT_OFST) & CONFIG_TDMA_TIMESLOT_MSK)
+
/* External Signal Register */
-#define EXT_SIGNAL_REG (0x4E << 11)
+#define EXT_SIGNAL_REG (0x4E << MEM_MAP_SHIFT)
#define EXT_SIGNAL_OFST (0)
#define EXT_SIGNAL_MSK (0x00000003 << EXT_SIGNAL_OFST) //enabled when both bits high
/* Control Register */
-#define CONTROL_REG (0x4F << 11)
+#define CONTROL_REG (0x4F << MEM_MAP_SHIFT)
#define CONTROL_START_ACQ_OFST (0)
#define CONTROL_START_ACQ_MSK (0x00000001 << CONTROL_START_ACQ_OFST)
@@ -211,12 +219,14 @@
#define CONTROL_DDR3_MEM_RST_MSK (0x00000001 << CONTROL_DDR3_MEM_RST_OFST) //only PHY, not DDR3 PLL ,Not used in software
#define CONTROL_ACQ_FIFO_CLR_OFST (14)
#define CONTROL_ACQ_FIFO_CLR_MSK (0x00000001 << CONTROL_ACQ_FIFO_CLR_OFST)
+#define CONTROL_STORAGE_CELL_NUM_OFST (16)
+#define CONTROL_STORAGE_CELL_NUM_MSK (0x0000000F << CONTROL_STORAGE_CELL_NUM_OFST)
/* Reconfiguratble PLL Paramater Register */
-#define PLL_PARAM_REG (0x50 << 11)
+#define PLL_PARAM_REG (0x50 << MEM_MAP_SHIFT)
/* Reconfiguratble PLL Control Regiser */
-#define PLL_CONTROL_REG (0x51 << 11)
+#define PLL_CONTROL_REG (0x51 << MEM_MAP_SHIFT)
#define PLL_CTRL_RECONFIG_RST_OFST (0) //parameter reset
#define PLL_CTRL_RECONFIG_RST_MSK (0x00000001 << PLL_CTRL_RECONFIG_RST_OFST) //parameter reset
@@ -228,7 +238,7 @@
#define PLL_CTRL_ADDR_MSK (0x0000003F << PLL_CTRL_ADDR_OFST)
/* Sample Register (Obsolete) */
-#define SAMPLE_REG (0x59 << 11)
+#define SAMPLE_REG (0x59 << MEM_MAP_SHIFT)
#define SAMPLE_ADC_SAMPLE_SEL_OFST (0)
#define SAMPLE_ADC_SAMPLE_SEL_MSK (0x00000007 << SAMPLE_ADC_SAMPLE_SEL_OFST)
@@ -278,39 +288,64 @@
#define SAMPLE_DECMT_FACTOR_4_VAL ((0x2 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK)
/** Vref Comp Mod Register */
-#define VREF_COMP_MOD_REG (0x5C << 11) //Not used in software, TBD in firmware
+#define VREF_COMP_MOD_REG (0x5C << MEM_MAP_SHIFT)
+
+#define VREF_COMP_MOD_OFST (0)
+#define VREF_COMP_MOD_MSK (0x00000FFF << VREF_COMP_MOD_OFST)
+#define VREF_COMP_MOD_ENABLE_OFST (31)
+#define VREF_COMP_MOD_ENABLE_MSK (0x00000FFF << VREF_COMP_MOD_ENABLE_OFST)
+
/** DAQ Register */
-#define DAQ_REG (0x5D << 11) //TBD in firmware
+#define DAQ_REG (0x5D << MEM_MAP_SHIFT) //TBD in firmware
/** Chip Power Register */
-#define CHIP_POWER_REG (0x5E << 11)
+#define CHIP_POWER_REG (0x5E << MEM_MAP_SHIFT)
#define CHIP_POWER_ENABLE_OFST (0)
#define CHIP_POWER_ENABLE_MSK (0x00000001 << CHIP_POWER_ENABLE_OFST)
+#define CHIP_POWER_STATUS_OFST (1)
+#define CHIP_POWER_STATUS_MSK (0x00000001 << CHIP_POWER_STATUS_OFST)
+
+
+/** Temperature Control Register */
+#define TEMP_CTRL_REG (0x5F << MEM_MAP_SHIFT)
+
+#define TEMP_CTRL_PROTCT_THRSHLD_OFST (0)
+#define TEMP_CTRL_PROTCT_THRSHLD_MSK (0x000007FF << TEMP_CTRL_PROTCT_THRSHLD_OFST)
+#define TEMP_CTRL_PROTCT_ENABLE_OFST (16)
+#define TEMP_CTRL_PROTCT_ENABLE_MSK (0x00000001 << TEMP_CTRL_PROTCT_ENABLE_OFST)
+#define TEMP_CTRL_OVR_TMP_EVNT_OFST (31)
+#define TEMP_CTRL_OVR_TMP_EVNT_MSK (0x00000001 << TEMP_CTRL_OVR_TMP_EVNT_OFST)
+#define TEMP_CTRL_CLR_OVR_TMP_EVNT_VAL ((0x1 << TEMP_CTRL_OVR_TMP_EVNT_OFST) & TEMP_CTRL_OVR_TMP_EVNT_MSK)
+
/* Set Delay 64 bit register */
-#define SET_DELAY_LSB_REG (0x60 << 11)
-#define SET_DELAY_MSB_REG (0x61 << 11)
+#define SET_DELAY_LSB_REG (0x60 << MEM_MAP_SHIFT)
+#define SET_DELAY_MSB_REG (0x61 << MEM_MAP_SHIFT)
/* Set Cycles 64 bit register */
-#define SET_CYCLES_LSB_REG (0x62 << 11)
-#define SET_CYCLES_MSB_REG (0x63 << 11)
+#define SET_CYCLES_LSB_REG (0x62 << MEM_MAP_SHIFT)
+#define SET_CYCLES_MSB_REG (0x63 << MEM_MAP_SHIFT)
/* Set Frames 64 bit register */
-#define SET_FRAMES_LSB_REG (0x64 << 11)
-#define SET_FRAMES_MSB_REG (0x65 << 11)
+#define SET_FRAMES_LSB_REG (0x64 << MEM_MAP_SHIFT)
+#define SET_FRAMES_MSB_REG (0x65 << MEM_MAP_SHIFT)
/* Set Period 64 bit register */
-#define SET_PERIOD_LSB_REG (0x66 << 11)
-#define SET_PERIOD_MSB_REG (0x67 << 11)
+#define SET_PERIOD_LSB_REG (0x66 << MEM_MAP_SHIFT)
+#define SET_PERIOD_MSB_REG (0x67 << MEM_MAP_SHIFT)
/* Set Period 64 bit register */
-#define SET_EXPTIME_LSB_REG (0x68 << 11)
-#define SET_EXPTIME_MSB_REG (0x69 << 11)
+#define SET_EXPTIME_LSB_REG (0x68 << MEM_MAP_SHIFT)
+#define SET_EXPTIME_MSB_REG (0x69 << MEM_MAP_SHIFT)
+
+/* Trigger Delay 32 bit register */
+#define SET_TRIGGER_DELAY_LSB_REG (0x70 << MEM_MAP_SHIFT)
+#define SET_TRIGGER_DELAY_MSB_REG (0x71 << MEM_MAP_SHIFT)
/* Module Coordinates Register 0 */
-#define COORD_0 (0x7C << 11)
+#define COORD_0 (0x7C << MEM_MAP_SHIFT)
#define COORD_0_Y_OFST (0)
#define COORD_0_Y_MSK (0x0000FFFF << COORD_0_Y_OFST)
@@ -318,11 +353,19 @@
#define COORD_0_X_MSK (0x0000FFFF << COORD_0_X_OFST)
/* Module Coordinates Register 1 */
-#define COORD_1 (0x7D << 11)
+#define COORD_1 (0x7D << MEM_MAP_SHIFT)
#define COORD_0_Z_OFST (0)
#define COORD_0_Z_MSK (0x0000FFFF << COORD_0_Z_OFST)
+/* ASIC Control Register */
+#define ASIC_CTRL_REG (0x7F)
+
+#define ASIC_CTRL_PRCHRG_TMR_OFST (0)
+#define ASIC_CTRL_PRCHRG_TMR_MSK (0x000000FF << ASIC_CTRL_PRCHRG_TMR_OFST)
+#define ASIC_CTRL_DS_TMR_OFST (8)
+#define ASIC_CTRL_DS_TMR_MSK (0x000000FF << ASIC_CTRL_DS_TMR_OFST)
+
#endif //REGISTERS_G_H
diff --git a/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer
new file mode 100755
index 000000000..7fed40ec4
Binary files /dev/null and b/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ
diff --git a/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_virtual b/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_virtual
new file mode 100755
index 000000000..cd39898fa
Binary files /dev/null and b/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_virtual differ
diff --git a/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.12 b/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.12
deleted file mode 100755
index 4664a3ecc..000000000
Binary files a/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.12 and /dev/null differ
diff --git a/slsDetectorSoftware/jungfrauDetectorServer/gitInfo.txt b/slsDetectorSoftware/jungfrauDetectorServer/gitInfo.txt
index 4df512cd8..2cffea544 100644
--- a/slsDetectorSoftware/jungfrauDetectorServer/gitInfo.txt
+++ b/slsDetectorSoftware/jungfrauDetectorServer/gitInfo.txt
@@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer
-URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
-Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
-Repsitory UUID: 2f3dc8d109de8607f3217cf429619073dc9cc60e
-Revision: 103
+URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
+Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
+Repsitory UUID: 06cdf8ad9204fd306cb1017b91e67452c61715d4
+Revision: 122
Branch: developer
-Last Changed Author: Dhanya_Maliakal
-Last Changed Rev: 3397
-Last Changed Date: 2017-12-04 18:23:05.000000002 +0100 ./RegisterDefs.h
+Last Changed Author: Erik_Frojdh
+Last Changed Rev: 3671
+Last Changed Date: 2018-03-13 10:29:31.000000002 +0100 ./Makefile.virtual
diff --git a/slsDetectorSoftware/jungfrauDetectorServer/gitInfoJungfrau.h b/slsDetectorSoftware/jungfrauDetectorServer/gitInfoJungfrau.h
index 1acd1f071..00181c6cb 100644
--- a/slsDetectorSoftware/jungfrauDetectorServer/gitInfoJungfrau.h
+++ b/slsDetectorSoftware/jungfrauDetectorServer/gitInfoJungfrau.h
@@ -1,6 +1,6 @@
-#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git"
-#define GITREPUUID "2f3dc8d109de8607f3217cf429619073dc9cc60e"
-#define GITAUTH "Dhanya_Maliakal"
-#define GITREV 0x3397
-#define GITDATE 0x20171204
+#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
+#define GITREPUUID "06cdf8ad9204fd306cb1017b91e67452c61715d4"
+#define GITAUTH "Erik_Frojdh"
+#define GITREV 0x3671
+#define GITDATE 0x20180313
#define GITBRANCH "developer"
diff --git a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c
index 826d02055..b8d0f2f07 100644
--- a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c
@@ -26,15 +26,26 @@ int32_t clkPhase[2] = {0, 0};
/* basic tests */
void checkFirmwareCompatibility(int flag) {
+#ifdef VIRTUAL
+ cprintf(BLUE,"\n\n"
+ "********************************************************\n"
+ "************** Jungfrau Virtual Server *****************\n"
+ "********************************************************\n\n");
+ if (mapCSP0() == FAIL) {
+ cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
+ exit(EXIT_FAILURE);
+ }
+ return;
+#endif
defineGPIOpins();
resetFPGA();
- if (mapCSP0() == FAIL) {
- cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
- exit(EXIT_FAILURE);
- }
+ if (mapCSP0() == FAIL) {
+ cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
+ exit(EXIT_FAILURE);
+ }
- // does check only if flag is 0 (by default), set by command line
+ // does check only if flag is 0 (by default), set by command line
if ((!flag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
exit(EXIT_FAILURE);
@@ -46,7 +57,9 @@ void checkFirmwareCompatibility(int flag) {
uint64_t macadd = getDetectorMAC();
int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION);
- //int64_t sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION);
+ int64_t sw_fw_apiversion = 0;
+ if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
+ sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION);
cprintf(BLUE,"\n\n"
"********************************************************\n"
"****************** Jungfrau Server *********************\n"
@@ -55,50 +68,56 @@ void checkFirmwareCompatibility(int flag) {
"Hardware Serial Nr:\t\t 0x%x\n"
"Detector IP Addr:\t\t 0x%x\n"
- "Detector MAC Addr:\t\t 0x%llx\n"
+ "Detector MAC Addr:\t\t 0x%llx\n\n"
"Firmware Version:\t\t 0x%llx\n"
"Software Version:\t\t 0x%llx\n"
- //"F/w-S/w API Version:\t\t 0x%llx\n"
- //"Required Firmware Version:\t 0x%x\n"
+ "F/w-S/w API Version:\t\t 0x%llx\n"
+ "Required Firmware Version:\t 0x%x\n"
"\n"
"********************************************************\n",
hversion, hsnumber,
ipadd, macadd,
- fwversion, swversion
- //, sw_fw_apiversion, REQUIRED_FIRMWARE_VERSION
+ fwversion, swversion,
+ sw_fw_apiversion, REQRD_FRMWR_VRSN
);
+ // return if flag is not zero, debug mode
+ if (flag)
+ return;
+
-/*
- * printf("Testing firmware capability... ");
//cant read versions
+ printf("Testing Firmware-software compatibility ...\n");
if(!fwversion || !sw_fw_apiversion){
cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n");
cprintf(RED,"Exiting Server. Goodbye!\n\n");
- exit(-1);
+ exit(EXIT_FAILURE);
}
//check for API compatibility - old server
- if(sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION){
+ if(sw_fw_apiversion > REQRD_FRMWR_VRSN){
cprintf(RED,"FATAL ERROR: This software version is incompatible.\n"
"Please update it to be compatible with this firmware\n\n");
cprintf(RED,"Exiting Server. Goodbye!\n\n");
- exit(-1);
+ exit(EXIT_FAILURE);
}
//check for firmware compatibility - old firmware
- if( REQUIRED_FIRMWARE_VERSION > fwversion){
+ if( REQRD_FRMWR_VRSN > fwversion){
cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n"
- "Please update it to v%d to be compatible with this server\n\n", REQUIRED_FIRMWARE_VERSION);
+ "Please update it to v%d to be compatible with this server\n\n", REQRD_FRMWR_VRSN);
cprintf(RED,"Exiting Server. Goodbye!\n\n");
- exit(-1);
+ exit(EXIT_FAILURE);
}
-*/
+ printf("Compatibility - success\n");
}
int checkType() {
+#ifdef VIRTUAL
+ return OK;
+#endif
volatile u_int32_t type = ((bus_r(FPGA_VERSION_REG) & DETECTOR_TYPE_MSK) >> DETECTOR_TYPE_OFST);
if (type != JUNGFRAU){
cprintf(BG_RED,"This is not a Jungfrau Server (read %d, expected %d)\n",type, JUNGFRAU);
@@ -111,6 +130,9 @@ int checkType() {
u_int32_t testFpga(void) {
+#ifdef VIRTUAL
+ return OK;
+#endif
printf("\nTesting FPGA...\n");
//fixed pattern
@@ -127,6 +149,9 @@ u_int32_t testFpga(void) {
int testBus() {
+#ifdef VIRTUAL
+ return OK;
+#endif
printf("\nTesting Bus...\n");
int ret = OK;
@@ -153,6 +178,9 @@ int moduleTest( enum digitalTestMode arg, int imod){
}
int detectorTest( enum digitalTestMode arg){
+#ifdef VIRTUAL
+ return OK;
+#endif
switch(arg){
case DETECTOR_FIRMWARE_TEST: return testFpga();
case DETECTOR_BUS_TEST: return testBus();
@@ -176,41 +204,57 @@ int64_t getDetectorId(enum idMode arg){
switch(arg){
case DETECTOR_SERIAL_NUMBER:
- retval = getDetectorNumber();// or getDetectorMAC()
- break;
+ return getDetectorNumber();// or getDetectorMAC()
case DETECTOR_FIRMWARE_VERSION:
- retval = getFirmwareVersion();
- break;
- //case SOFTWARE_FIRMWARE_API_VERSION:
- //return GetFirmwareSoftwareAPIVersion();
+ return getFirmwareVersion();
+ case SOFTWARE_FIRMWARE_API_VERSION:
+ return getFirmwareAPIVersion();
case DETECTOR_SOFTWARE_VERSION:
- retval= GITREV;
- retval= (retval <<32) | GITDATE;
- break;
+ return (GITDATE & 0xFFFFFF);
default:
- break;
+ return retval;
}
-
- return retval;
}
u_int64_t getFirmwareVersion() {
+#ifdef VIRTUAL
+ return 0;
+#endif
return ((bus_r(FPGA_VERSION_REG) & BOARD_REVISION_MSK) >> BOARD_REVISION_OFST);
}
+u_int64_t getFirmwareAPIVersion() {
+#ifdef VIRTUAL
+ return 0;
+#endif
+ return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
+}
+
u_int16_t getHardwareVersionNumber() {
+#ifdef VIRTUAL
+ return 0;
+#endif
return ((bus_r(MOD_SERIAL_NUM_REG) & HARDWARE_VERSION_NUM_MSK) >> HARDWARE_VERSION_NUM_OFST);
}
u_int16_t getHardwareSerialNumber() {
+#ifdef VIRTUAL
+ return 0;
+#endif
return ((bus_r(MOD_SERIAL_NUM_REG) & HARDWARE_SERIAL_NUM_MSK) >> HARDWARE_SERIAL_NUM_OFST);
}
u_int32_t getDetectorNumber(){
+#ifdef VIRTUAL
+ return 0;
+#endif
return bus_r(MOD_SERIAL_NUM_REG);
}
u_int64_t getDetectorMAC() {
+#ifdef VIRTUAL
+ return 0;
+#endif
char output[255],mac[255]="";
u_int64_t res=0;
FILE* sysFile = popen("ifconfig eth0 | grep HWaddr | cut -d \" \" -f 11", "r");
@@ -228,6 +272,9 @@ u_int64_t getDetectorMAC() {
}
u_int32_t getDetectorIP(){
+#ifdef VIRTUAL
+ return 0;
+#endif
char temp[50]="";
u_int32_t res=0;
//execute and get address
@@ -260,7 +307,7 @@ u_int32_t getDetectorIP(){
/* initialization */
void initControlServer(){
- clkPhase[0] = 0; clkPhase[1] = 0;
+ clkPhase[0] = 0; clkPhase[1] = 0;
setupDetector();
printf("\n");
}
@@ -322,9 +369,9 @@ void setupDetector() {
resetCore();
resetPeripheral();
cleanFifos();
-
+#ifndef VIRTUAL
prepareADC();
-
+#endif
// initialize dac series
initDac(0); /* todo might work without */
initDac(8); //only for old board compatibility
@@ -341,8 +388,7 @@ void setupDetector() {
cprintf(RED, "Warning: Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval[0]);
}
}
-
- bus_w(DAQ_REG, 0x0); /* Only once at server startup */
+ bus_w(DAQ_REG, 0x0); /* Only once at server startup */
setSpeed(CLOCK_DIVIDER, HALF_SPEED);
cleanFifos(); /* todo might work without */
resetCore(); /* todo might work without */
@@ -359,6 +405,12 @@ void setupDetector() {
/*setSpeed(CLOCK_DIVIDER, HALF_SPEED); depends if all the previous stuff works*/
setTiming(DEFAULT_TIMING_MODE);
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
+
+ /* temporary set up until new firmware fixes bug */
+ // set temperature threshold
+ setThresholdTemperature(DEFAULT_TMP_THRSHLD);
+ // reset temp event
+ setTemperatureEvent(0);
}
@@ -380,22 +432,52 @@ int powerChip (int on){
bus_w(CHIP_POWER_REG, bus_r(CHIP_POWER_REG) & ~CHIP_POWER_ENABLE_MSK);
}
}
- return bus_r(CHIP_POWER_REG);
+
+ return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_ENABLE_MSK) >> CHIP_POWER_ENABLE_OFST);
+ /* temporary setup until new firmware fixes bug */
+ //return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_STATUS_MSK) >> CHIP_POWER_STATUS_OFST);
}
+
+
+int autoCompDisable(int on) {
+ if(on != -1){
+ if(on){
+ cprintf(BLUE, "\n*** Auto comp disable mode: enabling ***\n");
+ bus_w(VREF_COMP_MOD_REG, bus_r(VREF_COMP_MOD_REG) | VREF_COMP_MOD_ENABLE_MSK);
+ }
+ else{
+ cprintf(BLUE, "\n*** Auto comp disable mode: disabling *** \n");
+ bus_w(VREF_COMP_MOD_REG, bus_r(VREF_COMP_MOD_REG) & ~VREF_COMP_MOD_ENABLE_MSK);
+ }
+ }
+
+ return (bus_r(VREF_COMP_MOD_REG) & VREF_COMP_MOD_ENABLE_MSK);
+}
+
+
void cleanFifos() {
+#ifdef VIRTUAL
+ return;
+#endif
printf("\nClearing Acquisition Fifos\n");
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_ACQ_FIFO_CLR_MSK);
bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_ACQ_FIFO_CLR_MSK);
}
void resetCore() {
+#ifdef VIRTUAL
+ return;
+#endif
printf("\nResetting Core\n");
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_CORE_RST_MSK);
bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_CORE_RST_MSK);
}
void resetPeripheral() {
+#ifdef VIRTUAL
+ return;
+#endif
printf("\nResetting Peripheral\n");
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PERIPHERAL_RST_MSK);
bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_PERIPHERAL_RST_MSK);
@@ -405,9 +487,11 @@ int adcPhase(int st){ /**carlos needed clkphase 1 and 2? cehck with Aldo */
printf("Setting ADC Phase to %d\n",st);
if (st > 65535 || st < -65535)
return clkPhase[0];
- clkPhase[1] = st - clkPhase[0];
- printf(" phase %d\n", clkPhase[1] );
+ clkPhase[1] = st - clkPhase[0];
+ if (clkPhase[1] == 0)
+ return clkPhase[0];
+
configurePll();
clkPhase[0] = st;
return clkPhase[0];
@@ -455,33 +539,65 @@ int setSpeed(enum speedVariable arg, int val) {
// setting
if(val >= 0) {
- switch(val){
+ // stop state machine if running
+ if(runBusy())
+ stopStateMachine();
- // stop state machine if running
- if(runBusy())
- stopStateMachine();
+ uint32_t txndelay_msk = 0;
+
+ switch(val){
// todo in firmware, for now setting half speed
case FULL_SPEED://40
printf("\nSetting Half Speed (20 MHz):\n");
- printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED); bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED);
- printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED); bus_w(CONFIG_REG, CONFIG_HALF_SPEED);
- printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL);
- printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED); adcPhase(ADC_PHASE_HALF_SPEED);
+
+ printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED);
+ bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED);
+
+ txndelay_msk = (bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK); // read config tdma timeslot value
+ printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED | txndelay_msk);
+ bus_w(CONFIG_REG, CONFIG_HALF_SPEED | txndelay_msk);
+
+ printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL);
+ bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL);
+
+ printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED);
+ adcPhase(ADC_PHASE_HALF_SPEED);
+
break;
case HALF_SPEED:
printf("\nSetting Half Speed (20 MHz):\n");
- printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED); bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED);
- printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED); bus_w(CONFIG_REG, CONFIG_HALF_SPEED);
- printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL);
- printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED); adcPhase(ADC_PHASE_HALF_SPEED);
+
+ printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED);
+ bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED);
+
+ txndelay_msk = (bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK); // read config tdma timeslot value
+ printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED | txndelay_msk);
+ bus_w(CONFIG_REG, CONFIG_HALF_SPEED | txndelay_msk);
+
+ printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL);
+ bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL);
+
+ printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED);
+ adcPhase(ADC_PHASE_HALF_SPEED);
+
break;
case QUARTER_SPEED:
printf("\nSetting Half Speed (10 MHz):\n");
- printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_QUARTER_SPEED); bus_w(SAMPLE_REG, SAMPLE_ADC_QUARTER_SPEED);
- printf("Setting Config Reg to 0x%x\n", CONFIG_QUARTER_SPEED); bus_w(CONFIG_REG, CONFIG_QUARTER_SPEED);
- printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_QUARTER_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_QUARTER_SPEED_VAL);
- printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_QUARTER_SPEED); adcPhase(ADC_PHASE_QUARTER_SPEED);
+
+ printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_QUARTER_SPEED);
+ bus_w(SAMPLE_REG, SAMPLE_ADC_QUARTER_SPEED);
+
+ txndelay_msk = (bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK); // read config tdma timeslot value
+ printf("Setting Config Reg to 0x%x\n", CONFIG_QUARTER_SPEED | txndelay_msk);
+ bus_w(CONFIG_REG, CONFIG_QUARTER_SPEED | txndelay_msk);
+
+ printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_QUARTER_SPEED_VAL);
+ bus_w(ADC_OFST_REG, ADC_OFST_QUARTER_SPEED_VAL);
+
+ printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_QUARTER_SPEED);
+ adcPhase(ADC_PHASE_QUARTER_SPEED);
+
break;
}
printf("\n");
@@ -543,7 +659,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
printf("\nSetting delay to %lldns\n", (long long int)val);
val *= (1E-3 * CLK_SYNC);
}
- retval = set64BitReg(val, SET_DELAY_LSB_REG, SET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC);
+ retval = set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG) / (1E-3 * CLK_SYNC);
printf("Getting delay: %lldns\n", (long long int)retval);
break;
@@ -566,6 +682,9 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
int64_t getTimeLeft(enum timerIndex ind){
+#ifdef VIRTUAL
+ return 0;
+#endif
int64_t retval = -1;
switch(ind){
@@ -748,6 +867,9 @@ enum detectorSettings getSettings(){
void initDac(int dacnum) {
+#ifdef VIRTUAL
+ return;
+#endif
printf("\nInitializing dac for %d to \n",dacnum);
u_int32_t codata;
@@ -809,6 +931,9 @@ void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){
}
if ( (val >= 0) || (val == -100)) {
+#ifdef VIRTUAL
+ dacValues[ind] = dacval;
+#else
u_int32_t codata;
int csdx = ind / NDAC + DAC_SERIAL_CS_OUT_OFST; // old board (16 dacs),so can be DAC_SERIAL_CS_OUT_OFST or +1
int dacchannel = ind % NDAC; // 0-8, dac channel number (also for dacnum 9-15 in old board)
@@ -835,6 +960,12 @@ void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){
DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST);
dacValues[ind] = dacval;
+
+ if (ind == VREF_COMP) {
+ bus_w (VREF_COMP_MOD_REG, (bus_r(VREF_COMP_MOD_REG) &~ (VREF_COMP_MOD_MSK)) // reset
+ | ((val << VREF_COMP_MOD_OFST) & VREF_COMP_MOD_MSK)); // or it with value
+ }
+#endif
}
printf("Getting DAC %d : ",ind);
@@ -844,6 +975,9 @@ void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){
int getADC(enum ADCINDEX ind, int imod){
+#ifdef VIRTUAL
+ return 0;
+#endif
char tempnames[2][40]={"VRs/FPGAs Temperature", "ADCs/ASICs Temperature"};
printf("Getting Temperature for %s\n",tempnames[ind]);
u_int32_t addr = GET_TEMPERATURE_TMP112_REG;
@@ -869,6 +1003,11 @@ int getADC(enum ADCINDEX ind, int imod){
int setHighVoltage(int val){
+#ifdef VIRTUAL
+ if (val >= 0)
+ highvoltage = val;
+ return highvoltage;
+#endif
u_int32_t dacvalue;
float alpha = 0.55;
// setting hv
@@ -962,6 +1101,9 @@ long int calcChecksum(int sourceip, int destip) {
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival){
+#ifdef VIRTUAL
+ return 0;
+#endif
cprintf(BLUE, "\n*** Configuring MAC ***\n");
uint32_t sourceport = DEFAULT_TX_UDP_PORT;
@@ -1070,6 +1212,9 @@ int setDetectorPosition(int pos[]) {
void resetPLL() {
+#ifdef VIRTUAL
+ return;
+#endif
// reset PLL Reconfiguration and PLL
bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) | PLL_CTRL_RECONFIG_RST_MSK | PLL_CTRL_RST_MSK);
usleep(100);
@@ -1078,7 +1223,9 @@ void resetPLL() {
u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val) {
-
+#ifdef VIRTUAL
+ return val;
+#endif
// set parameter
bus_w(PLL_PARAM_REG, val);
@@ -1098,10 +1245,13 @@ u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val) {
void configurePll() {
+#ifdef VIRTUAL
+ return;
+#endif
u_int32_t val;
int32_t phase=0, inv=0;
- printf(" phase in %d\n", clkPhase[1]);
+ printf("Configuring PLL with phase in %d\n", clkPhase[1]);
if (clkPhase[1]>0) {
inv=0;
phase=clkPhase[1];
@@ -1129,10 +1279,96 @@ void configurePll() {
+int setThresholdTemperature(int val) {
+
+ if (val >= 0) {
+ printf("\nThreshold Temperature: %d\n", val);
+
+ val *= (10.0/625.0);
+#ifdef VERBOSE
+ printf("Converted Threshold Temperature: %d\n", val);
+#endif
+ bus_w(TEMP_CTRL_REG, (bus_r(TEMP_CTRL_REG) &~(TEMP_CTRL_PROTCT_THRSHLD_MSK) &~(TEMP_CTRL_OVR_TMP_EVNT_MSK))
+ | (((val << TEMP_CTRL_PROTCT_THRSHLD_OFST) & TEMP_CTRL_PROTCT_THRSHLD_MSK)));
+#ifdef VERBOSE
+ printf("Converted Threshold Temperature set to %d\n", ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_THRSHLD_MSK) >> TEMP_CTRL_PROTCT_THRSHLD_OFST));
+#endif
+ }
+ uint32_t temp = ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_THRSHLD_MSK) >> TEMP_CTRL_PROTCT_THRSHLD_OFST);
+
+ // conversion
+ temp *= (625.0/10.0);
+ printf("Threshold Temperature %f °C\n",(double)temp/1000.00);
+
+ return temp;
+
+}
+
+
+int setTemperatureControl(int val) {
+ if (val >= 0) {
+ // binary value
+ if (val > 0 ) val = 1;
+ printf("\nTemperature control: %d\n", val);
+ bus_w(TEMP_CTRL_REG, (bus_r(TEMP_CTRL_REG) &~(TEMP_CTRL_PROTCT_ENABLE_MSK) &~(TEMP_CTRL_OVR_TMP_EVNT_MSK))
+ | (((val << TEMP_CTRL_PROTCT_ENABLE_OFST) & TEMP_CTRL_PROTCT_ENABLE_MSK)));
+#ifdef VERBOSE
+ printf("Temperature control set to %d\n", ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_ENABLE_MSK) >> TEMP_CTRL_PROTCT_ENABLE_OFST));
+#endif
+ }
+ return ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_ENABLE_MSK) >> TEMP_CTRL_PROTCT_ENABLE_OFST);
+}
+
+
+int setTemperatureEvent(int val) {
+#ifdef VIRTUAL
+ return 0;
+#endif
+ if (val >= 0) {
+ // set bit to clear it
+ val = 1;
+ printf("\nTemperature Event: %d\n", val);
+ bus_w(TEMP_CTRL_REG, (bus_r(TEMP_CTRL_REG) &~TEMP_CTRL_OVR_TMP_EVNT_MSK)
+ | (((val << TEMP_CTRL_OVR_TMP_EVNT_OFST) & TEMP_CTRL_OVR_TMP_EVNT_MSK)));
+#ifdef VERBOSE
+ printf("Temperature Event set to %d\n", ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_OVR_TMP_EVNT_MSK) >> TEMP_CTRL_OVR_TMP_EVNT_OFST));
+#endif
+ }
+ return ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_OVR_TMP_EVNT_MSK) >> TEMP_CTRL_OVR_TMP_EVNT_OFST);
+}
+
+
+
+int setNetworkParameter(enum NETWORKINDEX mode, int value) {
+ if (mode != TXN_FRAME)
+ return -1;
+
+ if (value >= 0) {
+ printf("\nSetting transmission delay: %d\n", value);
+ bus_w(CONFIG_REG, (bus_r(CONFIG_REG) &~CONFIG_TDMA_TIMESLOT_MSK)
+ | (((value << CONFIG_TDMA_TIMESLOT_OFST) & CONFIG_TDMA_TIMESLOT_MSK)));
+ if (value == 0)
+ bus_w(CONFIG_REG, bus_r(CONFIG_REG) &~ CONFIG_TDMA_MSK);
+ else
+ bus_w(CONFIG_REG, bus_r(CONFIG_REG) | CONFIG_TDMA_MSK);
+#ifdef VERBOSE
+ printf("Transmission delay set to %d\n", ((bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK) >> CONFIG_TDMA_TIMESLOT_OFST));
+#endif
+ }
+
+ return ((bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK) >> CONFIG_TDMA_TIMESLOT_OFST);
+}
+
+
+
+
/* aquisition */
int startStateMachine(){
+#ifdef VIRTUAL
+ return OK;
+#endif
printf("*******Starting State Machine*******\n");
cleanFifos();
@@ -1147,6 +1383,9 @@ int startStateMachine(){
int stopStateMachine(){
+#ifdef VIRTUAL
+ return OK;
+#endif
cprintf(BG_RED,"*******Stopping State Machine*******\n");
//stop state machine
@@ -1163,6 +1402,9 @@ int stopStateMachine(){
enum runStatus getRunStatus(){
+#ifdef VIRTUAL
+ return IDLE;
+#endif
#ifdef VERBOSE
printf("Getting status\n");
#endif
@@ -1206,7 +1448,11 @@ enum runStatus getRunStatus(){
void readFrame(int *ret, char *mess){
-
+#ifdef VIRTUAL
+ *ret = (int)FAIL;
+ sprintf(mess,"virtual detector, no acquisition taken\n");
+ return;
+#endif
// wait for status to be done
while(runBusy()){
usleep(500);
@@ -1228,6 +1474,9 @@ void readFrame(int *ret, char *mess){
u_int32_t runBusy(void) {
+#ifdef VIRTUAL
+ return 0;
+#endif
u_int32_t s = ((bus_r(STATUS_REG) & RUN_BUSY_MSK) >> RUN_BUSY_OFST);
#ifdef VERBOSE
printf("Status Register: %08x\n", s);
diff --git a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_defs.h
index c54847911..e9657d6a4 100644
--- a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_defs.h
+++ b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_defs.h
@@ -8,7 +8,8 @@
#define GOODBYE (-200)
-//#define REQUIRED_FIRMWARE_VERSION 16
+#define MIN_REQRD_VRSN_T_RD_API 0x171220
+#define REQRD_FRMWR_VRSN 0x171220
/* Struct Definitions */
@@ -48,13 +49,14 @@ enum DACINDEX {VB_COMP, VDD_PROT, VIN_COM, VREF_PRECH, VB_PIXBUF, VB_DS, VREF
0x1f00, /* FORCESWITCHG1 */ \
0x3f00 /* FORCESWITCHG2 */ \
};
-#define DEFAULT_SETT_NAMES { "Dynamic Gain", /* DYNAMICGAIN */ \
+#define DEFAULT_SETT_NAMES { "Dynamic Gain", /* DYNAMICGAIN */ \
"Dynamic High Gain 0", /* DYNAMICHG0 */ \
"Fix Gain 1", /* FIXGAIN1 */ \
"Fix Gain 2", /* FIXGAIN2 */ \
"Force Switch Gain 1", /* FORCESWITCHG1*/ \
"Force Switch Gain 2" /* FORCESWITCHG2*/ \
- };
+ };
+enum NETWORKINDEX { TXN_FRAME };
@@ -84,16 +86,19 @@ enum DACINDEX {VB_COMP, VDD_PROT, VIN_COM, VREF_PRECH, VB_PIXBUF, VB_DS, VREF
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_SETTINGS (DYNAMICGAIN)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
+#define DEFAULT_TMP_THRSHLD (65*1000) //milli degree Celsius
/* Defines in the Firmware */
#define FIX_PATT_VAL (0xACDC2014)
#define ADC_PORT_INVERT_VAL (0x453b2a9c)
+#define MAX_TIMESLOT_VAL (0x1F)
+#define MAX_THRESHOLD_TEMP_VAL (127999) //millidegrees
#define SAMPLE_ADC_HALF_SPEED (SAMPLE_DECMT_FACTOR_2_VAL + SAMPLE_DGTL_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x1000 */
#define SAMPLE_ADC_QUARTER_SPEED (SAMPLE_DECMT_FACTOR_4_VAL + SAMPLE_DGTL_SAMPLE_8_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x2810 */
-#define CONFIG_HALF_SPEED (CONFIG_TDMA_TIMESLOT_0_VAL + CONFIG_TDMA_DISABLE_VAL + CONFIG_HALF_SPEED_20MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL)
-#define CONFIG_QUARTER_SPEED (CONFIG_TDMA_TIMESLOT_0_VAL + CONFIG_TDMA_DISABLE_VAL + CONFIG_QUARTER_SPEED_10MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL)
+#define CONFIG_HALF_SPEED (CONFIG_TDMA_DISABLE_VAL + CONFIG_HALF_SPEED_20MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL)
+#define CONFIG_QUARTER_SPEED (CONFIG_TDMA_DISABLE_VAL + CONFIG_QUARTER_SPEED_10MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL)
#define ADC_OFST_HALF_SPEED_VAL (0x20) //adc pipeline
#define ADC_OFST_QUARTER_SPEED_VAL (0x0f)
#define ADC_PHASE_HALF_SPEED (0x41)
diff --git a/slsDetectorSoftware/moenchDetectorServer/gitInfo.txt b/slsDetectorSoftware/moenchDetectorServer/gitInfo.txt
index 178eb0fa1..4ff46c75b 100644
--- a/slsDetectorSoftware/moenchDetectorServer/gitInfo.txt
+++ b/slsDetectorSoftware/moenchDetectorServer/gitInfo.txt
@@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/moenchDetectorServer
-URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
-Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
-Repsitory UUID: 9f1b82c18ab0893d65bfadeb646b8ea244614632
-Revision: 83
-Branch: developer
-Last Changed Author: Dhanya_Maliakal
-Last Changed Rev: 1443
-Last Changed Date: 2017-07-10 11:03:27.000000002 +0200 ./Makefile
+URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
+Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
+Repsitory UUID: e6bd874a88493557fc5127d4a1686832299aaf06
+Revision: 85
+Branch: 3.0.1
+Last Changed Author: Dhanya_Thattil
+Last Changed Rev: 3346
+Last Changed Date: 2018-02-07 09:14:36.000000002 +0100 ./server_funcs.c
diff --git a/slsDetectorSoftware/moenchDetectorServer/gitInfoMoench.h b/slsDetectorSoftware/moenchDetectorServer/gitInfoMoench.h
index 289be4767..96f110d39 100644
--- a/slsDetectorSoftware/moenchDetectorServer/gitInfoMoench.h
+++ b/slsDetectorSoftware/moenchDetectorServer/gitInfoMoench.h
@@ -1,6 +1,6 @@
-#define GITURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git"
-#define GITREPUUID "9f1b82c18ab0893d65bfadeb646b8ea244614632"
-#define GITAUTH "Dhanya_Maliakal"
-#define GITREV 0x1443
-#define GITDATE 0x20170710
-#define GITBRANCH "blabla"
+#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
+#define GITREPUUID "e6bd874a88493557fc5127d4a1686832299aaf06"
+#define GITAUTH "Dhanya_Thattil"
+#define GITREV 0x3346
+#define GITDATE 0x20180207
+#define GITBRANCH "3.0.1"
diff --git a/slsDetectorSoftware/moenchDetectorServer/moenchDetectorServerv2.0.3 b/slsDetectorSoftware/moenchDetectorServer/moenchDetectorServerv2.0.3
deleted file mode 100755
index d49a67b57..000000000
Binary files a/slsDetectorSoftware/moenchDetectorServer/moenchDetectorServerv2.0.3 and /dev/null differ
diff --git a/slsDetectorSoftware/moenchDetectorServer/server_funcs.c b/slsDetectorSoftware/moenchDetectorServer/server_funcs.c
index cef404689..33f776c33 100755
--- a/slsDetectorSoftware/moenchDetectorServer/server_funcs.c
+++ b/slsDetectorSoftware/moenchDetectorServer/server_funcs.c
@@ -593,12 +593,10 @@ int get_id(int file_des) {
retval=getDetectorNumber();
break;
case DETECTOR_FIRMWARE_VERSION:
- retval=getFirmwareSVNVersion();
- retval=(retval <<32) | getFirmwareVersion();
+ retval = (getFirmwareVersion() & 0xFFFFFF);
break;
case DETECTOR_SOFTWARE_VERSION:
- retval= GITREV;
- retval= (retval <<32) | GITDATE;
+ retval = (GITDATE & 0xFFFFFF);
break;
default:
printf("Required unknown id %d \n", arg);
diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp
index d9d87fb02..c415be085 100644
--- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp
+++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp
@@ -1215,7 +1215,7 @@ int multiSlsDetector::getThresholdEnergy(int pos) {
if (ret1==-100)
ret1=ret;
else if (ret<(ret1-200) || ret>(ret1+200))
- ret1=FAIL;
+ ret1=-1;
}
@@ -1260,7 +1260,7 @@ int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings ise
if(iret[idet] != NULL){
if (ret==-100)
ret=*iret[idet];
- else if (ret<(*iret[idet]-200) || ret>(*iret[idet]+200))
+ else if (*iret[idet]<(ret-200) || *iret[idet]>(ret+200))
ret=-1;
delete iret[idet];
}else ret=-1;
@@ -3369,6 +3369,173 @@ dacs_t multiSlsDetector::getADC(dacIndex idac, int imod) {
return ret;
}
+
+
+int multiSlsDetector::setThresholdTemperature(int val, int imod) {
+ int ret = -100;
+
+ // single
+ {
+ int id=-1, im=-1;
+ if (decodeNMod(imod, id, im)>=0) {
+ if(detectors[id]){
+ ret = detectors[id]->setThresholdTemperature(val, im);
+ if(detectors[id]->getErrorMask())
+ setErrorMask(getErrorMask()|(1<numberOfDetectors;
+ int* iret[posmax-posmin];
+
+ for(int idet=posmin; idet(&slsDetector::setThresholdTemperature,
+ detectors[idet], val, imod, iret[idet]));
+ threadpool->add_task(task);
+ }
+ }
+ threadpool->startExecuting();
+ threadpool->wait_for_tasks_to_complete();
+ for(int idet=posmin; idetgetErrorMask())
+ setErrorMask(getErrorMask()|(1<=0) {
+ if(detectors[id]){
+ ret = detectors[id]->setTemperatureControl(val, im);
+ if(detectors[id]->getErrorMask())
+ setErrorMask(getErrorMask()|(1<numberOfDetectors;
+ int* iret[posmax-posmin];
+
+ for(int idet=posmin; idet(&slsDetector::setTemperatureControl,
+ detectors[idet], val, imod, iret[idet]));
+ threadpool->add_task(task);
+ }
+ }
+ threadpool->startExecuting();
+ threadpool->wait_for_tasks_to_complete();
+ for(int idet=posmin; idetgetErrorMask())
+ setErrorMask(getErrorMask()|(1<=0) {
+ if(detectors[id]){
+ ret = detectors[id]->setTemperatureEvent(val, im);
+ if(detectors[id]->getErrorMask())
+ setErrorMask(getErrorMask()|(1<numberOfDetectors;
+ int* iret[posmax-posmin];
+
+ for(int idet=posmin; idet(&slsDetector::setTemperatureEvent,
+ detectors[idet], val, imod, iret[idet]));
+ threadpool->add_task(task);
+ }
+ }
+ threadpool->startExecuting();
+ threadpool->wait_for_tasks_to_complete();
+ for(int idet=posmin; idetgetErrorMask())
+ setErrorMask(getErrorMask()|(1<dataBytes=0;
- thisMultiDetector->dataBytesInclGapPixels=0;
- thisMultiDetector->numberOfChannels=0;
-
- for (int idet=0; idetnumberOfDetectors; ++idet) {
- if (detectors[idet]) {
- ret1=detectors[idet]->setDynamicRange(p);
- if(detectors[idet]->getErrorMask())
- setErrorMask(getErrorMask()|(1<dataBytes+=detectors[idet]->getDataBytes();
- thisMultiDetector->dataBytesInclGapPixels+=detectors[idet]->getDataBytesInclGapPixels();
- // cout << "db " << idet << " " << detectors[idet]->getDataBytes() << endl;
- thisMultiDetector->numberOfChannels+=detectors[idet]->getTotalNumberOfChannels();
+ int ret=-100;
+ thisMultiDetector->dataBytes=0;
+ thisMultiDetector->dataBytesInclGapPixels=0;
+ thisMultiDetector->numberOfChannels=0;
- if (ret==-100)
- ret=ret1;
- else if (ret!=ret1)
- ret=-1;
+ if(!threadpool){
+ cout << "Error in creating threadpool. Exiting" << endl;
+ return -1;
+ }else{
+ //return storage values
+ int* iret[thisMultiDetector->numberOfDetectors];
+ for(int idet=0; idetnumberOfDetectors; ++idet){
+ if(detectors[idet]){
+ iret[idet]= new int(-1);
+ Task* task = new Task(new func1_t(&slsDetector::setDynamicRange,
+ detectors[idet],p,iret[idet]));
+ threadpool->add_task(task);
+ }
+ }
+ threadpool->startExecuting();
+ threadpool->wait_for_tasks_to_complete();
+ for(int idet=0; idetnumberOfDetectors; ++idet){
+ if(detectors[idet]){
+ if(iret[idet] != NULL){
+ thisMultiDetector->dataBytes+=detectors[idet]->getDataBytes();
+ thisMultiDetector->dataBytesInclGapPixels+=detectors[idet]->getDataBytesInclGapPixels();
+ thisMultiDetector->numberOfChannels+=detectors[idet]->getTotalNumberOfChannels();
+ if (ret==-100)
+ ret=*iret[idet];
+ else if (ret!=*iret[idet])
+ ret=-1;
+ delete iret[idet];
+ }else ret=-1;
+ if(detectors[idet]->getErrorMask())
+ setErrorMask(getErrorMask()|(1<numberOfDetectors; ++i) {
+ if (detectors[i]) {
+ ret=detectors[i]->setAutoComparatorDisableMode(ival);
+ if(detectors[i]->getErrorMask())
+ setErrorMask(getErrorMask()|(1<numberOfDetectors; ++i) {
if (detectors[i]) {
ret=detectors[i]->writeRegister(addr,val);
if(detectors[i]->getErrorMask())
setErrorMask(getErrorMask()|(1<numberOfDetectors; ++i) {
if (detectors[i]) {
ret=detectors[i]->readRegister(addr);
if(detectors[i]->getErrorMask())
setErrorMask(getErrorMask()|(1<numberOfDetectors; ++i) {
if (detectors[i]) {
ret1=detectors[i]->setBit(addr,n);
if(detectors[i]->getErrorMask())
setErrorMask(getErrorMask()|(1<numberOfDetectors; ++i) {
if (detectors[i]) {
ret1=detectors[i]->clearBit(addr,n);
if(detectors[i]->getErrorMask())
setErrorMask(getErrorMask()|(1<offsetY[isocket] + i) * maxX) + thisMultiDetector->offsetX[isocket])* (int)bytesperchannel,
+ (char*)image+ (i*slsmaxX*(int)bytesperchannel),
+ (slsmaxX*(int)bytesperchannel));
+ }
}
}
diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h
index c1948e473..a0875185d 100644
--- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h
+++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h
@@ -532,7 +532,7 @@ class multiSlsDetector : public slsDetectorUtils {
int64_t getId(idMode mode, int imod=0);
int digitalTest(digitalTestMode mode, int imod=0);
int executeTrimming(trimMode mode, int par1, int par2, int imod=-1);
- const char *getSettingsFile();
+ string getSettingsFile();
int decodeNMod(int i, int &idet, int &imod);
@@ -554,6 +554,12 @@ class multiSlsDetector : public slsDetectorUtils {
*/
int powerChip(int ival= -1);
+ /** automatic comparator disable for Jungfrau only
+ \param ival on is 1, off is 0, -1 to get
+ \returns OK or FAIL
+ */
+ int setAutoComparatorDisableMode(int ival= -1);
+
/** loads the modules settings/trimbits reading from a file - file name extension is automatically generated! */
int loadSettingsFile(string fname, int nmod=-1);
@@ -975,6 +981,31 @@ class multiSlsDetector : public slsDetectorUtils {
\returns current DAC value (temperature for eiger and jungfrau in millidegrees)
*/
dacs_t getADC(dacIndex index, int imod=-1);
+
+ /**
+ set/gets threshold temperature (Jungfrau only)
+ \param val value in millidegrees, -1 gets
+ \param imod module number, -1 is all
+ \returns threshold temperature in millidegrees
+ */
+ int setThresholdTemperature(int val=-1, int imod=-1);
+
+ /**
+ enables/disables temperature control (Jungfrau only)
+ \param val value, -1 gets
+ \param imod module number, -1 is all
+ \returns temperature control enable
+ */
+ int setTemperatureControl(int val=-1, int imod=-1);
+
+ /**
+ Resets/ gets over-temperature event (Jungfrau only)
+ \param val value, -1 gets
+ \param imod module number, -1 is all
+ \returns over-temperature event
+ */
+ int setTemperatureEvent(int val=-1, int imod=-1);
+
/**
configure channel
\param reg channel register
@@ -1069,13 +1100,13 @@ class multiSlsDetector : public slsDetectorUtils {
- int writeRegister(int addr, int val);
+ uint32_t writeRegister(uint32_t addr, uint32_t val);
int writeAdcRegister(int addr, int val);
- int readRegister(int addr);
+ uint32_t readRegister(uint32_t addr);
/**
sets a bit in a register
@@ -1085,7 +1116,7 @@ class multiSlsDetector : public slsDetectorUtils {
DO NOT USE!!! ONLY EXPERT USER!!!
*/
- int setBit(int addr, int n);
+ uint32_t setBit(uint32_t addr, int n);
/**
@@ -1096,7 +1127,7 @@ class multiSlsDetector : public slsDetectorUtils {
DO NOT USE!!! ONLY EXPERT USER!!!
*/
- int clearBit(int addr, int n);
+ uint32_t clearBit(uint32_t addr, int n);
@@ -1209,6 +1240,8 @@ class multiSlsDetector : public slsDetectorUtils {
slsDetector *getSlsDetector(int pos) {if (pos>=0 && pos< MAXDET) return detectors[pos]; return NULL;};
+ //additional way of accessing
+ slsDetector *operator()(int pos) {if (pos>=0 && pos< MAXDET) return detectors[pos]; return NULL;};
diff --git a/slsDetectorSoftware/mythen3DetectorServer/AD9257.h b/slsDetectorSoftware/mythen3DetectorServer/AD9257.h
deleted file mode 100755
index a716af64c..000000000
--- a/slsDetectorSoftware/mythen3DetectorServer/AD9257.h
+++ /dev/null
@@ -1,141 +0,0 @@
-#ifndef AD9257_H
-#define AD9257_H
-
-#include "ansi.h"
-
-#include "commonServerFunctions.h"
-#include
-
-/* AD9257 ADC DEFINES */
-#define AD9257_ADC_NUMBITS (24)
-
-#define AD9257_DEV_IND_2_REG (0x04)
-#define AD9257_CHAN_H_OFST (0)
-#define AD9257_CHAN_H_MSK (0x00000001 << AD9257_CHAN_H_OFST)
-#define AD9257_CHAN_G_OFST (1)
-#define AD9257_CHAN_G_MSK (0x00000001 << AD9257_CHAN_G_OFST)
-#define AD9257_CHAN_F_OFST (2)
-#define AD9257_CHAN_F_MSK (0x00000001 << AD9257_CHAN_F_OFST)
-#define AD9257_CHAN_E_OFST (3)
-#define AD9257_CHAN_E_MSK (0x00000001 << AD9257_CHAN_E_OFST)
-
-#define AD9257_DEV_IND_1_REG (0x05)
-#define AD9257_CHAN_D_OFST (0)
-#define AD9257_CHAN_D_MSK (0x00000001 << AD9257_CHAN_D_OFST)
-#define AD9257_CHAN_C_OFST (1)
-#define AD9257_CHAN_C_MSK (0x00000001 << AD9257_CHAN_C_OFST)
-#define AD9257_CHAN_B_OFST (2)
-#define AD9257_CHAN_B_MSK (0x00000001 << AD9257_CHAN_B_OFST)
-#define AD9257_CHAN_A_OFST (3)
-#define AD9257_CHAN_A_MSK (0x00000001 << AD9257_CHAN_A_OFST)
-#define AD9257_CLK_CH_DCO_OFST (4)
-#define AD9257_CLK_CH_DCO_MSK (0x00000001 << AD9257_CLK_CH_DCO_OFST)
-#define AD9257_CLK_CH_IFCO_OFST (5)
-#define AD9257_CLK_CH_IFCO_MSK (0x00000001 << AD9257_CLK_CH_IFCO_OFST)
-
-#define AD9257_POWER_MODE_REG (0x08)
-#define AD9257_POWER_INTERNAL_OFST (0)
-#define AD9257_POWER_INTERNAL_MSK (0x00000003 << AD9257_POWER_INTERNAL_OFST)
-#define AD9257_INT_RESET_VAL (0x3)
-#define AD9257_INT_CHIP_RUN_VAL (0x0)
-#define AD9257_POWER_EXTERNAL_OFST (5)
-#define AD9257_POWER_EXTERNAL_MSK (0x00000001 << AD9257_POWER_EXTERNAL_OFST)
-#define AD9257_EXT_FULL_POWER_VAL (0x0)
-#define AD9257_EXT_STANDBY_VAL (0x1)
-
-#define AD9257_OUT_MODE_REG (0x14)
-#define AD9257_OUT_FORMAT_OFST (0)
-#define AD9257_OUT_FORMAT_MSK (0x00000001 << AD9257_OUT_FORMAT_OFST)
-#define AD9257_OUT_BINARY_OFST_VAL (0)
-#define AD9257_OUT_TWOS_COMPL_VAL (1)
-#define AD9257_OUT_LVDS_OPT_OFST (6)
-#define AD9257_OUT_LVDS_OPT_MSK (0x00000001 << AD9257_OUT_LVDS_OPT_OFST)
-#define AD9257_OUT_LVDS_ANSI_VAL (0)
-#define AD9257_OUT_LVDS_IEEE_VAL (1)
-
-#define AD9257_OUT_PHASE_REG (0x16)
-#define AD9257_OUT_CLK_OFST (0)
-#define AD9257_OUT_CLK_MSK (0x0000000F << AD9257_OUT_CLK_OFST)
-#define AD9257_OUT_CLK_60_VAL (0x1)
-#define AD9257_IN_CLK_OFST (4)
-#define AD9257_IN_CLK_MSK (0x00000007 << AD9257_IN_CLK_OFST)
-#define AD9257_IN_CLK_0_VAL (0x0)
-
-#define AD9257_VREF_REG (0x18)
-#define AD9257_VREF_OFST (0)
-#define AD9257_VREF_MSK (0x00000003 << AD9257_VREF_OFST)
-#define AD9257_VREF_1_33_VAL (0x2)
-
-#define AD9257_TEST_MODE_REG (0x0D)
-#define AD9257_OUT_TEST_OFST (0)
-#define AD9257_OUT_TEST_MSK (0x0000000F << AD9257_OUT_TEST_OFST)
-#define AD9257_NONE_VAL (0x0)
-#define AD9257_MIXED_BIT_FREQ_VAL (0xC)
-#define AD9257_TEST_RESET_SHORT_GEN (4)
-#define AD9257_TEST_RESET_LONG_GEN (5)
-#define AD9257_USER_IN_MODE_OFST (6)
-#define AD9257_USER_IN_MODE_MSK (0x00000003 << AD9257_USER_IN_MODE_OFST)
-
-
-void setAdc(int addr, int val) {
-
- u_int32_t codata;
- codata = val + (addr << 8);
- printf(" Setting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr);
- serializeToSPI(ADC_SPI_REG, codata, ADC_SERIAL_CS_OUT_MSK, AD9257_ADC_NUMBITS,
- ADC_SERIAL_CLK_OUT_MSK, ADC_SERIAL_DATA_OUT_MSK, ADC_SERIAL_DATA_OUT_OFST);
-}
-
-void prepareADC(){
- printf("\n\nPreparing ADC ... \n");
-
- //power mode reset
- printf("power mode reset:\n");
- setAdc(AD9257_POWER_MODE_REG,
- (AD9257_INT_RESET_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK);
-
- //power mode chip run
- printf("power mode chip run:\n");
- setAdc(AD9257_POWER_MODE_REG,
- (AD9257_INT_CHIP_RUN_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK);
-
- //output clock phase
- printf("output clock phase:\n");
- setAdc(AD9257_OUT_PHASE_REG,
- (AD9257_OUT_CLK_60_VAL << AD9257_OUT_CLK_OFST) & AD9257_OUT_CLK_MSK);
-
- // lvds-iee reduced , binary offset
- printf("lvds-iee reduced, binary offset:\n");
- setAdc(AD9257_OUT_MODE_REG,
- (AD9257_OUT_LVDS_IEEE_VAL << AD9257_OUT_LVDS_OPT_OFST) & AD9257_OUT_LVDS_OPT_MSK);
-
- // all devices on chip to receive next command
- printf("all devices on chip to receive next command:\n");
- setAdc(AD9257_DEV_IND_2_REG,
- AD9257_CHAN_H_MSK | AD9257_CHAN_G_MSK | AD9257_CHAN_F_MSK | AD9257_CHAN_E_MSK);
- setAdc(AD9257_DEV_IND_1_REG,
- AD9257_CHAN_D_MSK | AD9257_CHAN_C_MSK | AD9257_CHAN_B_MSK | AD9257_CHAN_A_MSK |
- AD9257_CLK_CH_DCO_MSK | AD9257_CLK_CH_IFCO_MSK);
-
- // vref 1.33
- printf("vref 1.33:\n");
- setAdc(AD9257_VREF_REG,
- (AD9257_VREF_1_33_VAL << AD9257_VREF_OFST) & AD9257_VREF_MSK);
-
- // no test mode
- printf("no test mode:\n");
- setAdc(AD9257_TEST_MODE_REG,
- (AD9257_NONE_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK);
-
-#ifdef TESTADC
- printf("***************************************** *******\n");
- printf("******* PUTTING ADC IN TEST MODE!!!!!!!!! *******\n");
- printf("***************************************** *******\n");
- // mixed bit frequency test mode
- printf("mixed bit frequency test mode:\n");
- setAdc(AD9257_TEST_MODE_REG,
- (AD9257_MIXED_BIT_FREQ_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK);
-#endif
-}
-
-#endif //AD9257_H
diff --git a/slsDetectorSoftware/mythen3DetectorServer/AD9257.h b/slsDetectorSoftware/mythen3DetectorServer/AD9257.h
new file mode 120000
index 000000000..87b70e097
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/AD9257.h
@@ -0,0 +1 @@
+../slsDetectorServer/AD9257.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/mythen3DetectorServer/Makefile b/slsDetectorSoftware/mythen3DetectorServer/Makefile
index 7d4c38415..ba8ffe5f1 100644
--- a/slsDetectorSoftware/mythen3DetectorServer/Makefile
+++ b/slsDetectorSoftware/mythen3DetectorServer/Makefile
@@ -1,28 +1,33 @@
CROSS = bfin-uclinux-
CC = $(CROSS)gcc
#CC = gcc
-CLAGS += -Wall -DVIRTUAL -DDACS_INT -DGENERICD # -DSLS_DETECTOR_FUNCTION_LIST
-LDLIBS += -lm
-INCS = -I. -I../../slsReceiverSoftware/include/
-PROGS = mythen3Server
-#DESTDIR ?= bin
+CLAGS += -Wall -DMYTHEN3D -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
+LDLIBS += -lm -lstdc++
+
+
+PROGS = mythen3DetectorServer
+DESTDIR ?= bin
INSTMODE = 0777
-SRC_CLNT = slsDetectorServer.c slsDetectorServer_funcs.c communication_funcs.c slsDetectorFunctionList.c
+SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c
OBJS = $(SRC_CLNT:.c=.o)
-all: clean $(PROGS)
+all: clean versioning $(PROGS)
boot: $(OBJS)
-$(PROGS):
- echo $(OBJS)
-# mkdir -p $(DESTDIR)
- $(CC) $(SRC_CLNT) $(CLAGS) $(LDLIBS) $(INCS) -o $@
-# mv $(PROGS) $(DESTDIR)
+versioning:
+ @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;`
+$(PROGS): $(OBJS)
+# echo $(OBJS)
+ mkdir -p $(DESTDIR)
+ $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
+ mv $(PROGS) $(DESTDIR)
+ rm *.gdb
clean:
- rm -rf $(DESTDIR)/$(PROGS) *.o
+ rm -rf $(DESTDIR)/$(PROGS) *.o
+
diff --git a/slsDetectorSoftware/mythen3DetectorServer/Makefile.virtual b/slsDetectorSoftware/mythen3DetectorServer/Makefile.virtual
new file mode 100644
index 000000000..de7284bcc
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/Makefile.virtual
@@ -0,0 +1,25 @@
+CC = gcc
+CFLAGS += -Wall -DVIRTUAL -DMYTHEN3D -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
+LDLIBS += -lm -lstdc++
+
+PROGS = virtualMythen3DetectorServer
+DESTDIR ?= bin
+INSTMODE = 0777
+
+SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c
+OBJS = $(SRC_CLNT:.c=.o)
+
+all: clean $(PROGS)
+
+boot: $(OBJS)
+
+$(PROGS): $(OBJS)
+ echo $(OBJS)
+ mkdir -p $(DESTDIR)
+ $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
+ mv $(PROGS) $(DESTDIR)
+ rm *.gdb
+
+clean:
+ rm -rf $(DESTDIR)/$(PROGS) *.o
+
diff --git a/slsDetectorSoftware/mythen3DetectorServer/RegisterDefs.h b/slsDetectorSoftware/mythen3DetectorServer/RegisterDefs.h
index e475e8fcb..1fa922d3b 100644
--- a/slsDetectorSoftware/mythen3DetectorServer/RegisterDefs.h
+++ b/slsDetectorSoftware/mythen3DetectorServer/RegisterDefs.h
@@ -1,551 +1,101 @@
#ifndef REGISTERS_G_H
#define REGISTERS_G_H
-
-#include "sls_detector_defs.h"
-
-
/* Definitions for FPGA*/
-#define CSP0 0x20200000
-#define MEM_SIZE 0x100000
-
-
-
-/* values defined for FPGA */
-#define MCSNUM 0x0
-#define FIXED_PATT_VAL 0xacdc1980
-
-
-#define FPGA_INIT_PAT 0x60008
-#define FPGA_INIT_ADDR 0xb0000000
-
-//#ifdef JUNGFRAU_DHANYA
-#define POWER_ON_REG 0x5e<<11
-// Pwr_I2C_SDA <= PowerReg_s(1) when PowerReg_s(3)='1' else 'Z';
-// Pwr_I2C_SCL <= PowerReg_s(0) when PowerReg_s(2)='1' else 'Z';
-
-#define PWR_I2C_SCL_BIT 0
-#define PWR_I2C_SDA_BIT 1
-#define PWR_I2C_SCL_EN_BIT 2
-#define PWR_I2C_SDA_EN_BIT 3
-
-#define POWER_STATUS_REG 41<<11
-
-#define ADCREG1 0x08
-#define ADCREG2 0x14//20
-#define ADCREG3 0x4
-#define ADCREG4 0x5
-#define ADCREG_VREFS 24
-#define DBIT_PIPELINE_REG 89<<11 //0x59 same PATTERN_N_LOOP2_REG
-#define MEM_MACHINE_FIFOS_REG 79<<11 //from gotthard
-#define CONFGAIN_REG 93<<11 //from gotthard
-#define ADC_PIPELINE_REG 66<<11 //0x42 same as ADC_OFFSET_REG
-//#endif
-
-//#define ADC_OFFSET_REG 93<<11 //same as DAQ_REG
-#define ADC_INVERSION_REG 67<<11
-
-#define DAC_REG 64<<11//0x17<<11// control the dacs
-//ADC
-#define ADC_WRITE_REG 65<<11//0x18<<11
-//#define ADC_SYNC_REG 66<<11//0x19<<11
-//#define HV_REG 67<<11//0x20<<11
-
-
-
-
-//#define MUTIME_REG 0x1a<<11
-//temperature
-#define TEMP_IN_REG 0x1b<<11
-#define TEMP_OUT_REG 0x1c<<11
-//configure MAC
-#define TSE_CONF_REG 0x1d<<11
-#define ENET_CONF_REG 0x1e<<11
-//#define WRTSE_SHAD_REG 0x1f<<11
-//HV
-
-
-#define DUMMY_REG 68<<11//0x21<<11
-#define FPGA_VERSION_REG 0<<11 //0x22<<11
-#define PCB_REV_REG 0<<11
-#define FIX_PATT_REG 1<<11 //0x23<<11
-#define CONTROL_REG 79<<11//0x24<<11
-#define STATUS_REG 2<<11 //0x25<<11
-#define CONFIG_REG 77<<11//0x26<<11
-#define EXT_SIGNAL_REG 78<<11// 0x27<<11
-//#define FPGA_SVN_REG 0x29<<11
-
-
-#define CHIP_OF_INTRST_REG 0x2A<<11
-
-//FIFO
-#define LOOK_AT_ME_REG 3<<11 //0x28<<11
-#define SYSTEM_STATUS_REG 4<<11
-
-#define FIFO_DATA_REG 6<<11
-#define FIFO_STATUS_REG 7<<11
-
-// constant FifoDigitalInReg_c : integer := 60;
-#define FIFO_DIGITAL_DATA_LSB_REG 60<<11
-#define FIFO_DIGITAL_DATA_MSB_REG 61<<11
-
-#define FIFO_DATA_REG_OFF 0x50<<11 ///////
-//to read back dac registers
-//#define MOD_DACS1_REG 0x65<<11
-//#define MOD_DACS2_REG 0x66<<11
-//#define MOD_DACS3_REG 0x67<<11
-
-//user entered
-
-
-
-
-
-
-#define GET_ACTUAL_TIME_LSB_REG 16<<11
-#define GET_ACTUAL_TIME_MSB_REG 17<<11
-
-#define GET_MEASUREMENT_TIME_LSB_REG 38<<11
-#define GET_MEASUREMENT_TIME_MSB_REG 39<<11
-
-
-#define SET_DELAY_LSB_REG 96<<11 //0x68<<11
-#define SET_DELAY_MSB_REG 97<<11 //0x69<<11
-#define GET_DELAY_LSB_REG 18<<11//0x6a<<11
-#define GET_DELAY_MSB_REG 19<<11//0x6b<<11
-
-#define SET_CYCLES_LSB_REG 98<<11//0x6c<<11
-#define SET_CYCLES_MSB_REG 99<<11//0x6d<<11
-#define GET_CYCLES_LSB_REG 20<<11//0x6e<<11
-#define GET_CYCLES_MSB_REG 21<<11//0x6f<<11
-
-#define SET_FRAMES_LSB_REG 100<<11//0x70<<11
-#define SET_FRAMES_MSB_REG 101<<11//0x71<<11
-#define GET_FRAMES_LSB_REG 22<<11//0x72<<11
-#define GET_FRAMES_MSB_REG 23<<11//0x73<<11
-
-#define SET_PERIOD_LSB_REG 102<<11//0x74<<11
-#define SET_PERIOD_MSB_REG 103<<11//0x75<<11
-#define GET_PERIOD_LSB_REG 24<<11//0x76<<11
-#define GET_PERIOD_MSB_REG 25<<11//0x77<<11
-
-//#define PATTERN_WAIT0_TIME_REG_LSB 114<<11
-//#define PATTERN_WAIT0_TIME_REG_MSB 115<<11
-#define SET_EXPTIME_LSB_REG 114<<11//0x78<<11
-#define SET_EXPTIME_MSB_REG 115<<11//0x79<<11
-#define GET_EXPTIME_LSB_REG 26<<11//0x7a<<11
-#define GET_EXPTIME_MSB_REG 27<<11//0x7b<<11
-
-#define SET_GATES_LSB_REG 106<<11//0x7c<<11
-#define SET_GATES_MSB_REG 107<<11//0x7d<<11
-#define GET_GATES_LSB_REG 28<<11//0x7e<<11
-#define GET_GATES_MSB_REG 29<<11//0x7f<<11
-
-#define DATA_IN_LSB_REG 30<<11
-#define DATA_IN_MSB_REG 31<<11
-
-#define PATTERN_OUT_LSB_REG 32<<11
-#define PATTERN_OUT_MSB_REG 33<<11
-
-#define FRAMES_FROM_START_LSB_REG 34<<11
-#define FRAMES_FROM_START_MSB_REG 35<<11
-
-#define FRAMES_FROM_START_PG_LSB_REG 36<<11
-#define FRAMES_FROM_START_PG_MSB_REG 37<<11
-
-#define SLOW_ADC_REG 43<<11
-
-
-
-#define PLL_PARAM_REG 80<<11//0x37<<11
-#define PLL_PARAM_OUT_REG 5<<11 //0x38<<11
-#define PLL_CNTRL_REG 81<<11//0x34<<11
-
-
-#ifdef NEW_GBE_INTERFACE
-#define GBE_PARAM_OUT_REG 40<<11
-#define GBE_PARAM_REG 69<<11
-#define GBE_CNTRL_REG 70<<11
-#else
-#define RX_UDP_AREG 69<<11 //rx_udpip_AReg_c : integer:= 69; *\/
-#define UDPPORTS_AREG 70<<11// udpports_AReg_c : integer:= 70; *\/
-#define RX_UDPMACL_AREG 71<<11//rx_udpmacL_AReg_c : integer:= 71; *\/
-#define RX_UDPMACH_AREG 72<<11//rx_udpmacH_AReg_c : integer:= 72; *\/
-#define DETECTORMACL_AREG 73<<11//detectormacL_AReg_c : integer:= 73; *\/
-#define DETECTORMACH_AREG 74<<11//detectormacH_AReg_c : integer:= 74; *\/
-#define DETECTORIP_AREG 75<<11//detectorip_AReg_c : integer:= 75; *\/
-#define IPCHKSUM_AREG 76<<11//ipchksum_AReg_c : integer:= 76; *\/ */
-#endif
-
-
-#define PATTERN_CNTRL_REG 82<<11 // address of patword
-#define PATTERN_LIMITS_AREG 83<<11 // start/stop pattern
-
-#define PATTERN_LOOP0_AREG 84<<11 // start/stop of loop
-#define PATTERN_N_LOOP0_REG 85<<11 // # loops
-
-#define PATTERN_LOOP1_AREG 86<<11
-#define PATTERN_N_LOOP1_REG 87<<11
-
-#define PATTERN_LOOP2_AREG 88<<11
-#define PATTERN_N_LOOP2_REG 89<<11
-
-#define PATTERN_WAIT0_AREG 90<<11 // address where to wait
-#define PATTERN_WAIT1_AREG 91<<11
-#define PATTERN_WAIT2_AREG 92<<11
-
-
-
-//#define DAQ_REG 93<<11 //unused
-#define NSAMPLES_REG 93<<11 //unused
-
-
-#define HV_REG 95<<11
-
-
-
-#define PATTERN_IOCTRL_REG_LSB 108<<11 // if output or not
-#define PATTERN_IOCTRL_REG_MSB 109<<11
-
-#define PATTERN_IOCLKCTRL_REG_LSB 110<<11//unused
-#define PATTERN_IOCLKCTRL_REG_MSB 111<<11//unused
-#define PATTERN_IN_REG_LSB 112<<11 // write word
-#define PATTERN_IN_REG_MSB 113<<11
-#define PATTERN_WAIT0_TIME_REG_LSB 114<<11 // how long to wait
-#define PATTERN_WAIT0_TIME_REG_MSB 115<<11
-#define PATTERN_WAIT1_TIME_REG_LSB 116<<11
-#define PATTERN_WAIT1_TIME_REG_MSB 117<<11
-#define PATTERN_WAIT2_TIME_REG_LSB 118<<11
-#define PATTERN_WAIT2_TIME_REG_MSB 119<<11
-
-//#define DAC_REG_OFF 120
-//#define DAC_0_1_VAL_REG 120<<11
-//#define DAC_2_3_VAL_REG 121<<11
-//#define DAC_4_5_VAL_REG 122<<11
-//#define DAC_6_7_VAL_REG 123<<11
-//#define DAC_8_9_VAL_REG 124<<11
-//#define DAC_10_11_VAL_REG 125<<11
-//#define DAC_12_13_VAL_REG 126<<11
-//#define DAC_14_15_VAL_REG 127<<11
-#define DAC_VAL_REG 121<<11 // value of the DAC
-#define DAC_NUM_REG 122<<11 // Index of the DAC, only JCTB
-#define DAC_VAL_OUT_REG 42<<11
-#define ADC_LATCH_DISABLE_REG 120<<11
-
-
-
-
-
-
-
-
-/* registers defined in FPGA */
-#define GAIN_REG 0
-//#define FLOW_CONTROL_REG 0x11<<11
-//#define FLOW_STATUS_REG 0x12<<11
-//#define FRAME_REG 0x13<<11
-#define MULTI_PURPOSE_REG 0
-//#define TIME_FROM_START_REG 0x16<<11
-
-
-#define ROI_REG 0 // 0x35<<11
-#define OVERSAMPLING_REG 0 // 0x36<<11
-#define MOENCH_CNTR_REG 0 // 0x31<<11
-#define MOENCH_CNTR_OUT_REG 0 // 0x33<<11
-#define MOENCH_CNTR_CONF_REG 0 // 0x32<<11
-
-
-
-//image
-#define DARK_IMAGE_REG 0 // 0x81<<11
-#define GAIN_IMAGE_REG 0 // 0x82<<11
-
-//counter block memory
-#define COUNTER_MEMORY_REG 0 // 0x85<<11 //gotthard
-
-
-//not used
-//#define MCB_DOUT_REG_OFF 0 // 0x200000
-//#define FIFO_CNTRL_REG_OFF 0 // 0x300000
-//#define FIFO_COUNTR_REG_OFF 0 // 0x400000
-//not used so far
-//#define SPEED_REG 0 // 0x006000
-//#define SET_NBITS_REG 0 // 0x008000
-//not used
-//#define GET_SHIFT_IN_REG 0 // 0x022000
-
-
-
-#define SHIFTMOD 2
-#define SHIFTFIFO 9
-
-/** for PCB_REV_REG */
-#define DETECTOR_TYPE_MASK 0xFF000000
-#define DETECTOR_TYPE_OFFSET 24
-#define BOARD_REVISION_MASK 0xFFFFFF
-#define MOENCH03_MODULE_ID 2
-#define JUNGFRAU_MODULE_ID 1
-#define JUNGFRAU_CTB_ID 3
-
-
-
-
-/* for control register (16bit only)*/
-#define START_ACQ_BIT 0x0001
-#define STOP_ACQ_BIT 0x0002
-#define START_FIFOTEST_BIT 0x0004 // ?????
-#define STOP_FIFOTEST_BIT 0x0008 // ??????
-#define START_READOUT_BIT 0x0010
-#define STOP_READOUT_BIT 0x0020
-#define START_EXPOSURE_BIT 0x0040
-#define STOP_EXPOSURE_BIT 0x0080
-#define START_TRAIN_BIT 0x0100
-#define STOP_TRAIN_BIT 0x0200
-#define FIFO_RESET_BIT 0x8000
-#define SYNC_RESET 0x0400
-#define GB10_RESET_BIT 0x0800
-#define MEM_RESET_BIT 0x1000
-
-/* for status register */
-#define RUN_BUSY_BIT 0x00000001
-#define READOUT_BUSY_BIT 0x00000002
-#define FIFOTEST_BUSY_BIT 0x00000004 //????
-#define WAITING_FOR_TRIGGER_BIT 0x00000008
-#define DELAYBEFORE_BIT 0x00000010
-#define DELAYAFTER_BIT 0x00000020
-#define EXPOSING_BIT 0x00000040
-#define COUNT_ENABLE_BIT 0x00000080
-#define READSTATE_0_BIT 0x00000100
-#define READSTATE_1_BIT 0x00000200
-#define READSTATE_2_BIT 0x00000400
-#define LAM_BIT 0x00000400 // error!
-#define SOME_FIFO_FULL_BIT 0x00000800 // error!
-
-
-
-#define RUNSTATE_0_BIT 0x00001000
-#define RUNSTATE_1_BIT 0x00002000
-#define RUNSTATE_2_BIT 0x00004000
-#define STOPPED_BIT 0x00008000 // stopped!
-#define ALL_FIFO_EMPTY_BIT 0x00010000 // data ready
-#define RUNMACHINE_BUSY_BIT 0x00020000
-#define READMACHINE_BUSY_BIT 0x00040000
-#define PLL_RECONFIG_BUSY 0x00100000
-
-
-
-/* for fifo status register */
-#define FIFO_ENABLED_BIT 0x80000000
-#define FIFO_DISABLED_BIT 0x01000000
-#define FIFO_ERROR_BIT 0x08000000
-#define FIFO_EMPTY_BIT 0x04000000
-#define FIFO_DATA_READY_BIT 0x02000000
-#define FIFO_COUNTER_MASK 0x000001ff
-#define FIFO_NM_MASK 0x00e00000
-#define FIFO_NM_OFF 21
-#define FIFO_NC_MASK 0x001ffe00
-#define FIFO_NC_OFF 9
-
-/* for config register *///not really used yet
-#define TOT_ENABLE_BIT 0x00000002
-#define TIMED_GATE_BIT 0x00000004
-#define CONT_RO_ENABLE_BIT 0x00080000
-#define GB10_NOT_CPU_BIT 0x00001000
-#define ADC_OUTPUT_DISABLE_BIT 0x00100
-#define DIGITAL_OUTPUT_ENABLE_BIT 0x00200
-
-
-/* for speed register */
-#define CLK_DIVIDER_MASK 0x000000ff
-#define CLK_DIVIDER_OFFSET 0
-#define SET_LENGTH_MASK 0x00000f00
-#define SET_LENGTH_OFFSET 8
-#define WAIT_STATES_MASK 0x0000f000
-#define WAIT_STATES_OFFSET 12
-#define TOTCLK_DIVIDER_MASK 0xff000000
-#define TOTCLK_DIVIDER_OFFSET 24
-#define TOTCLK_DUTYCYCLE_MASK 0x00ff0000
-#define TOTCLK_DUTYCYCLE_OFFSET 16
-
-/* for external signal register */
-#define SIGNAL_OFFSET 4
-#define SIGNAL_MASK 0xF
-#define EXT_SIG_OFF 0x0
-#define EXT_GATE_IN_ACTIVEHIGH 0x1
-#define EXT_GATE_IN_ACTIVELOW 0x2
-#define EXT_TRIG_IN_RISING 0x3
-#define EXT_TRIG_IN_FALLING 0x4
-#define EXT_RO_TRIG_IN_RISING 0x5
-#define EXT_RO_TRIG_IN_FALLING 0x6
-#define EXT_GATE_OUT_ACTIVEHIGH 0x7
-#define EXT_GATE_OUT_ACTIVELOW 0x8
-#define EXT_TRIG_OUT_RISING 0x9
-#define EXT_TRIG_OUT_FALLING 0xA
-#define EXT_RO_TRIG_OUT_RISING 0xB
-#define EXT_RO_TRIG_OUT_FALLING 0xC
-
-
-
-/* for temperature register */
-#define T1_CLK_BIT 0x00000001
-#define T1_CS_BIT 0x00000002
-#define T2_CLK_BIT 0x00000004
-#define T2_CS_BIT 0x00000008
-
-
-
-/* fifo control register */
-//#define FIFO_RESET_BIT 0x00000001
-//#define FIFO_DISABLE_TOGGLE_BIT 0x00000002
-
-
-//chip shiftin register meaning
-#define OUTMUX_OFF 20
-#define OUTMUX_MASK 0x1f
-#define PROBES_OFF 4
-#define PROBES_MASK 0x7f
-#define OUTBUF_OFF 0
-#define OUTBUF_MASK 1
-
-
-/* multi purpose register */
-#define PHASE_STEP_BIT 0x00000001
-#define PHASE_STEP_OFFSET 0
-// #define xxx_BIT 0x00000002
-#define RESET_COUNTER_BIT 0x00000004
-#define RESET_COUNTER_OFFSET 2
-//#define xxx_BIT 0x00000008
-//#define xxx_BIT 0x00000010
-#define SW1_BIT 0x00000020
-#define SW1_OFFSET 5
-#define WRITE_BACK_BIT 0x00000040
-#define WRITE_BACK_OFFSET 6
-#define RESET_BIT 0x00000080
-#define RESET_OFFSET 7
-#define ENET_RESETN_BIT 0x00000800
-#define ENET_RESETN_OFFSET 11
-#define INT_RSTN_BIT 0x00002000
-#define INT_RSTN_OFFSET 13
-#define DIGITAL_TEST_BIT 0x00004000
-#define DIGITAL_TEST_OFFSET 14
-//#define CHANGE_AT_POWER_ON_BIT 0x00008000
-//#define CHANGE_AT_POWER_ON_OFFSET 15
-
-
-/* settings/conf gain register */
-#define GAIN_MASK 0x0000000f
-#define GAIN_OFFSET 0
-#define SETTINGS_MASK 0x000000f0
-#define SETTINGS_OFFSET 4
-
-
-/* CHIP_OF_INTRST_REG */
-#define CHANNEL_MASK 0xffff0000
-#define CHANNEL_OFFSET 16
-#define ACTIVE_ADC_MASK 0x0000001f
-
-
-
-/**ADC SYNC CLEAN FIFO*/
-#define ADCSYNC_CLEAN_FIFO_BITS 0x300000
-#define CLEAN_FIFO_MASK 0x0fffff
-
-
-
-
-enum {run_clk_c, adc_clk_c, sync_clk_c, dbit_clk_c};
-
-
-
-
-#define PLL_CNTR_ADDR_OFF 16 //PLL_CNTR_REG bits 21 downto 16 represent the counter address
-
-#define PLL_CNTR_RECONFIG_RESET_BIT 0
-#define PLL_CNTR_READ_BIT 1
-#define PLL_CNTR_WRITE_BIT 2
-#define PLL_CNTR_PLL_RESET_BIT 3
-
-
-#define PLL_CNTR_PHASE_EN_BIT 8
-#define PLL_CNTR_UPDN_BIT 9
-#define PLL_CNTR_CNTSEL_OFF 10
-
-
-
-
-
-#define PLL_MODE_REG 0x0
-#define PLL_STATUS_REG 0x1
-#define PLL_START_REG 0x2
-#define PLL_N_COUNTER_REG 0x3
-#define PLL_M_COUNTER_REG 0x4
-#define PLL_C_COUNTER_REG 0x5 //which ccounter stands in param 22:18; 7:0 lowcount 15:8 highcount; 16 bypassenable; 17 oddivision
-#define PLL_PHASE_SHIFT_REG 0x6 // which ccounter stands in param 16:20; 21 updown (1 up, 0 down)
-#define PLL_K_COUNTER_REG 0x7
-#define PLL_BANDWIDTH_REG 0x8
-#define PLL_CHARGEPUMP_REG 0x9
-#define PLL_VCO_DIV_REG 0x1c
-#define PLL_MIF_REG 0x1f
-
-#define PPL_M_CNT_PARAM_DEFAULT 0x4040
-#define PPL_N_CNT_PARAM_DEFAULT 0x20D0C
-#define PPL_C0_CNT_PARAM_DEFAULT 0x20D0C
-#define PPL_C1_CNT_PARAM_DEFAULT 0xA0A0
-#define PPL_C2_CNT_PARAM_DEFAULT 0x20D0C
-#define PPL_C3_CNT_PARAM_DEFAULT 0x0808
-#define PPL_BW_PARAM_DEFAULT 0x2EE0
-#define PPL_VCO_PARAM_DEFAULT 0x1
-
-#define NEW_PLL_RECONFIG
-
-#ifdef NEW_PLL_RECONFIG
-#define PLL_VCO_FREQ_MHZ 400//480//800
-#else
-#define PLL_VCO_FREQ_MHZ 480//800
-#endif
-
-
-
-
-
-/*
- GBE parameter and control registers definitions
-*/
-
-#define GBE_CTRL_WSTROBE 0
-#define GBE_CTRL_VAR_OFFSET 16
-#define GBE_CTRL_VAR_MASK 0XF
-#define GBE_CTRL_RAMADDR_OFFSET 24
-#define GBE_CTRL_RAMADDR_MASK 0X3F
-#define GBE_CTRL_INTERFACE 23
-
-#define RX_UDP_IP_ADDR 0
-#define RX_UDP_PORTS_ADDR 1
-#define RX_UDP_MAC_L_ADDR 2
-#define RX_UDP_MAC_H_ADDR 3
-#define IPCHECKSUM_ADDR 4
-#define GBE_DELAY_ADDR 5
-#define GBE_RESERVED1_ADDR 6
-#define GBE_RESERVED2_ADDR 7
-#define DETECTOR_MAC_L_ADDR 8
-#define DETECTOR_MAC_H_ADDR 9
-#define DETECTOR_IP_ADDR 10
-
-
-
-/**------------------
--- pattern registers definitions
---------------------------------------------- */
-#define IOSIGNALS_MASK 0xfffffffffffff
-#define ADC_ENABLE_BIT 63
-#define APATTERN_MASK 0xffff
-#define ASTART_OFFSET 0
-#define ASTOP_OFFSET 16
-#define PATTERN_CTRL_WRITE_BIT 0
-#define PATTERN_CTRL_READ_BIT 1
-#define PATTERN_CTRL_ADDR_OFFSET 16
-#define MAX_PATTERN_LENGTH 1024
+/* FPGA Version register */
+#define FPGA_VERSION_REG (0x00 << 11)
+
+#define BOARD_REVISION_OFST (0)
+#define BOARD_REVISION_MSK (0x00FFFFFF << BOARD_REVISION_OFST)
+#define DETECTOR_TYPE_OFST (24)
+#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST)
+
+/* Fix pattern register */
+#define FIX_PATT_REG (0x01 << 11)
+
+
+/* Timer 64 bit Regiser */
+#define SET_DELAY_LSB_REG (0x60 << 11) //96<<11 //0x68<<11
+#define SET_DELAY_MSB_REG (0x61 << 11) //97<<11 //0x69<<11
+#define SET_CYCLES_LSB_REG (0x62 << 11) //98<<11//0x6c<<11
+#define SET_CYCLES_MSB_REG (0x63 << 11) //99<<11//0x6d<<11
+#define SET_FRAMES_LSB_REG (0x64 << 11) //(100<<11)/** to hex */
+#define SET_FRAMES_MSB_REG (0x65 << 11) //101<<11//0x71<<11
+#define SET_PERIOD_LSB_REG (0x66 << 11) //102<<11//0x74<<11
+#define SET_PERIOD_MSB_REG (0x67 << 11) //103<<11//0x75<<11
+#define SET_GATES_LSB_REG (0x6A << 11) /*check in firmware*///106<<11//0x7c<<11
+#define SET_GATES_MSB_REG (0x6B << 11) //107<<11//0x7d<<11
+#define SET_EXPTIME_LSB_REG (0x72 << 11) /** check in firmware *///114<<11//0x78<<11
+#define SET_EXPTIME_MSB_REG (0x73 << 11) //115<<11//0x79<<11
+
+#define GET_ACTUAL_TIME_LSB_REG (0x10 << 11) //16<<11
+#define GET_ACTUAL_TIME_MSB_REG (0x11 << 11) //17<<11
+#define GET_DELAY_LSB_REG (0x12 << 11) //18<<11//0x6a<<11
+#define GET_DELAY_MSB_REG (0x13 << 11) //19<<11//0x6b<<11
+#define GET_CYCLES_LSB_REG (0x14 << 11) //20<<11//0x6e<<11
+#define GET_CYCLES_MSB_REG (0x15 << 11) //21<<11//0x6f<<11
+#define GET_FRAMES_LSB_REG (0x16 << 11) //22<<11//0x72<<11
+#define GET_FRAMES_MSB_REG (0x17 << 11) //23<<11//0x73<<11
+#define GET_PERIOD_LSB_REG (0x18 << 11) //24<<11//0x76<<11
+#define GET_PERIOD_MSB_REG (0x19 << 11) //25<<11//0x77<<11
+#define GET_EXPTIME_LSB_REG (0x1A << 11) //26<<11//0x7a<<11
+#define GET_EXPTIME_MSB_REG (0x1B << 11) //27<<11//0x7b<<11
+#define GET_GATES_LSB_REG (0x1C << 11) //28<<11//0x7e<<11
+#define GET_GATES_MSB_REG (0x1D << 11) //29<<11//0x7f<<11
+
+#define FRAMES_FROM_START_LSB_REG (0x22 << 11) //34<<11
+#define FRAMES_FROM_START_MSB_REG (0x23 << 11) //35<<11
+#define FRAMES_FROM_START_PG_LSB_REG (0x24 << 11) //36<<11
+#define FRAMES_FROM_START_PG_MSB_REG (0x25 << 11) //37<<11
+#define GET_MEASUREMENT_TIME_LSB_REG (0x26 << 11) //38<<11
+#define GET_MEASUREMENT_TIME_MSB_REG (0x27 << 11) //39<<11
+
+
+/* SPI (Serial Peripheral Interface) Register */
+#define SPI_REG (0x40 << 11)
+
+#define DAC_SERIAL_DIGITAL_OUT_OFST (0)
+#define DAC_SERIAL_DIGITAL_OUT_MSK (0x00000001 << DAC_SERIAL_DIGITAL_OUT_OFST)
+#define DAC_SERIAL_CLK_OUT_OFST (1)
+#define DAC_SERIAL_CLK_OUT_MSK (0x00000001 << DAC_SERIAL_CLK_OUT_OFST)
+#define DAC_SERIAL_CS_OUT_OFST (2)
+#define DAC_SERIAL_CS_OUT_MSK (0x00000001 << DAC_SERIAL_CS_OUT_OFST)
+#define HV_SERIAL_DIGITAL_OUT_OFST (8)
+#define HV_SERIAL_DIGITAL_OUT_MSK (0x00000001 << HV_SERIAL_DIGITAL_OUT_OFST)
+#define HV_SERIAL_CLK_OUT_OFST (9)
+#define HV_SERIAL_CLK_OUT_MSK (0x00000001 << HV_SERIAL_CLK_OUT_OFST)
+#define HV_SERIAL_CS_OUT_OFST (10)
+#define HV_SERIAL_CS_OUT_MSK (0x00000001 << HV_SERIAL_CS_OUT_OFST)
+
+/* Control Register */
+#define CONTROL_REG (0x4F << 11) //(79 << 11) /** to hex */
+
+
+/* Reconfiguratble PLL Control Regiser */
+#define PLL_CONTROL_REG (0x51 << 11) //(81 << 11)/** to hex */
+
+//#define PLL_CTRL_RECONFIG_RST_OFST (0) //parameter reset
+//#define PLL_CTRL_RECONFIG_RST_MSK (0x00000001 << PLL_CTRL_RECONFIG_RST_OFST) //parameter reset
+//#define PLL_CTRL_WR_PARAMETER_OFST (2)
+//#define PLL_CTRL_WR_PARAMETER_MSK (0x00000001 << PLL_CTRL_WR_PARAMETER_OFST)
+#define PLL_CTRL_RST_OFST (3)
+#define PLL_CTRL_RST_MSK (0x00000001 << PLL_CTRL_RST_OFST)
+//#define PLL_CTRL_ADDR_OFST (16)
+//#define PLL_CTRL_ADDR_MSK (0x0000003F << PLL_CTRL_ADDR_OFST)
+
+/* Samples Register */
+#define NSAMPLES_REG (0x5D << 11) //93<<11
+
+/* Power On Register */
+#define POWER_ON_REG (0x5e<<11)
+
+#define POWER_ENABLE_OFST (16)
+
+/* Dac Registers */
+#define DAC_VAL_REG (0x79 << 11) //121<<11
+#define DAC_NUM_REG (0x80 << 11) //122<<11
+#define DAC_VAL_OUT_REG (0x2A << 11) //42<<11
#endif
diff --git a/slsDetectorSoftware/mythen3DetectorServer/ansi.h b/slsDetectorSoftware/mythen3DetectorServer/ansi.h
new file mode 120000
index 000000000..a122db0ad
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/ansi.h
@@ -0,0 +1 @@
+../../slsReceiverSoftware/include/ansi.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/mythen3DetectorServer/blackfin.h b/slsDetectorSoftware/mythen3DetectorServer/blackfin.h
deleted file mode 100755
index 55b3a39b1..000000000
--- a/slsDetectorSoftware/mythen3DetectorServer/blackfin.h
+++ /dev/null
@@ -1,154 +0,0 @@
-#ifndef BLACKFIN_H
-#define BLACKFIN_H
-
-#include "ansi.h"
-
-#include
-#include // open
-#include // mmap
-
-
-/* global variables */
-u_int32_t CSP0BASE = 0;
-#define CSP0 0x20200000
-#define MEM_SIZE 0x100000
-
-
-
-/**
- * Write into a 16 bit register
- * @param offset address offset
- * @param data 16 bit data
- */
-void bus_w16(u_int32_t offset, u_int16_t data) {
- volatile u_int16_t *ptr1;
- ptr1=(u_int16_t*)(CSP0BASE+offset*2);
- *ptr1=data;
-}
-
-/**
- * Read from a 16 bit register
- * @param offset address offset
- * @retuns 16 bit data read
- */
-u_int16_t bus_r16(u_int32_t offset){
- volatile u_int16_t *ptr1;
- ptr1=(u_int16_t*)(CSP0BASE+offset*2);
- return *ptr1;
-}
-
-/**
- * Write into a 32 bit register
- * @param offset address offset
- * @param data 32 bit data
- */
-void bus_w(u_int32_t offset, u_int32_t data) {
- volatile u_int32_t *ptr1;
- ptr1=(u_int32_t*)(CSP0BASE+offset*2);
- *ptr1=data;
-}
-
-/**
- * Read from a 32 bit register
- * @param offset address offset
- * @retuns 32 bit data read
- */
-u_int32_t bus_r(u_int32_t offset) {
- volatile u_int32_t *ptr1;
- ptr1=(u_int32_t*)(CSP0BASE+offset*2);
- return *ptr1;
-}
-
-/**
- * Read from a 64 bit register
- * @param aLSB LSB offset address
- * @param aMSB MSB offset address
- * @returns 64 bit data read
- */
-int64_t get64BitReg(int aLSB, int aMSB){
- int64_t v64;
- u_int32_t vLSB,vMSB;
- vLSB=bus_r(aLSB);
- vMSB=bus_r(aMSB);
- v64=vMSB;
- v64=(v64<<32) | vLSB;
- printf(" reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, v64);
- return v64;
-}
-
-/**
- * Write into a 64 bit register
- * @param value 64 bit data
- * @param aLSB LSB offset address
- * @param aMSB MSB offset address
- * @returns 64 bit data read
- */
-int64_t set64BitReg(int64_t value, int aLSB, int aMSB){
- int64_t v64;
- u_int32_t vLSB,vMSB;
- if (value!=-1) {
- vLSB=value&(0xffffffff);
- bus_w(aLSB,vLSB);
- v64=value>> 32;
- vMSB=v64&(0xffffffff);
- bus_w(aMSB,vMSB);
- }
- return get64BitReg(aLSB, aMSB);
-
-}
-
-/**
- * Read from a 32 bit register (literal register value provided by client)
- * @param offset address offset
- * @retuns 32 bit data read
- */
-u_int32_t readRegister(u_int32_t offset) {
- return bus_r(offset << 11);
-}
-
-/**
- * Write into a 32 bit register (literal register value provided by client)
- * @param offset address offset
- * @param data 32 bit data
- */
-u_int32_t writeRegister(u_int32_t offset, u_int32_t data) {
- bus_w(offset << 11, data);
- return readRegister(offset);
-}
-
-
-/**
- * Map FPGA
- */
-int mapCSP0(void) {
- // if not mapped
- if (!CSP0BASE) {
- printf("Mapping memory\n");
-#ifdef VIRTUAL
- CSP0BASE = malloc(MEM_SIZE);
- printf("memory allocated\n");
-#else
- int fd;
- fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
- if (fd == -1) {
- cprintf(BG_RED, "Error: Can't find /dev/mem\n");
- return FAIL;
- }
-#ifdef VERBOSE
- printf("/dev/mem opened\n");
-#endif
- CSP0BASE = (u_int32_t)mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, CSP0);
- if (CSP0BASE == (u_int32_t)MAP_FAILED) {
- cprintf(BG_RED, "Error: Can't map memmory area\n");
- return FAIL;
- }
- printf("CSPOBASE mapped from %08x to %08x\n",CSP0BASE,CSP0BASE+MEM_SIZE);
-#endif
- printf("Status Register: %08x\n",bus_r(STATUS_REG));
- }else
- printf("Memory already mapped before\n");
- return OK;
-}
-
-
-#endif //BLACKFIN_H
diff --git a/slsDetectorSoftware/mythen3DetectorServer/blackfin.h b/slsDetectorSoftware/mythen3DetectorServer/blackfin.h
new file mode 120000
index 000000000..24f9c08f7
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/blackfin.h
@@ -0,0 +1 @@
+/afs/psi.ch/project/mythen/marie_a/MythenServer/slsDetectorPackage/slsDetectorSoftware/slsDetectorServer/blackfin.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h b/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h
deleted file mode 100755
index 4122fb7cf..000000000
--- a/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef COMMON_SERVER_FUNCTIONS_H
-#define COMMON_SERVER_FUNCTIONS_H
-
-#ifndef GOTTHARDD //gotthard already had bus_w etc defined in its firmware_funcs.c (not yet made with common files)
-#include "blackfin.h"
-#endif
-
-/* global variables */
-void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) {
-#ifdef VERBOSE
- if (numbitstosend == 16)
- printf("Writing to SPI Register: 0x%04x\n",val);
- else
- printf("Writing to SPI Register: 0x%08x\n", val);
-#endif
-
- u_int32_t valw;
-
- // start point
- valw = 0xffffffff; // old board compatibility (not using specific bits)
- bus_w (addr, valw);
-
- // chip sel bar down
- valw &= ~csmask; /* todo with test: done a bit different, not with previous value */
- bus_w (addr, valw);
-
- {
- int i = 0;
- for (i = 0; i < numbitstosend; ++i) {
-
- // clk down
- valw &= ~clkmask;
- bus_w (addr, valw);
-
- // write data (i)
- valw = ((valw & ~digoutmask) + // unset bit
- (((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb
- bus_w (addr, valw);
-
- // clk up
- valw |= clkmask ;
- bus_w (addr, valw);
- }
- }
-
- // chip sel bar up
- valw |= csmask; /* todo with test: not done for spi */
- bus_w (addr, valw);
-
- //clk down
- valw &= ~clkmask;
- bus_w (addr, valw);
-
- // stop point = start point of course
- valw = 0xffffffff; // old board compatibility (not using specific bits)
- bus_w (addr, valw);
-}
-
-
-#endif //COMMON_SERVER_FUNCTIONS_H
diff --git a/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h b/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h
new file mode 120000
index 000000000..33bdd8d53
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h
@@ -0,0 +1 @@
+../slsDetectorServer/commonServerFunctions.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.c b/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.c
deleted file mode 100755
index caa58a8c4..000000000
--- a/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.c
+++ /dev/null
@@ -1,690 +0,0 @@
-
-
-#include "communication_funcs.h"
-//#include
-#include /* for TCP_NODELAY */
-#include
-#include
-#include
-#include
-
-#include
-char lastClientIP[INET_ADDRSTRLEN];
-char thisClientIP[INET_ADDRSTRLEN];
-int lockStatus;
-int differentClients;
-
-//int socketDescriptor, file_des;
-const int send_rec_max_size=SEND_REC_MAX_SIZE;
-extern int errno;
-
-
-char dummyClientIP[INET_ADDRSTRLEN];
-
-
-fd_set readset, tempset;
-int isock=0, maxfd;
-
-
-int myport=-1;
-
-//struct sockaddr_in address;
-//#define VERBOSE
-
-
-int bindSocket(unsigned short int port_number) {
- int i;
-
- struct sockaddr_in addressS;
- int socketDescriptor;
- //int file_des;
-
- //file_des= -1;
-
-
-
-
-
-
-
-
-
-
- if (myport==port_number)
- return -10;
-
-
-
-
-
- socketDescriptor = socket(AF_INET, SOCK_STREAM,0); //tcp
-
- //socketDescriptor = socket(PF_INET, SOCK_STREAM, 0);
-
-
-
- if (socketDescriptor < 0) {
- printf("Can not create socket\n");
- } else {
-
- i = 1;
- setsockopt(socketDescriptor, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));
- // setsockopt(socketDescriptor, IPPROTO_TCP, TCP_NODELAY, (char *) &i, sizeof(i));
- // TCP_CORK
-
- // Set some fields in the serverAddress structure.
- addressS.sin_family = AF_INET;
- addressS.sin_addr.s_addr = htonl(INADDR_ANY);
- addressS.sin_port = htons(port_number);
-
- // memset(&address.sin_addr, 0, sizeof(address.sin_addr));
-
-
- if(bind(socketDescriptor,(struct sockaddr *) &addressS,sizeof(addressS))<0){
-
- printf("Can not create socket\n");
-
- socketDescriptor=-1;
- } else {
- if (listen(socketDescriptor, 5)==0) {
-
- if (isock==0) {
- FD_ZERO(&readset);
- }
-
-
- FD_SET(socketDescriptor, &readset);
- isock++;
- maxfd = socketDescriptor;
- printf ("%d port %d fd %d\n",isock, port_number,socketDescriptor);
- myport=port_number;
- } else
- printf("error on listen");
- }
- }
-
-
-
- //int getrlimit(int resource, struct rlimit *rlim);
-
-
-
- return socketDescriptor;
-
-}
-
-
-
-
-
-int getServerError(int socketDescriptor)
-{
- if (socketDescriptor<0) return 1;
- else return 0;
-};
-
-
-int acceptConnection(int socketDescriptor) {
-
-
- int j;
-
-
- struct sockaddr_in addressC;
- int file_des=-1;
- struct timeval tv;
- int result;
-
-
- //socklen_t address_length;
- socklen_t address_length=sizeof(struct sockaddr_in);
-
- if (socketDescriptor<0)
- return -1;
-
- memcpy(&tempset, &readset, sizeof(tempset));
- tv.tv_sec = 10000000;
- tv.tv_usec = 0;
- result = select(maxfd + 1, &tempset, NULL, NULL, &tv);
-
- if (result == 0) {
- printf("select() timed out!\n");
- } else if (result < 0 && errno != EINTR) {
- printf("Error in select(): %s\n", strerror(errno));
- } else if (result > 0) {
-#ifdef VERBOSE
- printf("select returned!\n");
-#endif
- for (j=0; j=0)
- close(file_des);
- FD_CLR(file_des, &readset);
-}
-
-void exitServer(int socketDescriptor) {
- if (socketDescriptor>=0)
- close(socketDescriptor);
-#ifdef VERY_VERBOSE
- printf("Closing server\n");
-#endif
- FD_CLR(socketDescriptor, &readset);
- socketDescriptor=-1;
- isock--;
-}
-
-
-
-
-void swapData(void* val,int length,intType itype){
- int i;
- int16_t* c= (int16_t*)val;
- int32_t* a= (int32_t*)val;
- int64_t* b= (int64_t*)val;
- for(i=0; length > 0; i++){
- switch(itype){
- case INT16:
- c[i] = ((c[i] & 0x00FF) << 8) | ((c[i] & 0xFF00) >> 8);
- length -= sizeof(int16_t);
- break;
- case INT32:
- a[i]=((a[i] << 8) & 0xFF00FF00) | ((a[i] >> 8) & 0xFF00FF );
- a[i]=(a[i] << 16) | ((a[i] >> 16) & 0xFFFF);
- length -= sizeof(int32_t);
- break;
- case INT64:
- b[i] = ((b[i] << 8) & 0xFF00FF00FF00FF00ULL ) | ((b[i] >> 8) & 0x00FF00FF00FF00FFULL );
- b[i] = ((b[i] << 16) & 0xFFFF0000FFFF0000ULL ) | ((b[i] >> 16) & 0x0000FFFF0000FFFFULL );
- b[i] = (b[i] << 32) | ((b[i] >> 32) & 0xFFFFFFFFULL);
- length -= sizeof(int64_t);
- break;
- default:
- length = 0;
- break;
- }
- }
-}
-
-int sendData(int file_des, void* buf,int length, intType itype){
-#ifndef PCCOMPILE
-#ifdef EIGERD
- swapData(buf, length, itype);
-#endif
-#endif
- return sendDataOnly(file_des, buf, length);
-}
-
-
-int receiveData(int file_des, void* buf,int length, intType itype){
- int ret = receiveDataOnly(file_des, buf, length);
-#ifndef PCCOMPILE
-#ifdef EIGERD
- if (ret >= 0) swapData(buf, length, itype);
-#endif
-#endif
- return ret;
-}
-
-
- int sendDataOnly(int file_des, void* buf,int length) {
- int ret = write(file_des, buf, length); //value of -1 is other end socket crash as sigpipe is ignored
- if (ret < 0) cprintf(BG_RED, "Error writing to socket. Possible socket crash\n");
- return ret;
-}
-
-
- int receiveDataOnly(int file_des, void* buf,int length) {
-
- int total_received=0;
- int nreceiving;
- int nreceived;
- if (file_des<0) return -1;
-#ifdef VERY_VERBOSE
- printf("want to receive %d Bytes\n", length);
-#endif
-
- while(length > 0) {
- nreceiving = (length>send_rec_max_size) ? send_rec_max_size:length;
- nreceived = read(file_des,(char*)buf+total_received,nreceiving);
- if(!nreceived){
- if(!total_received) {
- return -1; //to handle it
- }
- break;
- }
- length-=nreceived;
- total_received+=nreceived;
- }
-
- if (total_received>0)
- strcpy(thisClientIP,dummyClientIP);
-
- if (strcmp(lastClientIP,thisClientIP))
- differentClients=1;
- else
- differentClients=0;
-
- return total_received;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-int sendChannel(int file_des, sls_detector_channel *myChan) {
- int ts=0;
- //sendDataOnly(file_des,myChan, sizeof(sls_detector_channel));
- ts+=sendData(file_des,&(myChan->chan),sizeof(myChan->chan),INT32);
- ts+=sendData(file_des,&(myChan->chip),sizeof(myChan->chip),INT32);
- ts+=sendData(file_des,&(myChan->module),sizeof(myChan->module),INT32);
- ts+=sendData(file_des,&(myChan->reg),sizeof(myChan->reg),INT64);
- return ts;
-}
-
-int sendChip(int file_des, sls_detector_chip *myChip) {
- int ts=0;
- //ts+=sendDataOnly(file_des,myChip,sizeof(sls_detector_chip));
- ts+=sendData(file_des,&(myChip->chip),sizeof(myChip->chip),INT32);
- ts+=sendData(file_des,&(myChip->module),sizeof(myChip->module),INT32);
- ts+=sendData(file_des,&(myChip->nchan),sizeof(myChip->nchan),INT32);
- ts+=sendData(file_des,&(myChip->reg),sizeof(myChip->reg),INT32);
- ts+=sendData(file_des,(myChip->chanregs),sizeof(myChip->chanregs),INT32);
- ts+=sendData(file_des,myChip->chanregs,myChip->nchan*sizeof(int),INT32);
- return ts;
-}
-
-
-int sendModule(int file_des, sls_detector_module *myMod) {
- return sendModuleGeneral(file_des, myMod, 1);
-}
-
-
-int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) {
- int ts=0;
-#ifdef VERBOSE
- int idac;
-#endif
- int nChips=myMod->nchip;
- int nChans=myMod->nchan;
- int nAdcs=myMod->nadc;
- int nDacs=myMod->ndac;
- //ts+= sendDataOnly(file_des,myMod,sizeof(sls_detector_module));
- ts+=sendData(file_des,&(myMod->module),sizeof(myMod->module),INT32);
- ts+=sendData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32);
- ts+=sendData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32);
- ts+=sendData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32);
- ts+=sendData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32);
- ts+=sendData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32);
- ts+=sendData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32);
- ts+=sendData(file_des,myMod->dacs,sizeof(myMod->ndac),OTHER);
- if(sendAll){
- ts+=sendData(file_des,myMod->adcs,sizeof(myMod->nadc),OTHER);
- }else{
- uint32_t k = 0;
- ts+=sendData(file_des,&k,sizeof(k),OTHER);
- }
-
- /*some detectors dont require sending all trimbits etc.*/
- if(sendAll){
- ts+=sendData(file_des,myMod->chipregs,sizeof(myMod->nchip),OTHER);
- ts+=sendData(file_des,myMod->chanregs,sizeof(myMod->nchan),OTHER);
- }
- ts+=sendData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER);
- ts+=sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER);
-
-#ifdef VERBOSE
- printf("module %d of size %d sent\n",myMod->module, ts);
-#endif
- ts+= sendData(file_des,myMod->dacs,sizeof(dacs_t)*nDacs,INT32);
-#ifdef VERBOSE
- printf("dacs %d of size %d sent\n",myMod->module, ts);
- for (idac=0; idac< nDacs; idac++)
- printf("dac %d is %d\n",idac,(int)myMod->dacs[idac]);
-#endif
- if(sendAll)
- ts+= sendData(file_des,myMod->adcs,sizeof(dacs_t)*nAdcs,INT32);
- else {
- uint32_t k = 0;
- ts+= sendData(file_des,&k,sizeof(k),INT32);
- }
-
-#ifdef VERBOSE
- printf("adcs %d of size %d sent\n",myMod->module, ts);
-#endif
-
- /*some detectors dont require sending all trimbits etc.*/
- if(sendAll){
- ts+=sendData(file_des,myMod->chipregs,sizeof(int)*nChips,INT32);
-#ifdef VERBOSE
- printf("chips %d of size %d sent\n",myMod->module, ts);
-#endif
- ts+=sendData(file_des,myMod->chanregs,sizeof(int)*nChans,INT32);
-#ifdef VERBOSE
- printf("chans %d of size %d sent - %d\n",myMod->module, ts, myMod->nchan);
-#endif
- }
-
-#ifdef VERBOSE
- printf("module %d of size %d sent register %x\n",myMod->module, ts, myMod->reg);
-#endif
- return ts;
-}
-
-int receiveChannel(int file_des, sls_detector_channel *myChan) {
- int ts=0;
- //receiveDataOnly(file_des,myChan,sizeof(sls_detector_channel));
- ts+=receiveData(file_des,&(myChan->chan),sizeof(myChan->chan),INT32);
- ts+=receiveData(file_des,&(myChan->chip),sizeof(myChan->chip),INT32);
- ts+=receiveData(file_des,&(myChan->module),sizeof(myChan->module),INT32);
- ts+=receiveData(file_des,&(myChan->reg),sizeof(myChan->reg),INT32);
- return ts;
-}
-
-int receiveChip(int file_des, sls_detector_chip* myChip) {
-
- int *ptr=myChip->chanregs;
- int ts=0;
- int nChans, nchanold=myChip->nchan, chdiff;
-
- //ts+= receiveDataOnly(file_des,myChip,sizeof(sls_detector_chip));
- ts+=receiveData(file_des,&(myChip->chip),sizeof(myChip->chip),INT32);
- ts+=receiveData(file_des,&(myChip->module),sizeof(myChip->module),INT32);
- ts+=receiveData(file_des,&(myChip->nchan),sizeof(myChip->nchan),INT32);
- ts+=receiveData(file_des,&(myChip->reg),sizeof(myChip->reg),INT32);
- ts+=receiveData(file_des,(myChip->chanregs),sizeof(myChip->chanregs),INT32);
-
- myChip->chanregs=ptr;
- nChans=myChip->nchan;
- chdiff=nChans-nchanold;
- if (nchanold!=nChans) {
- printf("wrong number of channels received!\n");
- }
-
-
-#ifdef VERBOSE
- printf("chip structure received\n");
- printf("now receiving %d channels\n", nChans);
-#endif
-
- if (chdiff<=0)
- ts+=receiveData(file_des,myChip->chanregs, sizeof(int)*nChans,INT32);
- else {
- ptr=(int*)malloc(chdiff*sizeof(int));
- myChip->nchan=nchanold;
- ts+=receiveData(file_des,myChip->chanregs, sizeof(int)*nchanold,INT32);
- ts+=receiveData(file_des,ptr, sizeof(int)*chdiff,INT32);
- free(ptr);
- return FAIL;
- }
-
-#ifdef VERBOSE
- printf("chip's channels received\n");
-#endif
- return ts;
-}
-
-
-int receiveModule(int file_des, sls_detector_module* myMod) {
- return receiveModuleGeneral(file_des,myMod,1);
-}
-
-int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll) {
- int ts=0;
- dacs_t *dacptr=myMod->dacs;
- dacs_t *adcptr=myMod->adcs;
- int *chipptr=myMod->chipregs, *chanptr=myMod->chanregs;
- int nChips, nchipold=myMod->nchip, nchipdiff;
- int nChans, nchanold=myMod->nchan, nchandiff;
- int nDacs, ndold=myMod->ndac, ndacdiff;
- int nAdcs, naold=myMod->nadc, nadcdiff;
-#ifdef VERBOSE
- int id=0;
-#endif
- // ts+= receiveDataOnly(file_des,myMod,sizeof(sls_detector_module));
- ts+=receiveData(file_des,&(myMod->module),sizeof(myMod->module),INT32);
- ts+=receiveData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32);
- ts+=receiveData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32);
- ts+=receiveData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32);
- ts+=receiveData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32);
- ts+=receiveData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32);
- ts+=receiveData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32);
- ts+=receiveData(file_des,myMod->dacs,sizeof(myMod->ndac),INT32);
- if(receiveAll){ // temporary fix
- ts+=receiveData(file_des,myMod->adcs,sizeof(myMod->nadc),INT32);
- }else {
- uint32_t k;ts+=receiveData(file_des,&k,sizeof(k),INT32);//nadc is 0
- }
-
- /*some detectors dont require sending all trimbits etc.*/
- if(receiveAll){
- ts+=receiveData(file_des,myMod->chipregs,sizeof(myMod->nchip),INT32);
- ts+=receiveData(file_des,myMod->chanregs,sizeof(myMod->nchan),INT32);
- }
- ts+=receiveData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER);
- ts+=receiveData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER);
-
- myMod->dacs=dacptr;
- myMod->adcs=adcptr;
- myMod->chipregs=chipptr;
- myMod->chanregs=chanptr;
-
-#ifdef EIGERD
- //feature to exclude sending of trimbtis, nchips=0,nchans=0 in that case
- if(myMod->nchip == 0 && myMod->nchan == 0) {
- receiveAll=0;
- nchipold=0;
- nchanold=0;
- }
-#endif
-
-
- nChips=myMod->nchip;
- nchipdiff=nChips-nchipold;
- if (nchipold!=nChips) {
- printf("received wrong number of chips\n");
- }
-#ifdef VERBOSE
- else
- printf("received %d chips\n",nChips);
-#endif
-
- nChans=myMod->nchan;
- nchandiff=nChans-nchanold;
- if (nchanold!=nChans) {
- printf("received wrong number of channels\n");
- }
-#ifdef VERBOSE
- else
- printf("received %d chans\n",nChans);
-#endif
-
-
- nDacs=myMod->ndac;
- ndacdiff=nDacs-ndold;
- if (ndold!=nDacs) {
- printf("received wrong number of dacs\n");
- }
-#ifdef VERBOSE
- else
- printf("received %d dacs\n",nDacs);
-#endif
-
- nAdcs=myMod->nadc;
- nadcdiff=nAdcs-naold;
- if (naold!=nAdcs) {
- printf("received wrong number of adcs\n");
- }
-#ifdef VERBOSE
- else
- printf("received %d adcs\n",nAdcs);
-#endif
- if (ndacdiff<=0) {
- ts+=receiveData(file_des,myMod->dacs, sizeof(dacs_t)*nDacs,INT32);
-#ifdef VERBOSE
- printf("dacs received\n");
- int id;
- for (id=0; iddacs[id]);
-
-
-#endif
- } else {
- dacptr=(dacs_t*)malloc(ndacdiff*sizeof(dacs_t));
- myMod->ndac=ndold;
- ts+=receiveData(file_des,myMod->dacs, sizeof(dacs_t)*ndold,INT32);
- ts+=receiveData(file_des,dacptr, sizeof(dacs_t)*ndacdiff,INT32);
- free(dacptr);
- return FAIL;
- }
-
- if (nadcdiff<=0) {
- ts+=receiveData(file_des,myMod->adcs, sizeof(dacs_t)*nAdcs,INT32);
-#ifdef VERBOSE
- printf("adcs received\n");
-#endif
- } else {
- adcptr=(dacs_t*)malloc(nadcdiff*sizeof(dacs_t));
- myMod->nadc=naold;
- ts+=receiveData(file_des,myMod->adcs, sizeof(dacs_t)*naold,INT32);
- ts+=receiveData(file_des,adcptr, sizeof(dacs_t)*nadcdiff,INT32);
- free(adcptr);
- return FAIL;
- }
-
-
- /*some detectors dont require sending all trimbits etc.*/
- if(receiveAll){
-
- if (nchipdiff<=0) {
- ts+=receiveData(file_des,myMod->chipregs, sizeof(int)*nChips,INT32);
-#ifdef VERBOSE
- printf("chips received\n");
-#endif
- } else {
- chipptr=(int*)malloc(nchipdiff*sizeof(int));
- myMod->nchip=nchipold;
- ts+=receiveData(file_des,myMod->chipregs, sizeof(int)*nchipold,INT32);
- ts+=receiveData(file_des,chipptr, sizeof(int)*nchipdiff,INT32);
- free(chipptr);
- return FAIL;
- }
-
- if (nchandiff<=0) {
- ts+=receiveData(file_des,myMod->chanregs, sizeof(int)*nChans,INT32);
-#ifdef VERBOSE
- printf("chans received\n");
-#endif
- } else {
- chanptr=(int*)malloc(nchandiff*sizeof(int));
- myMod->nchan=nchanold;
- ts+=receiveData(file_des,myMod->chanregs, sizeof(int)*nchanold,INT32);
- ts+=receiveData(file_des,chanptr, sizeof(int)*nchandiff,INT32);
- free(chanptr);
- return FAIL;
- }
- }
-#ifdef VERBOSE
- printf("received module %d of size %d register %x\n",myMod->module,ts,myMod->reg);
-#endif
-
- return ts;
-}
diff --git a/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.c b/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.c
new file mode 120000
index 000000000..87a4f95d1
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.c
@@ -0,0 +1 @@
+../commonFiles/communication_funcs.c
\ No newline at end of file
diff --git a/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.h b/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.h
deleted file mode 100755
index e4e3fac27..000000000
--- a/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef COMMUNICATION_FUNCS_H
-#define COMMUNICATION_FUNCS_H
-
-#define SEND_REC_MAX_SIZE 4096
-#define DEFAULT_PORTNO 1952
-#include
-#include
-
-
-#include
-#include
-#include
-#include
-
-#include "sls_detector_defs.h"
-
-
-
-typedef enum{
- INT16,
- INT32,
- INT64,
- OTHER
-}intType;
-
-
-
-
-int bindSocket(unsigned short int port_number);
-int acceptConnection(int socketDescriptor);
-void closeConnection(int file_Des);
-void exitServer(int socketDescriptor);
-
-void swapData(void* val,int length,intType itype);
-int sendData(int file_des, void* buf,int length, intType itype);
-int receiveData(int file_des, void* buf,int length, intType itype);
-int sendDataOnly(int file_des, void* buf,int length);
-int receiveDataOnly(int file_des, void* buf,int length);
-
-
-int getServerError(int socketDescriptor);
-int sendChannel(int file_des, sls_detector_channel *myChan);
-int sendChip(int file_des, sls_detector_chip *myChip);
-int sendModule(int file_des, sls_detector_module *myMod);
-int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll);
-int receiveChannel(int file_des, sls_detector_channel *myChan);
-int receiveChip(int file_des, sls_detector_chip* myChip);
-int receiveModule(int file_des, sls_detector_module* myMod);
-int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll);
-
-#endif
diff --git a/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.h b/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.h
new file mode 120000
index 000000000..f220903b2
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.h
@@ -0,0 +1 @@
+../commonFiles/communication_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/mythen3DetectorServer/gitInfo.txt b/slsDetectorSoftware/mythen3DetectorServer/gitInfo.txt
new file mode 100644
index 000000000..4df512cd8
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/gitInfo.txt
@@ -0,0 +1,9 @@
+Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer
+URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
+Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
+Repsitory UUID: 2f3dc8d109de8607f3217cf429619073dc9cc60e
+Revision: 103
+Branch: developer
+Last Changed Author: Dhanya_Maliakal
+Last Changed Rev: 3397
+Last Changed Date: 2017-12-04 18:23:05.000000002 +0100 ./RegisterDefs.h
diff --git a/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3.h b/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3.h
new file mode 100644
index 000000000..1acd1f071
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3.h
@@ -0,0 +1,6 @@
+#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git"
+#define GITREPUUID "2f3dc8d109de8607f3217cf429619073dc9cc60e"
+#define GITAUTH "Dhanya_Maliakal"
+#define GITREV 0x3397
+#define GITDATE 0x20171204
+#define GITBRANCH "developer"
diff --git a/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3Tmp.h b/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3Tmp.h
new file mode 100644
index 000000000..dfd9bb246
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3Tmp.h
@@ -0,0 +1,6 @@
+#define GITURL ""
+#define GITREPUUID ""
+#define GITAUTH ""
+#define GITREV ""
+#define GITDATE ""
+#define GITBRANCH ""
diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server
new file mode 100755
index 000000000..2f0fcf0df
Binary files /dev/null and b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server differ
diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server.gdb b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server.gdb
new file mode 100755
index 000000000..4d4b23a68
Binary files /dev/null and b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server.gdb differ
diff --git a/slsDetectorSoftware/mythen3DetectorServer/programfpga.h b/slsDetectorSoftware/mythen3DetectorServer/programfpga.h
deleted file mode 100755
index db7b1cfb8..000000000
--- a/slsDetectorSoftware/mythen3DetectorServer/programfpga.h
+++ /dev/null
@@ -1,178 +0,0 @@
-#ifndef PROGRAM_FPGA_H
-#define PROGRAM_FPGA_H
-
-#include "ansi.h"
-
-#include
-#include // usleep
-#include
-
-
-/* global variables */
-#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
-int gpioDefined=0;
-char mtdvalue[10];
-
-
-
-/**
- * Define GPIO pins if not defined
- */
-void defineGPIOpins(){
- if (!gpioDefined) {
- //define the gpio pins
- system("echo 7 > /sys/class/gpio/export");
- system("echo 9 > /sys/class/gpio/export");
- //define their direction
- system("echo in > /sys/class/gpio/gpio7/direction");
- system("echo out > /sys/class/gpio/gpio9/direction");
- printf("gpio pins defined\n");
- gpioDefined = 1;
- }else printf("gpio pins already defined earlier\n");
-}
-
-/**
- * Notify FPGA to not touch flash
- */
-void FPGAdontTouchFlash(){
- //tell FPGA to not touch flash
- system("echo 0 > /sys/class/gpio/gpio9/value");
- //usleep(100*1000);
-}
-
-
-/**
- * Notify FPGA to program from flash
- */
-void FPGATouchFlash(){
- //tell FPGA to touch flash to program itself
- system("echo 1 > /sys/class/gpio/gpio9/value");
-}
-
-/**
- * Reset FPGA
- */
-void resetFPGA(){
- cprintf(BLUE,"\n*** Reseting FPGA ***\n");
- FPGAdontTouchFlash();
- FPGATouchFlash();
- usleep(CTRL_SRVR_INIT_TIME_US);
-}
-
-/**
- * Erasing flash
- */
-void eraseFlash(){
-#ifdef VERY_VERBOSE
- printf("\nErasing Flash\n");
-#endif
- char command[255];
- sprintf(command,"flash_eraseall %s",mtdvalue);
- system(command);
- printf("flash erased\n");
-}
-
-/**
- * Open the drive to copy program and
- * notify FPGA not to touch the program
- * @param filefp pointer to flash
- * @return 0 for success, 1 for fail (cannot open file for writing program)
- */
-int startWritingFPGAprogram(FILE** filefp){
-#ifdef VERY_VERBOSE
- printf("\nStart Writing of FPGA program\n");
-#endif
-
- //getting the drive
- char output[255];
- FILE* fp = popen("awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd", "r");
- fgets(output, sizeof(output), fp);
- pclose(fp);
- strcpy(mtdvalue,"/dev/");
- char* pch = strtok(output,":");
- if(pch == NULL){
- cprintf(RED,"Could not get mtd value\n");
- return FAIL;
- }
- strcat(mtdvalue,pch);
- printf ("\nFlash drive found: %s\n",mtdvalue);
-
- FPGAdontTouchFlash();
-
- //writing the program to flash
- *filefp = fopen(mtdvalue, "w");
- if(*filefp == NULL){
- cprintf(RED,"Unable to open %s in write mode\n",mtdvalue);
- return 1;
- }
- printf("flash ready for writing\n");
-
- return 0;
-}
-
-/**
- * When done writing the program, close file pointer and
- * notify FPGA to pick up the program from flash
- * @param filefp pointer to flash
- */
-void stopWritingFPGAprogram(FILE* filefp){
-#ifdef VERY_VERBOSE
- printf("\nStopping of writing FPGA program\n");
-#endif
-
- int wait = 0;
- if(filefp!= NULL){
- fclose(filefp);
- wait = 1;
- }
-
- //touch and program
- FPGATouchFlash();
-
- if(wait){
-#ifdef VERY_VERBOSE
- printf("Waiting for FPGA to program from flash\n");
-#endif
- //waiting for success or done
- char output[255];
- int res=0;
- while(res == 0){
- FILE* sysFile = popen("cat /sys/class/gpio/gpio7/value", "r");
- fgets(output, sizeof(output), sysFile);
- pclose(sysFile);
- sscanf(output,"%d",&res);
-#ifdef VERY_VERBOSE
- printf("gpi07 returned %d\n",res);
-#endif
- }
- }
- printf("FPGA has picked up the program from flash\n\n");
-}
-
-
-/**
- * Write FPGA Program to flash
- * @param fpgasrc source program
- * @param fsize size of program
- * @param filefp pointer to flash
- * @return 0 for success, 1 for fail (cannot write)
- */
-int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp){
-#ifdef VERY_VERBOSE
- printf("\nWriting of FPGA Program\n");
- cprintf(BLUE,"address of fpgasrc:%p\n",(void *)fpgasrc);
- cprintf(BLUE,"fsize:%d\n",fsize);
- cprintf(BLUE,"pointer:%p\n",(void*)filefp);
-#endif
-
- if(fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp )!= fsize){
- cprintf(RED,"Could not write FPGA source to flash\n");
- return 1;
- }
-#ifdef VERY_VERBOSE
- cprintf(BLUE, "program written to flash\n");
-#endif
- return 0;
-}
-
-#endif //PROGRAM_FPGA_H
diff --git a/slsDetectorSoftware/mythen3DetectorServer/programfpga.h b/slsDetectorSoftware/mythen3DetectorServer/programfpga.h
new file mode 120000
index 000000000..72c54d21d
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/programfpga.h
@@ -0,0 +1 @@
+../slsDetectorServer/programfpga.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.c
index df40eabff..b31416c6a 100644
--- a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.c
@@ -1,1196 +1,1304 @@
-#ifdef SLS_DETECTOR_FUNCTION_LIST
+//#ifdef SLS_DETECTOR_FUNCTION_LIST
+
#include "slsDetectorFunctionList.h"
-#include "slsDetectorServer_defs.h"
-
-#include
-#include
+#include "gitInfoMythen3.h"
-const int nChans=NCHAN;
-const int nChips=NCHIP;
-const int nDacs=NDAC;
-const int nAdcs=NADC;
-const int allSelected=-2;
-const int noneSelected=-1;
+#include "AD9257.h" // include "commonServerFunctions.h", which in turn includes "blackfin.h"
+#include "programfpga.h"
+#include "RegisterDefs.h"
+/* global variables */
sls_detector_module *detectorModules=NULL;
int *detectorChips=NULL;
int *detectorChans=NULL;
dacs_t *detectorDacs=NULL;
dacs_t *detectorAdcs=NULL;
-int nModY = NMAXMOD;
-int nModX = NMAXMOD;
-int dynamicRange= DYNAMIC_RANGE;
-int dataBytes = NMAXMOD*NCHIP*NCHAN*2;
-int masterMode = NO_MASTER;
-int syncMode = NO_SYNCHRONIZATION;
-int timingMode = AUTO_TIMING;
-
-
-
enum detectorSettings thisSettings;
-int sChan, sChip, sMod, sDac, sAdc;
-int nModBoard;
-extern int dataBytes;
+enum masterFlags masterMode = NO_MASTER;
+int32_t clkPhase[2] = {0, 0};
+int vlimit = -1;
-int initializeDetectorStructure(){
- int imod;
- int n=getNModBoard(X)*getNModBoard(Y);
-#ifdef VERBOSE
- printf("Board is for %d modules\n",n);
-#endif
- detectorModules=malloc(n*sizeof(sls_detector_module));
- detectorChips=malloc(n*NCHIP*sizeof(int));
- detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int));
- detectorDacs=malloc(n*NDAC*sizeof(int));
- detectorAdcs=malloc(n*NADC*sizeof(int));
-#ifdef VERBOSE
- printf("modules from 0x%x to 0x%x\n",(unsigned int)(detectorModules), (unsigned int)(detectorModules+n));
- printf("chips from 0x%x to 0x%x\n",(unsigned int)(detectorChips), (unsigned int)(detectorChips+n*NCHIP));
- printf("chans from 0x%x to 0x%x\n",(unsigned int)(detectorChans), (unsigned int)(detectorChans+n*NCHIP*NCHAN));
- printf("dacs from 0x%x to 0x%x\n",(unsigned int)(detectorDacs), (unsigned int)(detectorDacs+n*NDAC));
- printf("adcs from 0x%x to 0x%x\n",(unsigned int)(detectorAdcs), (unsigned int)(detectorAdcs+n*NADC));
-#endif
- for (imod=0; imoddacs=detectorDacs+imod*NDAC;
- (detectorModules+imod)->adcs=detectorAdcs+imod*NADC;
- (detectorModules+imod)->chipregs=detectorChips+imod*NCHIP;
- (detectorModules+imod)->chanregs=detectorChans+imod*NCHIP*NCHAN;
- (detectorModules+imod)->ndac=NDAC;
- (detectorModules+imod)->nadc=NADC;
- (detectorModules+imod)->nchip=NCHIP;
- (detectorModules+imod)->nchan=NCHIP*NCHAN;
- (detectorModules+imod)->module=imod;
- (detectorModules+imod)->gain=0;
- (detectorModules+imod)->offset=0;
- (detectorModules+imod)->reg=0;
- /* initialize registers, dacs, retrieve sn, adc values etc */
- }
- thisSettings=UNINITIALIZED;
- sChan=noneSelected;
- sChip=noneSelected;
- sMod=noneSelected;
- sDac=noneSelected;
- sAdc=noneSelected;
+/* basic tests */
- return OK;
+void checkFirmwareCompatibility(int flag) {
+
+ defineGPIOpins();
+ resetFPGA();
+ if (mapCSP0() == FAIL) {
+ cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ // does check only if flag is 0 (by default), set by command line
+ if ((!flag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) {
+ cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ uint32_t ipadd = getDetectorIP();
+ uint64_t macadd = getDetectorMAC();
+ int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
+ int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION);
+ //int64_t sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION);
+ cprintf(BLUE,"\n\n"
+ "********************************************************\n"
+ "****************** Mythen3 Server *********************\n"
+ "********************************************************\n\n"
+
+ "Detector IP Addr:\t\t 0x%x\n"
+ "Detector MAC Addr:\t\t 0x%llx\n"
+
+ "Firmware Version:\t\t 0x%llx\n"
+ "Software Version:\t\t 0x%llx\n"
+ //"F/w-S/w API Version:\t\t 0x%llx\n"
+ //"Required Firmware Version:\t 0x%x\n"
+ "\n"
+ "********************************************************\n",
+ hversion, hsnumber,
+ ipadd, macadd,
+ fwversion, swversion
+ //, sw_fw_apiversion, REQUIRED_FIRMWARE_VERSION
+ );
+
+
+/*
+ * printf("Testing firmware capability... ");
+ //cant read versions
+ if(!fwversion || !sw_fw_apiversion){
+ cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n");
+ cprintf(RED,"Exiting Server. Goodbye!\n\n");
+ exit(-1);
+ }
+
+ //check for API compatibility - old server
+ if(sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION){
+ cprintf(RED,"FATAL ERROR: This software version is incompatible.\n"
+ "Please update it to be compatible with this firmware\n\n");
+ cprintf(RED,"Exiting Server. Goodbye!\n\n");
+ exit(-1);
+ }
+
+ //check for firmware compatibility - old firmware
+ if( REQUIRED_FIRMWARE_VERSION > fwversion){
+ cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n"
+ "Please update it to v%d to be compatible with this server\n\n", REQUIRED_FIRMWARE_VERSION);
+ cprintf(RED,"Exiting Server. Goodbye!\n\n");
+ exit(-1);
+ }
+*/
+}
+
+
+int checkType() {
+ volatile u_int32_t type = ((bus_r(FPGA_VERSION_REG) & DETECTOR_TYPE_MSK) >> DETECTOR_TYPE_OFST);
+ if (type != JUNGFRAUCTB){
+ cprintf(BG_RED,"This is not a Mythen 3 Server (read %d, expected %d)\n",type, JUNGFRAUCTB);
+ return FAIL;
+ }
+
+ return OK;
}
+u_int32_t testFpga(void) {
+ printf("\nTesting FPGA...\n");
-
-
-int setupDetector(){
- //testFpga();
- //testRAM();
-
- //setSettings(GET_SETTINGS,-1);
- //setFrames(1);
- //setTrains(1);
- //setExposureTime(1e6);
- //setPeriod(1e9);
- //setDelay(0);
- //setGates(0);
-
- //setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
- //setMaster(GET_MASTER);
- //setSynchronization(GET_SYNCHRONIZATION_MODE);
- return OK;
+ //fixed pattern
+ int ret = OK;
+ volatile u_int32_t val = bus_r(FIX_PATT_REG);
+ if (val == FIX_PATT_VAL) {
+ printf("Fixed pattern: successful match 0x%08x\n",val);
+ } else {
+ cprintf(RED,"Fixed pattern does not match! Read 0x%08x, expected 0x%08x\n", val, FIX_PATT_VAL);
+ ret = FAIL;
+ }
+ return ret;
}
+int testBus() {
+ printf("\nTesting Bus...\n");
+ int ret = OK;
+ u_int32_t addr = SET_DELAY_LSB_REG;
+ int times = 1000 * 1000;
+ int i = 0;
-int setNMod(int nm, enum dimension dim){
- return 1;
+ for (i = 0; i < times; ++i) {
+ bus_w(addr, i * 100);
+ if (i * 100 != bus_r(SET_DELAY_LSB_REG)) {
+ cprintf(RED,"ERROR: Mismatch! Wrote 0x%x, read 0x%x\n", i * 100, bus_r(SET_DELAY_LSB_REG));
+ ret = FAIL;
+ }
+ }
+
+ if (ret == OK)
+ printf("Successfully tested bus %d times\n", times);
+ return ret;
}
-int getNModBoard(enum dimension arg){
- return 1;
-}
-
-
-
-
-
-
-
-
-int64_t getModuleId(enum idMode arg, int imod){
- //DETECTOR_SERIAL_NUMBER
- //DETECTOR_FIRMWARE_VERSION
- return 0;
-}
-
-
-
-
-int64_t getDetectorId(enum idMode arg){
- //DETECTOR_SOFTWARE_VERSION defined in slsDetector_defs.h?
- return 0;
-}
-
-
-
-
-
-int moduleTest( enum digitalTestMode arg, int imod){
- //template testShiftIn from mcb_funcs.c
-
- //CHIP_TEST
- //testShiftIn
- //testShiftOut
- //testShiftStSel
- //testDataInOutMux
- //testExtPulseMux
- //testOutMux
- //testFpgaMux
-
- return OK;
-}
-
-
-
-
int detectorTest( enum digitalTestMode arg){
- //templates from firmware_funcs.c
-
- //DETECTOR_FIRMWARE_TEST:testFpga()
- //DETECTOR_MEMORY_TEST:testRAM()
- //DETECTOR_BUS_TEST:testBus()
- //DETECTOR_SOFTWARE_TEST:testFpga()
- return OK;
-}
-
-
-
-int setDacRegister(int dacnum,int dacvalue) {
-
- bus_w(DAC_NUM_REG, dacnum);
- bus_w(DAC_VAL_REG, dacvalue);
- bus_w(DAC_NUM_REG, dacnum | (1<<16));
- bus_w(DAC_NUM_REG, dacnum);
- printf("Wrote dac register value %d address %d\n",bus_r(DAC_VAL_REG),bus_r(DAC_NUM_REG)) ;
- return getDacRegister(dacnum);
-}
-
-
-
-int getDacRegister(int dacnum) {
-
- bus_w(DAC_NUM_REG, dacnum);
- printf("READ dac register value %d address %d\n",(int16_t)bus_r(DAC_VAL_OUT_REG),bus_r(DAC_NUM_REG)) ;
- return (int16_t)bus_r(DAC_VAL_OUT_REG);
-}
-
-
-
-int nextDac(){
- return dacSPI(0xf<=0) {
- cmd=0x3;
- }
- else if (dacvalue==-100) {
- cmd=0x4;
- }
- codata=cmd< conversion done in slsDetectorServer_funcs.c-> set_dac()
-
- //if normal dac:
-
- int dacval = val; // in DAC
- u_int32_t offw;
- u_int32_t ichip; // DAC-chip (3 chips with each 8 DACs)
- u_int16_t valw;
- int i,ddx,csdx,cdx; // ddx=data, cdx=clk, csdx=chipselect
-
- //select dac-chip:
- if (myDetectorType==JUNGFRAUCTB)
- ichip=2-ind/8;
- printf("This is a CTB\n");
- else
- ichip=ind/8;
- printf("This is not a CTB\n");
-
- // if(val>0 && mV){ // convert to DACu, if val is given in mV
- // dacval = val * 4095 / 2500; // convert to DAC
- if(dacval<0 || dacval>4095){
- dacval = -1;
- printf("The DAC is out of range! Error!");
- return -1;
- }
- // }
-
- else if(dacval>=0 && dacval<=4095){
- printf("Setting of DAC %d to %d DACunits",ind,dacval);
- ddx=0; // data is first bit in DAC_REG
- cdx=1; // clk is 2nd bit in DAC_REG
- if (myDetectorType==JUNGFRAUCTB)
- csdx=2;
- else
- csdx=ichip+2;
-
- //setting int reference
- offw=DAC_REG;
- valw=bus_r(offw)|0xff; // alles (ddx,cdx,csdx) auf 1 setzen (for START)
- bus_w(offw,(valw)); // start point
- //chip select down:
- valw=((valw&(~(0x1<=0) {
- printf("vpower\n");
- dacval=((vmax-val)*4095)/(vmax-vmin);
- if (dacval<0)
- dacval=0;
- if (dacval>4095)
- dacval=-100;
- if (val==-100)
- dacval=-100;
-
-
- } else if (dacindex>=0) {
- printf("vchip\n");
- dacval=((2700-val)*4095)/1000;
- if (dacval<0)
- dacval=0;
- if (dacval>4095)
- dacval=4095;
-
- } else {
- vLimit=val;
- printf("vlimit %d\n",vLimit );
+ switch(arg){
+ case DETECTOR_SERIAL_NUMBER:
+ retval = getDetectorMAC();
+ break;
+ case DETECTOR_FIRMWARE_VERSION:
+ retval = getFirmwareVersion();
+ break;
+ //case SOFTWARE_FIRMWARE_API_VERSION:
+ //return GetFirmwareSoftwareAPIVersion();
+ case DETECTOR_SOFTWARE_VERSION:
+ retval= GITREV;
+ retval= (retval <<32) | GITDATE;
+ break;
+ default:
+ break;
}
-
- }
- if (pwrindex>=0 && val!=-1) {
- preg=bus_r(POWER_ON_REG);
- printf("power reg is %08x\n",bus_r(POWER_ON_REG));
- printf("Switching off power %d\n", pwrindex);
- bus_w(POWER_ON_REG,preg&(~(1<<(16+pwrindex))));
- setDAC(dacindex,-100);
- printf("power reg is %08x\n",bus_r(POWER_ON_REG));
- retval=0;
- }
-
- if (dacindex>0 && dacval!=-100) {
-
- printf("Setting power %d to %d mV\n",ind,val);
- printf("Setting DAC %d to value %d\n",dacindex,dacval);
- retval=setDac(dacindex,dacval);
- if (pwrindex>=0 && dacval>=0 ) {
- preg=bus_r(POWER_ON_REG);
- printf("power reg is %08x\n",bus_r(POWER_ON_REG));
- printf("Switching on power %d\n", pwrindex);
- bus_w(POWER_ON_REG,preg|((1<<(16+pwrindex))));
- printf("power reg is %08x\n",bus_r(POWER_ON_REG));
+ return retval;
+}
+
+u_int64_t getFirmwareVersion() {
+ return ((bus_r(FPGA_VERSION_REG) & BOARD_REVISION_MSK) >> BOARD_REVISION_OFST);
+}
+
+
+
+u_int64_t getDetectorMAC() {
+ char output[255],mac[255]="";
+ u_int64_t res=0;
+ FILE* sysFile = popen("ifconfig eth0 | grep HWaddr | cut -d \" \" -f 11", "r");
+ fgets(output, sizeof(output), sysFile);
+ pclose(sysFile);
+ //getting rid of ":"
+ char * pch;
+ pch = strtok (output,":");
+ while (pch != NULL){
+ strcat(mac,pch);
+ pch = strtok (NULL, ":");
}
- }
-
- if (pwrindex>=0) {
- if (bus_r(POWER_ON_REG)&(1<<(16+pwrindex))){
- vmax=2700-(getDacRegister(19)*1000)/4095-200;
- printf("Vchip id %d mV\n",vmax+200);
- retval1=vmax-(retval*(vmax-vmin))/4095;
- printf("Vdac id %d mV\n",retval1);
- if (retval1>vmax)
- retval1=vmax;
- if (retval1=0) {
- if (retval>=0) {
- retval1=2700-(retval*1000)/4095;
- printf("Vchip is %d mV\n",vmax);
- } else
- retval1=-1;
- } else {
- printf("Get vlimit %d\n",vLimit);
- retval=vLimit;
- retval1=vLimit;
+ sscanf(mac,"%llx",&res);
+ return res;
+}
+
+u_int32_t getDetectorIP(){
+ char temp[50]="";
+ u_int32_t res=0;
+ //execute and get address
+ char output[255];
+ FILE* sysFile = popen("ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2", "r");
+ fgets(output, sizeof(output), sysFile);
+ pclose(sysFile);
+
+ //converting IPaddress to hex.
+ char* pcword = strtok (output,".");
+ while (pcword != NULL) {
+ sprintf(output,"%02x",atoi(pcword));
+ strcat(temp,output);
+ pcword = strtok (NULL, ".");
+ }
+ strcpy(output,temp);
+ sscanf(output, "%x", &res);
+ //printf("ip:%x\n",res);
+
+ return res;
+}
+
+
+
+
+
+
+
+
+/* initialization */
+
+void initControlServer(){
+ clkPhase[0] = 0; clkPhase[1] = 0;
+ setupDetector();
+ printf("\n");
+}
+
+
+
+void initStopServer() {
+
+ usleep(CTRL_SRVR_INIT_TIME_US);
+ if (mapCSP0() == FAIL) {
+ cprintf(BG_RED, "Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
+ exit(EXIT_FAILURE);
+ }
+}
+
+
+
+
+
+
+/* set up detector */
+
+void allocateDetectorStructureMemory(){
+ printf("This Server is for 1 Jungfrau module (500k)\n");
+
+ //Allocation of memory
+ if (detectorModules!=NULL) free(detectorModules);
+ if (detectorChans!=NULL) free(detectorChans);
+ if (detectorChips!=NULL) free(detectorChips);
+ if (detectorDacs!=NULL) free(detectorDacs);
+ if (detectorAdcs!=NULL) free(detectorAdcs);
+ detectorModules=malloc(sizeof(sls_detector_module));
+ detectorChips=malloc(NCHIP*sizeof(int));
+ detectorChans=malloc(NCHIP*NCHAN*sizeof(int));
+ detectorDacs=malloc(NDAC*sizeof(dacs_t));
+ detectorAdcs=malloc(NADC*sizeof(dacs_t));
+#ifdef VERBOSE
+ printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n);
+ printf("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs+n*NDAC);
+ printf("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs+n*NADC);
+#endif
+ (detectorModules)->dacs=detectorDacs;
+ (detectorModules)->adcs=detectorAdcs;
+ (detectorModules)->ndac=NDAC;
+ (detectorModules)->nadc=NADC;
+ (detectorModules)->nchip=NCHIP;
+ (detectorModules)->nchan=NCHIP*NCHAN;
+ (detectorModules)->module=0;
+ (detectorModules)->gain=0;
+ (detectorModules)->offset=0;
+ (detectorModules)->reg=0;
+ thisSettings = UNINITIALIZED;
+
+ // if trimval requested, should return -1 to acknowledge unknown
+ int ichan=0;
+ for (ichan=0; ichan<(detectorModules->nchan); ichan++) {
+ *((detectorModules->chanregs)+ichan) = -1;
+ }
+}
+
+
+
+void setupDetector() {
+
+ allocateDetectorStructureMemory();
+
+ resetPLL();
+ resetCore();
+ resetPeripheral();
+ cleanFifos();
+
+ //initialize dac series
+ initDac(0);
+ initDac(8);
+ initDac(16);
+
+ //set dacs
+ printf("Setting Default Dac values\n");
+ {
+ int i = 0;
+ int retval[2]={-1,-1};
+ const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
+ for(i = 0; i < NDAC; ++i) {
+ setDAC((enum DACINDEX)i,defaultvals[i],0,0,retval);
+ if (retval[0] != defaultvals[i])
+ cprintf(RED, "Warning: Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval[0]);
+ }
+ }
+
+ /*setSamples(1);
+ bus_w(DAC_REG,0xffff);
+ setSpeed
+ cleanFifos(); /* todo might work without
+ resetCore(); /* todo might work without */
+
+ //Initialization of acquistion parameters
+ setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
+ setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
+ setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
+ setTimer(FRAME_PERIOD, DEFAULT_PERIOD);
+ setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY);
+}
+
+
+
+
+
+
+
+/* firmware functions (resets) */
+
+int powerChip (int on){
+
+ /* set all the required voltages */
+ return 0;
+}
+
+
+void cleanFifos() { printf("\nClearing Acquisition Fifos - Not doing anything\n");
+ /* printf("\nClearing Acquisition Fifos\n");
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_ACQ_FIFO_CLR_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_ACQ_FIFO_CLR_MSK);*/
+}
+
+void resetCore() {printf("\nResetting Core - Not doing anything\n");
+ /*printf("\nResetting Core\n");
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_CORE_RST_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_CORE_RST_MSK);*/
+}
+
+void resetPeripheral() {printf("\nResetting Peripheral - Not doing anything\n");
+ /* printf("\nResetting Peripheral\n");
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PERIPHERAL_RST_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_PERIPHERAL_RST_MSK);*/
+}
+
+int getPhase(int i) {
+ if (i>=0 && i<4)
+ return clkPhase[i];
+ else
+ return -1;
+}
+
+
+int configurePhase(int val, int i) { /** compare with old jungfrau software and add in */
+
+ u_int32_t l=0x0c;
+ u_int32_t h=0x0d;
+ u_int32_t vv;
+ int32_t phase=0, inv=0;
+
+ u_int32_t tot;
+ u_int32_t odd=1;//0;
+
+ if (i<0 || i>3)
+ return -1;
+
+ if (val>65535 || val<-65535)
+ return clkPhase[i];
+
+ resetPLL();
+
+ setPllReconfigReg(PLL_MODE_REG, 1, 0);
+ printf("phase in %d\n",clkPhase[1]);
+
+ if (val>0) {
+ inv=0;
+ phase=val&0xffff;
+ } else {
+ inv=0;
+ val=-1*val;
+ phase=(~val)&0xffff;
}
- return retval1;
+
+ vv=phase | (i<<16);// | (inv<<21);
+
+ setPllReconfigReg(PLL_PHASE_SHIFT_REG,vv,0);
+
+ clkPhase[i]=val;
+ return clkPhase[i];
}
-double getADC(enum dacIndex ind, int imod){
- //get adc value
- return 0;
+int configureFrequency(int val, enum CLKINDEX i) { /** compare with old jungfrau software and add in */
+
+
+ u_int32_t l=0x0c;
+ u_int32_t h=0x0d;
+ u_int32_t vv;
+ int32_t phase=0, inv=0;
+
+ u_int32_t tot;
+ u_int32_t odd=1;//0;
+ printf("Want to configure frequency of counter %d to %d\n",i,val);
+ // printf("PLL reconfig reset\N"); bus_w(PLL_CNTRL_REG,(1<3) {
+ printf("wrong counter number %d\n",i);
+ return -1;
+ }
+
+ if (val<=0) {
+
+ printf("get value %d %d \n",i,clkDivider[i]);
+ return clkDivider[i];
+ }
+ if (i==adc_clk_c){
+ if (val>40)
+ {
+ printf("Too high frequency %d MHz for these ADCs!\n", val);
+ return clkDivider[i];
+ }
+ }
+
+ tot= PLL_VCO_FREQ_MHZ/val;
+ l=tot/2;
+ h=l;
+ if (tot>2*l) {
+ h=l+1;
+ odd=1;
+ }
+ else
+ {
+ odd=0;
+ }
+
+ printf("Counter %d: Low is %d, High is %d\n",i, l,h);
+
+
+ vv= (i<<18)| (odd<<17) | l | (h<<8);
+
+ printf("Counter %d, val: %08x\n", i, vv);
+ setPllReconfigReg(PLL_C_COUNTER_REG, vv,0);
+
+
+ usleep(10000);
+
+ resetPLL();
+
+ clkDivider[i]=PLL_VCO_FREQ_MHZ/(l+h);
+
+ printf("Frequency of clock %d is %d\n", i, clkDivider[i]);
+
+ return clkDivider[i];
}
-int setChannel(sls_detector_channel myChan){
- //template initChannelByNumber() from mcb_funcs.c
- return myChan.reg;
+
+
+
+/* set parameters - nmod, dr, roi */
+
+int setNMod(int nm, enum dimension dim){
+ return NMOD;
}
-int getChannel(sls_detector_channel *myChan){
- //template getChannelbyNumber() from mcb_funcs.c
- return FAIL;
+int getNModBoard(enum dimension arg){
+ return NMAXMOD;
+}
+
+
+int setDynamicRange(int dr){
+ /* edit functionality */
+ return 16;
}
-int setChip(sls_detector_chip myChip){
- //template initChipbyNumber() from mcb_funcs.c
- return myChip.reg;
+
+/* parameters - readout */
+
+int setSpeed(enum speedVariable arg, int val) {
+ int retval = -1;
+
+ switch (arg) {
+ case DBIT_PHASE:
+ if (val==-1)
+ retval=getPhase(DBIT_CLK_C);
+ else
+ retval=configurePhase(val,DBIT_CLK_C);
+ break;
+ case DBIT_CLOCK:
+ retval=configureFrequency(val,DBIT_CLK_C);
+ if (configureFrequency(-1,SYNC_CLK_C)>retval){
+ configureFrequency(retval,SYNC_CLK_C);
+ printf("--Configuring sync clk to %d MHz\n",val);
+ } else if (configureFrequency(-1,ADC_CLK_C)>retval && configureFrequency(-1,RUN_CLK_C)>retval) {
+ printf("++Configuring sync clk to %d MHz\n",val);
+ configureFrequency(retval,SYNC_CLK_C);
+ }
+ break;
+ default:
+ sprintf(mess,"Unknown speed parameter %d",arg);
+ break;
+ }
+ return retval;
}
-int getChip(sls_detector_chip *myChip){
- //template getChipbyNumber() from mcb_funcs.c
- return FAIL;
-}
-int setModule(sls_detector_module myChan){
- //template initModulebyNumber() from mcb_funcs.c
- return OK;
-}
-int getModule(sls_detector_module *myChan){
- //template getModulebyNumber() from mcb_funcs.c
- return FAIL;
-}
-int getThresholdEnergy(int imod){
- //template getThresholdEnergy() from mcb_funcs.c
- //depending on settings
- return FAIL;
+
+/* parameters - timer */
+
+int64_t setTimer(enum timerIndex ind, int64_t val) {
+
+ int64_t retval = -1;
+ switch(ind){
+
+ case FRAME_NUMBER:
+ if(val >= 0)
+ printf("\nSetting #frames: %lld\n",(long long int)val);
+ retval = set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
+ printf("Getting #frames: %lld\n",(long long int)retval);
+ break;
+
+ case ACQUISITION_TIME:
+ if(val >= 0){
+ printf("\nSetting exptime: %lldns\n", (long long int)val);
+ val *= (1E-3 * CLK_RUN); /* ?? */
+ }
+ retval = set64BitReg(val, SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) / (1E-3 * CLK_RUN);
+ printf("Getting exptime: %lldns\n", (long long int)retval);
+ break;
+
+ case FRAME_PERIOD:
+ if(val >= 0){
+ printf("\nSetting period to %lldns\n",(long long int)val);
+ val *= (1E-3 * CLK_SYNC); /* ?? */
+ }
+ retval = set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG )/ (1E-3 * CLK_SYNC);
+ printf("Getting period: %lldns\n", (long long int)retval);
+ break;
+
+ case DELAY_AFTER_TRIGGER:
+ if(val >= 0){
+ printf("\nSetting delay to %lldns\n", (long long int)val);
+ val *= (1E-3 * CLK_SYNC); /* ?? */
+ }
+ retval = set64BitReg(val, SET_DELAY_LSB_REG, SET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC);
+ printf("Getting delay: %lldns\n", (long long int)retval);
+ break;
+
+ case CYCLES_NUMBER:
+ if(val >= 0)
+ printf("\nSetting #cycles to %lld\n", (long long int)val);
+ retval = set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
+ printf("Getting #cycles: %lld\n", (long long int)retval);
+ break;
+
+ case GATES_NUMBER:
+ if(val >= 0)
+ printf("\nSetting #gates to %lld\n", (long long int)val);
+ retval = set64BitReg(val, SET_GATES_LSB_REG, SET_GATES_MSB_REG);
+ printf("Getting #gates: %lld\n", (long long int)retval);
+ break;
+
+ case PROBES_NUMBER: /* does not exist in firmware_funcs.c*/
+ /*if(val >= 0)
+ printf("\nSetting #probes to %lld\n", (long long int)val);
+ retval = set64BitReg(val, SET_PROBES_LSB_REG, SET_PROBES_MSB_REG);
+ printf("Getting #probes: %lld\n", (long long int)retval);
+ */
+ break;
+
+ case SAMPLES_JCTB:
+ if(val >= 0)
+ printf("\nSetting #samples to %lld\n", (long long int)val);
+ retval = bus_w(NSAMPLES_REG, val);
+ printf("Getting #samples: %lld\n", (long long int)retval);
+
+ break;
+
+ default:
+ cprintf(RED,"Warning: Timer Index not implemented for this detector: %d\n", ind);
+ break;
+ }
+
+ return retval;
+
}
-int setThresholdEnergy(int thr, int imod){
- //template getThresholdEnergy() from mcb_funcs.c
- //depending on settings
- return FAIL;
+
+int64_t getTimeLeft(enum timerIndex ind){
+ int64_t retval = -1;
+ switch(ind){
+
+ case FRAME_NUMBER:
+ retval = get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG);
+ printf("Getting number of frames left: %lld\n",(long long int)retval);
+ break;
+
+ case FRAME_PERIOD:
+ retval = get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG) / (1E-3 * CLK_SYNC);
+ printf("Getting period left: %lldns\n", (long long int)retval);
+ break;
+
+ case DELAY_AFTER_TRIGGER:
+ retval = get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC);
+ printf("Getting delay left: %lldns\n", (long long int)retval);
+ break;
+
+ /** acquisition time and period gives in time left in func.c, pls check with anna */
+
+ case CYCLES_NUMBER:
+ retval = get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG);
+ printf("Getting number of cycles left: %lld\n", (long long int)retval);
+ break;
+
+ case ACTUAL_TIME:
+ retval = get64BitReg(GET_ACTUAL_TIME_LSB_REG, GET_ACTUAL_TIME_MSB_REG) / (1E-9 * CLK_SYNC);
+ printf("Getting actual time (time from start): %lld\n", (long long int)retval);
+ break;
+
+ case MEASUREMENT_TIME:
+ retval = get64BitReg(GET_MEASUREMENT_TIME_LSB_REG, GET_MEASUREMENT_TIME_MSB_REG) / (1E-9 * CLK_SYNC);
+ printf("Getting measurement time (timestamp/ start frame time): %lld\n", (long long int)retval);
+ break;
+
+ case FRAMES_FROM_START:
+ retval = get64BitReg(FRAMES_FROM_START_LSB_REG, FRAMES_FROM_START_MSB_REG);
+ printf("Getting frames from start run control %lld\n", (long long int)retval);
+ break;
+
+ case FRAMES_FROM_START_PG: /** ask anna, seems to be calling previous function (frames_from_start) */
+ retval = get64BitReg(FRAMES_FROM_START_PG_LSB_REG, FRAMES_FROM_START_PG_MSB_REG);
+ printf("Getting frames from start run control %lld\n", (long long int)retval);
+ break;
+
+ default:
+ cprintf(RED, "Warning: Remaining Timer index not implemented for this detector: %d\n", ind);
+ break;
+ }
+
+ return retval;
+}
+
+
+
+
+
+
+/* parameters - channel, chip, module, settings */
+
+
+int setModule(sls_detector_module myMod){
+ return thisSettings;
+}
+
+
+int getModule(sls_detector_module *myMod){
+ return OK;
}
enum detectorSettings setSettings(enum detectorSettings sett, int imod){
- //template setSettings() from mcb_funcs.c
- //reads the dac registers from fpga to confirm which settings, if weird, undefined
+ return getSettings();
- return OK;
}
+
+enum detectorSettings getSettings(){
+ return thisSettings;
+}
+
+
+
+
+
+/* parameters - dac, adc, hv */
+
+
+
+
+
+
+void initDac(int dacnum) {
+ printf("\nInitializing dac for %d to \n",dacnum);
+
+ u_int32_t codata;
+ int csdx = dacnum / NDAC_PER_SET + DAC_SERIAL_CS_OUT_OFST; //,so can be DAC_SERIAL_CS_OUT_OFST or +1
+ int dacchannel = 0xf; // all channels
+ int dacvalue = 0x6; // can be any random value (just writing to power up)
+ printf(" Write to Input Register\n"
+ " Chip select bit:%d\n"
+ " Dac Channel:0x%x\n"
+ " Dac Value:0x%x\n",
+ csdx, dacchannel, dacvalue);
+
+ codata = LTC2620_DAC_CMD_WRITE + // command to write to input register
+ ((dacchannel << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) + // all channels
+ ((dacvalue << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK); // any random value
+ serializeToSPI(SPI_REG, codata, (0x1 << csdx), LTC2620_DAC_NUMBITS,
+ DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST);
+}
+
+
+
+
+
+
+
+
+
+int voltageToDac(int value){
+ int vmin = 0;
+ int vmax = MAX_DACVOLTVAL;
+ int nsteps = MAX_DACVAL;
+ if ((value < vmin) || (value > vmax)) {
+ cprintf(RED,"Voltage value (to convert to dac value) is outside bounds: %d\n", value);
+ return -1;
+ }
+ return (int)(((value - vmin) / (vmax - vmin)) * (nsteps - 1) + 0.5);
+}
+
+int dacToVoltage(unsigned int digital){
+ int vmin = 0;
+ int vmax = MAX_DACVOLTVAL;
+ int nsteps = MAX_DACVAL;
+ int v = vmin + (vmax - vmin) * digital / (nsteps - 1);
+ if((v < 0) || (v > nsteps - 1)) {
+ cprintf(RED,"Voltage value (converted from dac value) is outside bounds: %d\n", v);
+ return -1;
+ }
+ return v;
+}
+
+int powerToDac(int value, int chip) {
+ int nsteps = MAX_DACVAL;
+ int vchip = MAX_VCHIPVAL - (getDacRegister(V_CHIP)*1000)/(nsteps -1);
+ printf("Current V_Chip: %d mV\n",vchip);
+
+ int vmax = vchip - MIN_VCHIP_OFSTVAL;
+ int vmin = MIN_VCHIP_VAL;
+
+ // recalculating only for v_chip
+ if (chip) {
+ printf("vchip\n");
+ vmax = MAX_VCHIPVAL;
+ vmin = MAX_VCHIPVAL - 1000;
+ }
+ else
+ printf("vpower\n");
+
+ int v = (int)(((vmax - value) * (nsteps - 1) / (vmax - vmin)) ); /***+0.5 removed is this correct? seems different from voltageToDac maybe get rid of 0.5*/
+
+
+ if (v < 0) v = 0;
+ if (v > nsteps - 1) v = nsteps - 1;
+ if (value == -100) v = -100;
+
+ return v;
+}
+
+int dacToPower(int value, int chip) {
+ int retval1 = -1;
+ int nsteps = MAX_DACVAL;
+ int vchip = MAX_VCHIPVAL - (getDacRegister(V_CHIP)*1000)/(nsteps -1);
+ printf("Vchip id %d mV\n",vmax);
+ int vmax = vchip - MIN_VCHIP_OFSTVAL;
+ int vmin = MIN_VCHIP_VAL;
+
+ // recalculating only for v_chip
+ if (chip) {
+ printf("vchip\n");
+ vmax = MAX_VCHIPVAL;
+ vmin = MAX_VCHIPVAL - 1000;
+ }
+ else
+ printf("vpower\n");
+
+ retval1 = vmax - (value * (vmax - vmin)) / (nsteps - 1);
+ if (retval1 > vmax) retval1 = vmax;
+ if (retval1 < vmin) retval1 = vmin;
+ if (value < 0) retval1 = value;
+ return retval1;
+}
+
+
+
+void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){
+
+ int dacval = val;
+
+ // dacs: if set and mv, convert to dac
+ if (ind < val > 0 && mV) {
+ val = voltageToDac(val); //gives -1 on error
+ }
+
+
+ if ( (val >= 0) || (val == -100)) {
+
+
+ u_int32_t ichip = 2 - ind / NDAC_PER_SET;
+ u_int32_t valw = 0;
+ int i;
+
+ // start and chip select bar down -----------------
+ SPIChipSelect (&valw, SPI_REG, (0x1 << csdx));
+
+
+ // next dac --------------------------------------
+ for (i = 0; i < ichip; ++i) {
+ printf("%d next DAC\n", i);
+ sendDataToSPI (&valw, SPI_REG, LTC2620_DAC_CMD_MSK, LTC2620_DAC_NUMBITS,
+ DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST);
+ }
+
+
+ // this dac ----------------------------------------
+ u_int32_t codata;
+ int csdx = DAC_SERIAL_CS_OUT_OFST;
+ int dacchannel = ind % NDAC_PER_SET;
+
+ printf("\nSetting of DAC %d : %d dac units (%d mV)\n",ind, dacval, val);
+ // command
+ if (val >= 0) {
+ printf(" Write to Input Register and Update\n");
+ codata = LTC2620_DAC_CMD_SET;
+
+ } else if (val == -100) {
+ printf(" POWER DOWN\n");
+ codata = LTC2620_DAC_CMD_POWER_DOWN;
+ }
+ // address
+ printf(" Chip select bit:%d\n"
+ " Dac Channel:0x%x\n"
+ " Dac Value:0x%x\n",
+ csdx, dacchannel, val);
+ codata += ((dacchannel << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) +
+ ((val << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK);
+ // to spi
+ serializeToSPI(SPI_REG, codata, (0x1 << csdx), LTC2620_DAC_NUMBITS,
+ DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST);
+
+
+ printf("--------done setting dac set %d \n",i);
+
+ // next dac -----------------------------------------------------------
+ for (i = ichip+1; i < (N_DAC / NDAC_PER_SET); ++i) {
+ printf("%d next DAC\n", i);
+ sendDataToSPI (&valw, SPI_REG, LTC2620_DAC_CMD_MSK, LTC2620_DAC_NUMBITS,
+ DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST);
+ }
+
+
+ //chip select bar up, clk down and stop --------------------------------
+ SPIChipDeselect (&valw, SPI_REG, (0x1 << csdx), DAC_SERIAL_CLK_OUT_MSK);
+
+ // writes to register
+ setDacRegister(ind, dacval);
+ }
+
+ // reading dac value from register
+ printf("Getting DAC %d : ",ind);
+ retval[0] = getDacRegister(ind); printf("%d dac units ", retval[0]);
+ retval[1] = dacToVoltage(retval[0]);printf("(%d mV)\n", retval[1]);
+}
+
+
+int setPower(enum DACINDEX ind, int val) {
+
+ // not implemented yet
+ if ((ind == V_D) || (ind == V_C))
+ return -1;
+
+ // vlimit software limit
+ else if (ind == V_LIMIT) {
+ if (val >= 0)
+ vlimit = val;
+ return vlimit;
+ }
+
+ int pwrindex = -1;
+ int dacval = val;
+ int retval=-1, retval1=-1;
+ u_int32_t preg = 0;
+ int temp[2] = {-1,-1};
+
+ // get
+ if (val == -1)
+ dacval = -1;
+
+ // vchip
+ else if (ind == V_CHIP)
+ dacval = powerToDac(val, 1);
+
+ // power a, b, c , d, io
+ else {
+ dacval = powerToDac(val, 0);
+
+ switch (ind) {
+ case V_IO: pwrindex = 0;break;
+ case V_A: pwrindex = 1; break;
+ case V_B: pwrindex = 2; break;
+ default:break;
+ }
+
+ // shut down
+ preg = bus_r(POWER_ON_REG);
+ printf("power reg is %08x\n",bus_r(POWER_ON_REG));
+ printf("Switching off power %d\n", ind);
+ bus_w(POWER_ON_REG,preg &(~(1 << (POWER_ENABLE_OFST + pwrindex))));
+ setDac(ind,-100, 0, 1, temp);
+ printf("power reg is %08x\n",bus_r(POWER_ON_REG));
+ retval=0;
+ }
+
+ // actual setting
+ if (val != -100) {
+ printf("Setting power %d to %d mV (%d dac val)\n",ind, val, dacval);
+ retval = setDac(ind, dacval);
+ // setting power a, b, c, d, io
+ if (pwrindex >= 0 && dacval >= 0 ) {
+ preg = bus_r(POWER_ON_REG);
+ printf("power reg is %08x\n", bus_r(POWER_ON_REG));
+ printf("Switching on power %d\n", pwrindex);
+ bus_w(POWER_ON_REG, preg | ((1 << (POWER_ENABLE_OFST + pwrindex))));
+ printf("power reg is %08x\n",bus_r(POWER_ON_REG));
+ }
+ }
+
+ if (pwrindex >= 0) {
+ if (bus_r(POWER_ON_REG) & (1 << (POWER_ENABLE_OFST + pwrindex))) {
+ retval1 = dacToPower(retval, 0);
+ printf("Vdac id %d mV\n",retval1);
+ } else
+ retval1 = 0;
+ } else {
+ if (retval >= 0) {
+ retval1 = dacToPower(retval, 1);
+ /*printf("Vchip is %d mV\n",vmax); makes no sense.. should be printing retval1??? */
+ } else
+ retval1=-1;
+ }
+
+ return retval1;
+}
+
+int getVLimit() {
+ return vlimit;
+}
+
+void setDacRegister(int dacnum,int dacvalue) {
+ bus_w(DAC_NUM_REG, dacnum);
+ bus_w(DAC_VAL_REG, dacvalue);
+ bus_w(DAC_NUM_REG, dacnum | (1<<16));/** super strange writing dac num in weird ways */
+ bus_w(DAC_NUM_REG, dacnum);
+ printf("Wrote dac register value %d address %d\n",bus_r(DAC_VAL_REG),bus_r(DAC_NUM_REG)) ;
+}
+
+int getDacRegister(int dacnum) {/** super strange, reading out in some other register than written */
+ bus_w(DAC_NUM_REG, dacnum);
+ printf("READ dac register value %d address %d\n",(int16_t)bus_r(DAC_VAL_OUT_REG),bus_r(DAC_NUM_REG)) ;
+ return (int16_t)bus_r(DAC_VAL_OUT_REG);
+}
+
+
+
+
+
+/* parameters - timing, extsig */
+
+
+enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){
+ return AUTO_TIMING;
+}
+
+
+
+
+/* jungfrau specific - pll, flashing fpga */
+
+
+
+void resetPLL() {
+ // reset PLL Reconfiguration and PLL
+ bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) | PLL_CTRL_RECONFIG_RST_MSK | PLL_CTRL_RST_MSK);
+ usleep(100);
+ bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) & ~PLL_CTRL_RECONFIG_RST_MSK & ~PLL_CTRL_RST_MSK);
+}
+
+
+u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val) {
+
+ // set parameter
+ bus_w(PLL_PARAM_REG, val);
+
+ // set address
+ bus_w(PLL_CONTROL_REG, (reg << PLL_CTRL_ADDR_OFST) & PLL_CTRL_ADDR_MSK);
+ usleep(10*1000);
+
+ //write parameter
+ bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) | PLL_CTRL_WR_PARAMETER_MSK);
+ bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) & ~PLL_CTRL_WR_PARAMETER_MSK);
+ usleep(10*1000);
+
+ return val;
+}
+
+
+
+
+void configurePll() {
+ u_int32_t val;
+ int32_t phase=0, inv=0;
+
+ printf(" phase in %d\n", clkPhase[1]);
+ if (clkPhase[1]>0) {
+ inv=0;
+ phase=clkPhase[1];
+ } else {
+ inv=1;
+ phase=-1*clkPhase[1];
+ }
+ printf(" phase out %d (0x%08x)\n", phase, phase);
+
+ if (inv) {
+ val = ((phase << PLL_SHIFT_NUM_SHIFTS_OFST) & PLL_SHIFT_NUM_SHIFTS_MSK) + PLL_SHIFT_CNT_SLCT_C1_VAL + PLL_SHIFT_UP_DOWN_NEG_VAL;
+ printf(" phase word 0x%08x\n", val);
+ setPllReconfigReg(PLL_PHASE_SHIFT_REG, val);
+ } else {
+ val = ((phase << PLL_SHIFT_NUM_SHIFTS_OFST) & PLL_SHIFT_NUM_SHIFTS_MSK) + PLL_SHIFT_CNT_SLCT_C0_VAL + PLL_SHIFT_UP_DOWN_NEG_VAL;
+ printf(" phase word 0x%08x\n", val);
+ setPllReconfigReg(PLL_PHASE_SHIFT_REG, val);
+
+ printf(" phase word 0x%08x\n", val);
+ val = ((phase << PLL_SHIFT_NUM_SHIFTS_OFST) & PLL_SHIFT_NUM_SHIFTS_MSK) + PLL_SHIFT_CNT_SLCT_C2_VAL;
+ setPllReconfigReg(PLL_PHASE_SHIFT_REG, val);
+ }
+ usleep(10000);
+}
+
+
+
+
+/* aquisition */
+
int startStateMachine(){
- //template startStateMachine() from firmware_funcs.c
- /*
- fifoReset();
- now_ptr=(char*)ram_values;
- //send start acquisition to fpga
- */
- return FAIL;
+ printf("*******Starting State Machine*******\n");
+
+ cleanFifos();
+
+ //start state machine
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_START_ACQ_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_START_ACQ_MSK);
+
+ printf("Status Register: %08x\n",bus_r(STATUS_REG));
+ return OK;
}
int stopStateMachine(){
- //template stopStateMachine() from firmware_funcs.c
- // send stop to fpga
- //if status = busy after 500us, return FAIL
- return FAIL;
+ cprintf(BG_RED,"*******Stopping State Machine*******\n");
+
+ //stop state machine
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STOP_ACQ_MSK);
+ usleep(100);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STOP_ACQ_MSK);
+
+ printf("Status Register: %08x\n",bus_r(STATUS_REG));
+ return OK;
}
-int startReadOut(){
- //template startReadOut() from firmware_funcs.c
- //send fpga start readout
- return FAIL;
-}
+
enum runStatus getRunStatus(){
- //template runState() from firmware_funcs.c
- //get status from fpga
- return ERROR;
+#ifdef VERBOSE
+ printf("Getting status\n");
+#endif
+
+ enum runStatus s;
+ u_int32_t retval = bus_r(STATUS_REG);
+ printf("Status Register: %08x\n",retval);
+
+ //running
+ if(((retval & RUN_BUSY_MSK) >> RUN_BUSY_OFST)) {
+ if ((retval & WAITING_FOR_TRIGGER_MSK) >> WAITING_FOR_TRIGGER_OFST) {
+ printf("-----------------------------------WAITING-----------------------------------\n");
+ s=WAITING;
+ }
+ else{
+ printf("-----------------------------------RUNNING-----------------------------------\n");
+ s=RUNNING;
+ }
+ }
+
+ //not running
+ else {
+ if ((retval & STOPPED_MSK) >> STOPPED_OFST) {
+ printf("-----------------------------------STOPPED--------------------------\n");
+ s=STOPPED;
+ } else if ((retval & RUNMACHINE_BUSY_MSK) >> RUNMACHINE_BUSY_OFST) {
+ printf("-----------------------------------READ MACHINE BUSY--------------------------\n");
+ s=TRANSMITTING;
+ } else if (!retval) {
+ printf("-----------------------------------IDLE--------------------------------------\n");
+ s=IDLE;
+ } else {
+ printf("-----------------------------------Unknown status %08x--------------------------------------\n", retval);
+ s=ERROR;
+ }
+ }
+
+ return s;
}
-char *readFrame(int *ret, char *mess){
- //template fifo_read_event() from firmware_funcs.c
- //checks if state machine running and if fifo has data(look_at_me_reg) and accordingly reads frame
- // memcpy(now_ptr, values, dataBytes);
- //returns ptr to values
- return NULL;
+
+void readFrame(int *ret, char *mess){
+
+ // wait for status to be done
+ while(runBusy()){
+ usleep(500);
+ }
+
+ // frames left to give status
+ int64_t retval = getTimeLeft(FRAME_NUMBER) + 1;
+ if ( retval > 0) {
+ *ret = (int)FAIL;
+ sprintf(mess,"no data and run stopped: %lld frames left\n",retval);
+ cprintf(RED,"%s\n",mess);
+ } else {
+ *ret = (int)FINISHED;
+ sprintf(mess,"acquisition successfully finished\n");
+ printf("%s",mess);
+ }
}
-int64_t setTimer(enum timerIndex ind, int64_t val){
- //template setDelay() from firmware_funcs.c
- //writes to reg
- //FRAME_NUMBER --> defined in sls_receiver_defs.h
- //ACQUISITION_TIME
- //FRAME_PERIOD -> how many frames per trigger
- //DELAY_AFTER_TRIGGER
- //GATES_NUMBER
- //PROBES_NUMBER = # counters
- //CYCLES_NUMBER -> how many triggers
- int64_t retval = -1; // return value to check
-
- switch(ind){ // only change the timer corresponding to ind
-
- case FRAME_NUMBER:
- if(val >= 0)
- printf("\nSetting #frames: %lld\n",(long long int)val);
- retval = set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
- printf("Getting #frames: %lld\n",(long long int)retval);
- break;
-
- case ACQUISITION_TIME: // defined in sls_receiver_defs.h
- if(val>=0){
- printf("\n Setting the exposure time: %lld ns \n",(long long int)val);
- val *= (1E-3 * CLK_RUN); // convert from ns to clk-cycles
- // CLK_RUN is defined in slsDetectorServer_defs.h
- }
- retval = set64BitReg(val,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG )/(1E-3 * CLK_RUN); // set the register to val and read back, convert back to ns
- // SET_EXPTIME_LSB_REG are defined in RegisterDefs.h
- printf("Getting the exposure time: %lld ns \n", (long long int)retval);
- break;
-
- case FRAME_PERIOD: // how many frames per trigger
- if(val >= 0){
- printf("\nSetting period to %lldns\n",(long long int)val);
- val *= (1E-3 * CLK_SYNC);
- }
- retval = set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG )/ (1E-3 * CLK_SYNC);
- // CLK_SYN is defined in slsDetectorServer_defs.h
- printf("Getting period: %lldns\n", (long long int)retval);
- break;
-
- case DELAY_AFTER_TRIGGER:
- if(val >= 0){
- printf("\nSetting delay to %lldns\n", (long long int)val);
- val *= (1E-3 * CLK_SYNC);
- }
- retval = set64BitReg(val, SET_DELAY_LSB_REG, SET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC);
- printf("Getting delay: %lldns\n", (long long int)retval);
- break;
-
- // case PROBES_NUMBER:
-
- case CYCLES_NUMBER: // how many triggers
- if(val >= 0)
- printf("\nSetting #cycles to %lld\n", (long long int)val);
- retval = set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
- printf("Getting #cycles: %lld\n", (long long int)retval);
- break;
-
- default:
- cprintf(RED,"Warning: Timer Index not implemented for this detector: %d\n", ind);
- break;
- }
- return retval;
-}
-
-
-int64_t getTimeLeft(enum timerIndex ind){
- //template getDelay() from firmware_funcs.c
- //reads from reg
- //FRAME_NUMBER
- //ACQUISITION_TIME
- //FRAME_PERIOD
- //DELAY_AFTER_TRIGGER
- //GATES_NUMBER
- //PROBES_NUMBER
- //CYCLES_NUMBER
- return -1;
-}
-
-
-int setDynamicRange(int dr){
- //template setDynamicRange() from firmware_funcs.c
- return 0;
-}
-
-
-enum readOutFlags setReadOutFlags(enum readOutFlags val){
- //template setStoreInRAM from firmware_funcs.c
- return -1;
+u_int32_t runBusy(void) {
+ u_int32_t s = ((bus_r(STATUS_REG) & RUN_BUSY_MSK) >> RUN_BUSY_OFST);
+#ifdef VERBOSE
+ printf("Status Register: %08x\n", s);
+#endif
+ return s;
}
-int setROI(int n, ROI arg[], int *retvalsize, int *ret){
- return FAIL;
+
+
+
+
+/* common */
+
+//jungfrau doesnt require chips and chans (save memory)
+int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod){
+
+ int idac, iadc;
+ int ret=OK;
+
+#ifdef VERBOSE
+ printf("Copying module %x to module %x\n",srcMod,destMod);
+#endif
+
+ if (srcMod->module>=0) {
+#ifdef VERBOSE
+ printf("Copying module number %d to module number %d\n",srcMod->module,destMod->module);
+#endif
+ destMod->module=srcMod->module;
+ }
+ if (srcMod->serialnumber>=0){
+
+ destMod->serialnumber=srcMod->serialnumber;
+ }
+ if ((srcMod->nchip)>(destMod->nchip)) {
+ printf("Number of chip of source is larger than number of chips of destination\n");
+ return FAIL;
+ }
+ if ((srcMod->nchan)>(destMod->nchan)) {
+ printf("Number of channels of source is larger than number of channels of destination\n");
+ return FAIL;
+ }
+ if ((srcMod->ndac)>(destMod->ndac)) {
+ printf("Number of dacs of source is larger than number of dacs of destination\n");
+ return FAIL;
+ }
+ if ((srcMod->nadc)>(destMod->nadc)) {
+ printf("Number of dacs of source is larger than number of dacs of destination\n");
+ return FAIL;
+ }
+
+#ifdef VERBOSE
+ printf("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac);
+ printf("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc);
+ printf("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip);
+ printf("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan);
+
+#endif
+ destMod->ndac=srcMod->ndac;
+ destMod->nadc=srcMod->nadc;
+ destMod->nchip=srcMod->nchip;
+ destMod->nchan=srcMod->nchan;
+ if (srcMod->reg>=0)
+ destMod->reg=srcMod->reg;
+#ifdef VERBOSE
+ printf("Copying register %x (%x)\n",destMod->reg,srcMod->reg );
+#endif
+ if (srcMod->gain>=0)
+ destMod->gain=srcMod->gain;
+ if (srcMod->offset>=0)
+ destMod->offset=srcMod->offset;
+
+ for (idac=0; idac<(srcMod->ndac); idac++) {
+ if (*((srcMod->dacs)+idac)>=0)
+ *((destMod->dacs)+idac)=*((srcMod->dacs)+idac);
+ }
+ for (iadc=0; iadc<(srcMod->nadc); iadc++) {
+ if (*((srcMod->adcs)+iadc)>=0)
+ *((destMod->adcs)+iadc)=*((srcMod->adcs)+iadc);
+ }
+ return ret;
}
-
-int setSpeed(enum speedVariable arg, int val){
- //template setClockDivider() from firmware_funcs.c
- //CLOCK_DIVIDER
- //WAIT_STATES
- //SET_SIGNAL_LENGTH
- //TOT_CLOCK_DIVIDER
- //TOT_DUTY_CYCLE
-
- //returns eg getClockDivider from firmware_funcs.c
- return 0;
-}
-
-
-
-int executeTrimming(enum trimMode mode, int par1, int par2, int imod){
- // template trim_with_noise from trimming_funcs.c
- return FAIL;
-}
-
-
-
-
-int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb){
- //detector specific.
- return FAIL;
-}
-
-
-int loadImage(enum imageType index, char *imageVals){
- //detector specific.
- return FAIL;
-}
-
-
-int readCounterBlock(int startACQ, char *counterVals){
- //detector specific.
- return FAIL;
-}
-
-int resetCounterBlock(int startACQ){
- //detector specific.
- return FAIL;
-}
-
-int startReceiver(int d){
-
- return 0;
-}
-
-int calibratePedestal(int frames){
-
- return 0;
-}
-
int calculateDataBytes(){
- return 0;
+ return DATA_BYTES;
}
-int getTotalNumberOfChannels(){return 0;}
-int getTotalNumberOfChips(){return 0;}
-int getTotalNumberOfModules(){return 0;}
-int getNumberOfChannelsPerChip(){return 0;}
-int getNumberOfChannelsPerModule(){return 0;}
-int getNumberOfChipsPerModule(){return 0;}
-int getNumberOfDACsPerModule(){return 0;}
-int getNumberOfADCsPerModule(){return 0;}
+int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerModule() * (int)getTotalNumberOfModules());}
+int getTotalNumberOfChips(){return ((int)getNumberOfChipsPerModule() * (int)getTotalNumberOfModules());}
+int getTotalNumberOfModules(){return NMOD;}
+int getNumberOfChannelsPerModule(){return ((int)getNumberOfChannelsPerChip() * (int)getTotalNumberOfChips());}
+int getNumberOfChipsPerModule(){return NCHIP;}
+int getNumberOfDACsPerModule(){return NDAC;}
+int getNumberOfADCsPerModule(){return NADC;}
+int getNumberOfChannelsPerChip(){return NCHAN;}
-
-
-
-
-enum externalSignalFlag getExtSignal(int signalindex){
- //template getExtSignal from firmware_funcs.c
- //return signals[signalindex];
- return -1;
-}
-
-
-
-
-
-enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag){
- //template setExtSignal from firmware_funcs.c
-
- //in short..sets signals array, checks if agrees with timing mode, writes to fpga reg, calls synchronization and then settiming
- /*
- if (signalindex>=0 && signalindex<4) {
- signals[signalindex]=flag;
-#ifdef VERBOSE
- printf("settings signal variable number %d to value %04x\n", signalindex, signals[signalindex]);
-#endif
- // if output signal, set it!
- switch (flag) {
- case GATE_IN_ACTIVE_HIGH:
- case GATE_IN_ACTIVE_LOW:
- if (timingMode==GATE_FIX_NUMBER || timingMode==GATE_WITH_START_TRIGGER)//timingMode = AUTO_TIMING by default and is set in setTiming()
- setFPGASignal(signalindex,flag); //not implemented here, checks if flag within limits and writes to fpga reg
- else
- setFPGASignal(signalindex,SIGNAL_OFF);
- break;
- case TRIGGER_IN_RISING_EDGE:
- case TRIGGER_IN_FALLING_EDGE:
- if (timingMode==TRIGGER_EXPOSURE || timingMode==GATE_WITH_START_TRIGGER)
- setFPGASignal(signalindex,flag);
- else
- setFPGASignal(signalindex,SIGNAL_OFF);
- break;
- case RO_TRIGGER_IN_RISING_EDGE:
- case RO_TRIGGER_IN_FALLING_EDGE:
- if (timingMode==BURST_TRIGGER)
- setFPGASignal(signalindex,flag);
- else
- setFPGASignal(signalindex,SIGNAL_OFF);
- break;
- case MASTER_SLAVE_SYNCHRONIZATION:
- setSynchronization(syncMode);//syncmode = NO_SYNCHRONIZATION by default and set with this function
- break;
- default:
- setFPGASignal(signalindex,mode);
- }
-
- setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
- }
- */
- return getExtSignal(signalindex);
-}
-
-
-
-
-
-
-enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){
- //template setTiming from firmware_funcs.c
- //template getFPGASignal from firmware_funcs.c
-
-
- //getFPGASignal(signalindex) used later on in this fucntion
- //gets flag from fpga reg, checks if flag within limits,
- //if( flag=SIGNAL_OFF and signals[signalindex]==MASTER_SLAVE_SYNCHRONIZATION), return -1, (ensures masterslaveflag !=off now)
- //else return flag
-
- int ret=GET_EXTERNAL_COMMUNICATION_MODE;
- //sets timingmode variable
- //ensures that the signals are in acceptance with timing mode and according sets the timing mode
- /*
- int g=-1, t=-1, rot=-1;
-
- int i;
-
- switch (ti) {
- case AUTO_TIMING:
- timingMode=ti;
- // disable all gates/triggers in except if used for master/slave synchronization
- for (i=0; i<4; i++) {
- if (getFPGASignal(i)>0 && getFPGASignal(i)=0 && t>=0 && rot<0) {
- ret=GATE_WITH_START_TRIGGER;
- } else if (g<0 && t>=0 && rot<0) {
- ret=TRIGGER_EXPOSURE;
- } else if (g>=0 && t<0 && rot<0) {
- ret=GATE_FIX_NUMBER;
- } else if (g<0 && t<0 && rot>0) {
- ret=TRIGGER_READOUT;
- } else if (g<0 && t<0 && rot<0) {
- ret=AUTO_TIMING;
- }
-
- */
- return ret;
-}
-
-
+/* sync */
enum masterFlags setMaster(enum masterFlags arg){
- //template setMaster from firmware_funcs.c
- /*
- int i;
- switch(f) {
- case NO_MASTER:
- // switch of gates or triggers
- masterMode=NO_MASTER;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- setFPGASignal(i,SIGNAL_OFF);
- }
- }
- break;
- case IS_MASTER:
- // configure gate or trigger out
- masterMode=IS_MASTER;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- switch (syncMode) {
- case NO_SYNCHRONIZATION:
- setFPGASignal(i,SIGNAL_OFF);
- break;
- case MASTER_GATES:
- setFPGASignal(i,GATE_OUT_ACTIVE_HIGH);
- break;
- case MASTER_TRIGGERS:
- setFPGASignal(i,TRIGGER_OUT_RISING_EDGE);
- break;
- case SLAVE_STARTS_WHEN_MASTER_STOPS:
- setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE);
- break;
- default:
- ;
- }
- }
- }
- break;
- case IS_SLAVE:
- // configure gate or trigger in
- masterMode=IS_SLAVE;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- switch (syncMode) {
- case NO_SYNCHRONIZATION:
- setFPGASignal(i,SIGNAL_OFF);
- break;
- case MASTER_GATES:
- setFPGASignal(i,GATE_IN_ACTIVE_HIGH);
- break;
- case MASTER_TRIGGERS:
- setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
- break;
- case SLAVE_STARTS_WHEN_MASTER_STOPS:
- setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
- break;
- default:
- ;
- }
- }
- }
- break;
- default:
- //do nothing
- ;
- }
-
- switch(masterMode) {
- case NO_MASTER:
- return NO_MASTER;
-
-
- case IS_MASTER:
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- switch (syncMode) {
- case NO_SYNCHRONIZATION:
- return IS_MASTER;
- case MASTER_GATES:
- if (getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH)
- return IS_MASTER;
- else
- return NO_MASTER;
- case MASTER_TRIGGERS:
- if (getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE)
- return IS_MASTER;
- else
- return NO_MASTER;
- case SLAVE_STARTS_WHEN_MASTER_STOPS:
- if (getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE)
- return IS_MASTER;
- else
- return NO_MASTER;
- default:
- return NO_MASTER;
- }
-
- }
- }
-
- case IS_SLAVE:
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- switch (syncMode) {
- case NO_SYNCHRONIZATION:
- return IS_SLAVE;
- case MASTER_GATES:
- if (getFPGASignal(i)==GATE_IN_ACTIVE_HIGH)
- return IS_SLAVE;
- else
- return NO_MASTER;
- case MASTER_TRIGGERS:
- case SLAVE_STARTS_WHEN_MASTER_STOPS:
- if (getFPGASignal(i)==TRIGGER_IN_RISING_EDGE)
- return IS_SLAVE;
- else
- return NO_MASTER;
- default:
- return NO_MASTER;
- }
-
- }
- }
-
- }
- */
-
- return NO_MASTER;
+ return NO_MASTER;
}
-
-
enum synchronizationMode setSynchronization(enum synchronizationMode arg){
- /*
- int i;
-
- switch(s) {
- case NO_SYNCHRONIZATION:
- syncMode=NO_SYNCHRONIZATION;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- setFPGASignal(i,SIGNAL_OFF);
- }
- }
- break;
- // disable external signals?
- case MASTER_GATES:
- // configure gate in or out
- syncMode=MASTER_GATES;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- if (masterMode==IS_MASTER)
- setFPGASignal(i,GATE_OUT_ACTIVE_HIGH);
- else if (masterMode==IS_SLAVE)
- setFPGASignal(i,GATE_IN_ACTIVE_HIGH);
- }
- }
-
- break;
- case MASTER_TRIGGERS:
- // configure trigger in or out
- syncMode=MASTER_TRIGGERS;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- if (masterMode==IS_MASTER)
- setFPGASignal(i,TRIGGER_OUT_RISING_EDGE);
- else if (masterMode==IS_SLAVE)
- setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
- }
- }
- break;
-
-
- case SLAVE_STARTS_WHEN_MASTER_STOPS:
- // configure trigger in or out
- syncMode=SLAVE_STARTS_WHEN_MASTER_STOPS;
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- if (masterMode==IS_MASTER)
- setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE);
- else if (masterMode==IS_SLAVE)
- setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
- }
- }
- break;
-
-
- default:
- //do nothing
- ;
- }
-
- switch (syncMode) {
-
- case NO_SYNCHRONIZATION:
- return NO_SYNCHRONIZATION;
-
- case MASTER_GATES:
-
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- if (masterMode==IS_MASTER && getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH)
- return MASTER_GATES;
- else if (masterMode==IS_SLAVE && getFPGASignal(i)==GATE_IN_ACTIVE_HIGH)
- return MASTER_GATES;
- }
- }
- return NO_SYNCHRONIZATION;
-
- case MASTER_TRIGGERS:
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- if (masterMode==IS_MASTER && getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE)
- return MASTER_TRIGGERS;
- else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE)
- return MASTER_TRIGGERS;
- }
- }
- return NO_SYNCHRONIZATION;
-
- case SLAVE_STARTS_WHEN_MASTER_STOPS:
- for (i=0; i<4; i++) {
- if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
- if (masterMode==IS_MASTER && getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE)
- return SLAVE_STARTS_WHEN_MASTER_STOPS;
- else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE)
- return SLAVE_STARTS_WHEN_MASTER_STOPS;
- }
- }
- return NO_SYNCHRONIZATION;
-
- default:
- return NO_SYNCHRONIZATION;
-
- }
-
-
- */
- return NO_SYNCHRONIZATION;
+ return NO_SYNCHRONIZATION;
}
-#endif
+
+
+
+//#endif
diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.h
deleted file mode 100644
index 4da4a3d8b..000000000
--- a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.h
+++ /dev/null
@@ -1,245 +0,0 @@
-#ifdef SLS_DETECTOR_FUNCTION_LIST
-#ifndef SLS_DETECTOR_FUNCTION_LIST_H
-#define SLS_DETECTOR_FUNCTION_LIST_H
-
-#include "sls_receiver_defs.h"
-#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h
-
-#include
-#include // FILE
-
-
-/****************************************************
-This functions are used by the slsDetectroServer_funcs interface.
-Here are the definitions, but the actual implementation should be done for each single detector.
-
-****************************************************/
-
-
-// basic tests
-void checkFirmwareCompatibility(int flag);
-#ifdef JUNGFRAUD
-int checkType();
-u_int32_t testFpga(void);
-int testBus(void);
-#endif
-
-#if defined(MYTHEND) || defined(JUNGFRAUD)
-int moduleTest( enum digitalTestMode arg, int imod);
-int detectorTest( enum digitalTestMode arg);
-#endif
-
-// Ids
-int64_t getDetectorId(enum idMode arg);
-u_int64_t getFirmwareVersion();
-#ifdef MYTHEND
-int64_t getModuleId(enum idMode arg, int imod);
-#elif JUNGFRAUD
-u_int16_t getHardwareVersionNumber();
-u_int16_t getHardwareSerialNumber();
-#endif
-u_int32_t getDetectorNumber();
-u_int64_t getDetectorMAC();
-u_int32_t getDetectorIP();
-
-
-// initialization
-void initControlServer();
-void initStopServer();
-#ifdef EIGERD
-void getModuleConfiguration();
-#endif
-
-// set up detector
-void allocateDetectorStructureMemory();
-void setupDetector();
-
-
-// advanced read/write reg
-#ifndef EIGERD
-extern u_int32_t writeRegister(u_int32_t offset, u_int32_t data); // blackfin.h
-extern u_int32_t readRegister(u_int32_t offset); // blackfin.h
-#else
-uint32_t writeRegister(uint32_t offset, uint32_t data);
-uint32_t readRegister(uint32_t offset);
-#endif
-
-
-// firmware functions (resets)
-#ifdef JUNGFRAUD
-int powerChip (int on);
-void cleanFifos();
-void resetCore();
-void resetPeripheral();
-int adcPhase(int st);
-int getPhase();
-#endif
-
-// parameters - nmod, dr, roi
-int setNMod(int nm, enum dimension dim); // mythen specific, but for detector compatibility as a get
-int getNModBoard(enum dimension arg); // mythen specific, but for detector compatibility as a get
-int setDynamicRange(int dr);
-#ifdef GOTTHARD
-int setROI(int n, ROI arg[], int *retvalsize, int *ret);
-#endif
-
-// parameters - readout
-int setSpeed(enum speedVariable arg, int val);
-#if defined(EIGERD) || defined(MYTHEND)
-enum readOutFlags setReadOutFlags(enum readOutFlags val);
-#endif
-#ifdef MYTHEND
-int executeTrimming(enum trimMode mode, int par1, int par2, int imod);
-#endif
-
-// parameters - timer
-int64_t setTimer(enum timerIndex ind, int64_t val);
-#ifndef EIGERD
-int64_t getTimeLeft(enum timerIndex ind);
-#endif
-
-
-// parameters - channel, chip, module, settings
-#ifdef MYTHEND
-int setChannel(sls_detector_channel myChan);
-int getChannel(sls_detector_channel *myChan);
-int setChip(sls_detector_chip myChip);
-int getChip(sls_detector_chip *myChip);
-#endif
-#ifdef EIGERD
-int setModule(sls_detector_module myMod, int delay);
-#else
-int setModule(sls_detector_module myMod);
-#endif
-int getModule(sls_detector_module *myMod);
-enum detectorSettings setSettings(enum detectorSettings sett, int imod);
-enum detectorSettings getSettings();
-
-
-// parameters - threshold
-#if defined(MYTHEND) || defined(EIGERD)
-int getThresholdEnergy(int imod);
-int setThresholdEnergy(int ev, int imod);
-#endif
-
-// parameters - dac, adc, hv
-#ifdef JUNGFRAUD
-void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset);
-void initDac(int dacnum);
-extern void setAdc(int addr, int val); // AD9257.h
-int voltageToDac(int value);
-int dacToVoltage(unsigned int digital);
-#endif
-void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]);
-int getADC(enum ADCINDEX ind, int imod);
-#ifndef MYTHEND
-int setHighVoltage(int val);
-#endif
-
-
-
-// parameters - timing, extsig
-#ifdef MYTHEND
-enum externalSignalFlag getExtSignal(int signalindex);
-enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag);
-#endif
-enum externalCommunicationMode setTiming( enum externalCommunicationMode arg);
-
-// configure mac
-#ifdef JUNGFRAUD
-long int calcChecksum(int sourceip, int destip);
-#endif
-#ifndef MYTHEND
-int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival);
-#endif
-#if defined(JUNGFRAUD) || defined(EIGERD)
-int setDetectorPosition(int pos[]);
-#endif
-
-
-// very detector specific
-
-// gotthard specific - image, pedestal
-#ifdef GOTTHARDD
-int loadImage(enum imageType index, char *imageVals);
-int readCounterBlock(int startACQ, char *counterVals);
-int resetCounterBlock(int startACQ);
-int calibratePedestal(int frames);
-
-// jungfrau specific - pll, flashing firmware
-#elif JUNGFRAUD
-void resetPLL();
-u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val);
-void configurePll();
-extern void eraseFlash(); // programfpga.h
-extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h
-extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h
-extern int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp); // programfpga.h
-
-// eiger specific - iodelay, 10g, pulse, rate, temp, activate, delay nw parameter
-#elif EIGERD
-int setIODelay(int val, int imod);
-int enableTenGigabitEthernet(int val);
-int setCounterBit(int val);
-int pulsePixel(int n, int x, int y);
-int pulsePixelNMove(int n, int x, int y);
-int pulseChip(int n);
-int64_t setRateCorrection(int64_t custom_tau_in_nsec);
-int getRateCorrectionEnable();
-int getDefaultSettingsTau_in_nsec();
-void setDefaultSettingsTau_in_nsec(int t);
-int64_t getCurrentTau();
-void setExternalGating(int enable[]);
-int setAllTrimbits(int val);
-int getAllTrimbits();
-int getBebFPGATemp();
-int activate(int enable);
-int setNetworkParameter(enum NETWORKINDEX mode, int value);
-#endif
-
-
-
-
-// aquisition
-#if defined(EIGERD) || defined(GOTTHARD)
-int prepareAcquisition();
-#endif
-int startStateMachine();
-#ifdef VIRTUAL
-void* start_timer(void* arg);
-#endif
-int stopStateMachine();
-#ifndef JUNGFRAUD
-int startReadOut();
-#endif
-enum runStatus getRunStatus();
-void readFrame(int *ret, char *mess);
-#ifdef JUNGFRAUD
-u_int32_t runBusy(void);
-#endif
-
-
-//common
-int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod);
-int calculateDataBytes();
-int getTotalNumberOfChannels();
-int getTotalNumberOfChips();
-int getTotalNumberOfModules();
-int getNumberOfChannelsPerModule();
-int getNumberOfChipsPerModule();
-int getNumberOfDACsPerModule();
-int getNumberOfADCsPerModule();
-#ifdef EIGERD
-int getNumberOfGainsPerModule();
-int getNumberOfOffsetsPerModule();
-#endif
-int getNumberOfChannelsPerChip();
-
-// sync
-enum masterFlags setMaster(enum masterFlags arg);
-enum synchronizationMode setSynchronization(enum synchronizationMode arg);
-
-
-
-#endif
-#endif
diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.h
new file mode 120000
index 000000000..345b8c029
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.h
@@ -0,0 +1 @@
+../slsDetectorServer/slsDetectorFunctionList.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c
deleted file mode 100755
index fcbebfceb..000000000
--- a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/* A simple server in the internet domain using TCP
- The port number is passed as an argument */
-
-#include "sls_detector_defs.h"
-#include "slsDetectorServer_defs.h"
-
-#include "communication_funcs.h"
-#include "slsDetectorServer_funcs.h"
-
-#include
-#include
-#include
-#include
-
-
-extern int sockfd;
-
-
-void error(char *msg){
- perror(msg);
-}
-
-int main(int argc, char *argv[]){
- int portno, b;
- int retval=OK;
- int sd, fd;
- int debugflag = 0;
-
- // if socket crash, ignores SISPIPE, prevents global signal handler
- // subsequent read/write to socket gives error - must handle locally
- signal(SIGPIPE, SIG_IGN);
-
- // circumvent the basic tests
- if(argc > 1) {
- if(!strcasecmp(argv[1],"-debug")){
- debugflag = 1;
- argc=1;
- }
- }
-
-
-#ifdef STOP_SERVER
- char cmd[100];
-#endif
- if (argc==1) {
- portno = DEFAULT_PORTNO;
- cprintf(BLUE,
- "********************************************************\n"
- "********* opening control server on port %d **********\n"
- "********************************************************\n\n"
- , portno);
- b=1;
- basictests(debugflag);
-#ifdef STOP_SERVER
- sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
- //cprintf(BLUE,"cmd:%s\n", cmd);
- system(cmd);
-#endif
- } else {
- portno = DEFAULT_PORTNO+1;
- if ( sscanf(argv[1],"%d",&portno) == 0) {
- printf("could not open stop server: unknown port\n");
- return 1;
- }
- cprintf(BLUE,
- "********************************************************\n"
- "*********** opening stop server on port %d ***********\n"
- "********************************************************\n\n"
- , portno);
- b=0;
- }
-
- init_detector(b); //defined in slsDetectorServer_funcs
-
- sd=bindSocket(portno); //defined in communication_funcs
- sockfd=sd;
- if (getServerError(sd)) { //defined in communication_funcs
- printf("server error!\n");
- return -1;
- }
-
- /* assign function table */
- function_table(); //defined in slsDetectorServer_funcs
-#ifdef VERBOSE
- printf("function table assigned \n");
-#endif
-
-
- printf("\nReady...\n\n");
-
- /* waits for connection */
- while(retval!=GOODBYE) {
-#ifdef VERBOSE
- printf("\n");
-#endif
-#ifdef VERY_VERBOSE
- printf("Waiting for client call\n");
-#endif
- fd=acceptConnection(sockfd); //defined in communication_funcs
-#ifdef VERY_VERBOSE
- printf("Connection accepted\n");
-#endif
- if (fd>0) {
- retval=decode_function(fd); //defined in slsDetectorServer_funcs
-#ifdef VERY_VERBOSE
- printf("function executed\n");
-#endif
- closeConnection(fd); //defined in communication_funcs
-#ifdef VERY_VERBOSE
- printf("connection closed\n");
-#endif
- }
- }
-
- exitServer(sockfd); //defined in communication_funcs
- printf("Goodbye!\n");
-
- return 0;
-}
-
diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c
new file mode 120000
index 000000000..a7eb59acb
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c
@@ -0,0 +1 @@
+../slsDetectorServer/slsDetectorServer.c
\ No newline at end of file
diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_defs.h
index d8b9e82bf..e638f840e 100644
--- a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_defs.h
+++ b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_defs.h
@@ -1,8 +1,8 @@
/*
- * slsDetectorServer_defs.h
+ * mythen3Server_defs.h
*
* Created on: Jan 24, 2013
- * Author: l_maliakal_d
+ * Author: l_maliakal_d, changed my Marie A.
*/
#ifndef SLSDETECTORSERVER_DEFS_H_
@@ -15,79 +15,153 @@
-#define GOODBYE (-200)
-enum DACINDEX {vIpre, vIbias, Vrf, VrfSh, vIinSh, VdcSh, Vth2, VPL, Vth1, Vth3, Vtrim, casSh, cas, vIbiasSh, vIcin, VPH, NC, vIpreOut}; // Mythen 3.01
-#define DEFAULT_DAC_VALS {\
- 2150, /* vIpre */ \
- 1200, /* vIbias */ \
- 900, /* Vrf */ \
- 1050, /* VrfSh */ \
- 1400, /* vIinSh */ \
- 655, /* VdcSh */ \
- 850, /* Vth2 */ \
- 1400, /* VPL */ \
- 850, /* Vth1 */ \
- 850, /* Vth3 */ \
- 2294, /* Vtrim */ \
- 983, /* casSh */ \
- 1474, /* cas */ \
- 1200, /* vIbiasSh */ \
- 1600, /* vIcin */ \
- 1520, /* VPH */ \
- 0, /* NC */ \
- 1000 /* vIpreOut */ \
- };
+#define GOODBYE (-200)
+enum DACINDEX {vIpre, vIbias, Vrf, VrfSh, vIinSh, VdcSh, Vth2, VPL, Vth1, Vth3, Vtrim, casSh, cas, vIbiasSh, vIcin, VPH, NC, vIpreOut, V_D, V_CHIP, V_C, V_B, V_A, V_IO, V_LIM}; // Mythen 3.01
+enum PWRINDEX {PWR_IO, PWR_A, PWR_B, PWR_C, PWR_D, PWR_CHIP=-1, PWR_LIMIT=-1};
+enum CLKINDEX {RUN_CLK_C, ADC_CLK_C, SYNC_CLK_C, DBIT_CLK_C};
+
+#define DEFAULT_DAC_VALS { 2150, /* vIpre */ \
+ 1200, /* vIbias */ \
+ 900, /* Vrf */ \
+ 1050, /* VrfSh */ \
+ 1400, /* vIinSh */ \
+ 655, /* VdcSh */ \
+ 850, /* Vth2 */ \
+ 1400, /* VPL */ \
+ 850, /* Vth1 */ \
+ 850, /* Vth3 */ \
+ 2294, /* Vtrim */ \
+ 983, /* casSh */ \
+ 1474, /* cas */ \
+ 1200, /* vIbiasSh */ \
+ 1600, /* vIcin */ \
+ 1520, /* VPH */ \
+ 0, /* NC */ \
+ 1000 /* vIpreOut */ \
+ 0 /* V_D */ \
+ 0 /* V_CHIP */ \
+ 0 /* V_C */ \
+ 1335 /* V_B */ \
+ 1335 /* V_A */ \
+ 1350 /* V_IO */ \
+ };
+
+#define DEFAULT_DAC_NAMES { "vIpre", \
+ "vIbias", \
+ "Vrf", \
+ "VrfSh", \
+ "vIinSh", \
+ "VdcSh", \
+ "Vth2", \
+ "VPL", \
+ "Vth1", \
+ "Vth3", \
+ "Vtrim", \
+ "casSh", \
+ "cas", \
+ "vIbiasSh", \
+ "vIcin", \
+ "VPH", \
+ "NC", \
+ "vIpreOut" \
+ "v_d" \
+ "v_chip" \
+ "v_c" \
+ "v_b" \
+ "v_a" \
+ "v_io" \
+ };
+
+/*Hardware Definitions */
+#define NMAXMOD (1)
+#define NMOD (1)
+#define NCHAN (32)
+#define NCHIP (1)
+#define NADC (0)
+#define NDAC (24)
+#define NDAC_PER_SET (8)
+
+
+#define NPWR (5)
+#define MAX_DACVOLTVAL (2500) //mV
+#define MAX_DACVAL (4096) // dac val
+#define MAX_VCHIPVAL (2700) //mV /** name ???? */
+#define MIN_VCHIP_OFSTVAL (200) //mV /** name ???? */
+#define MIN_VCHIP_VAL (600) //mV /** name ???? */
-/*Hardware Definitions
-#define NMAXMOD (1)
-#define NMOD (1)
-#define NCHAN (256 * 256)
-#define NCHIP (4)
-#define NADC (0)
-#define NDAC (16)
-#define NGAIN (0)
-#define NOFFSET (0)
-*/
/** Default Parameters */
-#define DEFAULT_EXPTIME (10*1000) //ns
-
-/* Hardware Definitions */
-#define NMAXMOD (1)
-#define NMOD (1)
-#define NCHAN (256 * 256)
-#define NCHIP (8)
-#define NADC (0)
-#define NDAC (8)
-#define NDAC_OLDBOARD (16)
-#define DYNAMIC_RANGE (16)
-#define NUM_BITS_PER_PIXEL (DYNAMIC_RANGE / 8)
-#define DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
-#define IP_PACKETSIZE (0x2052)
-#define CLK_RUN (40) /* MHz */
-#define CLK_SYNC (20) /* MHz */
+#define DEFAULT_NUM_FRAMES (1)
+#define DEFAULT_NUM_CYCLES (1)
+#define DEFAULT_EXPTIME (200*1000) //ns
+#define DEFAULT_PERIOD (1*1000*1000) //ns
+#define DEFAULT_DELAY (0)
+#define DEFAULT_HIGH_VOLTAGE (0)
+#define DEFAULT_TIMING_MODE (AUTO_TIMING)
-// Hardware definitions
+/* Defines in the Firmware */
+#define FIX_PATT_VAL (0xACDC1980)
-#define NCHAN 36
-#define NCHIP 1
-#define NADC 9 //
+/* LTC2620 DAC DEFINES */
+#define LTC2620_DAC_CMD_OFST (20)
+#define LTC2620_DAC_CMD_MSK (0x0000000F << LTC2620_DAC_CMD_OFST)
+#define LTC2620_DAC_ADDR_OFST (16)
+#define LTC2620_DAC_ADDR_MSK (0x0000000F << LTC2620_DAC_ADDR_OFST)
+#define LTC2620_DAC_DATA_OFST (4)
+#define LTC2620_DAC_DATA_MSK (0x00000FFF << LTC2620_DAC_DATA_OFST)
-/* #ifdef CTB */
-/* #define NDAC 24 */
-/* #define NPWR 5 */
-/* #else */
-/* #define NDAC 16 */
-/* #define NPWR 0 */
-/* #endif */
-#define DAC_CMD_OFF 20
+#define LTC2620_DAC_CMD_WRITE (0x00000000 << LTC2620_DAC_CMD_OFST)
+#define LTC2620_DAC_CMD_SET (0x00000003 << LTC2620_DAC_CMD_OFST)
+#define LTC2620_DAC_CMD_POWER_DOWN (0x00000004 << LTC2620_DAC_CMD_OFST)
+#define LTC2620_DAC_NUMBITS (24)
-#define NMAXMODX 1
-#define NMAXMODY 1
-#define NMAXMOD (NMAXMODX*NMAXMODY)
+/** PLL Reconfiguration Registers */
+//https://www.altera.com/documentation/mcn1424769382940.html
+#define PLL_MODE_REG (0x00)
+#define PLL_STATUS_REG (0x01)
+#define PLL_START_REG (0x02)
+#define PLL_N_COUNTER_REG (0x03)
+#define PLL_M_COUNTER_REG (0x04)
+#define PLL_C_COUNTER_REG (0x05)
+#define PLL_PHASE_SHIFT_REG (0x06)
+
+#define PLL_SHIFT_NUM_SHIFTS_OFST (0)
+#define PLL_SHIFT_NUM_SHIFTS_MSK (0x0000FFFF << PLL_SHIFT_NUM_SHIFTS_OFST)
+
+#define PLL_SHIFT_CNT_SELECT_OFST (16)
+#define PLL_SHIFT_CNT_SELECT_MSK (0x0000001F << PLL_SHIFT_CNT_SELECT_OFST)
+#define PLL_SHIFT_CNT_SLCT_C0_VAL ((0x0 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C1_VAL ((0x1 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C2_VAL ((0x2 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C3_VAL ((0x3 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C4_VAL ((0x4 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C5_VAL ((0x5 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C6_VAL ((0x6 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C7_VAL ((0x7 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C8_VAL ((0x8 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C9_VAL ((0x9 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C10_VAL ((0x10 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C11_VAL ((0x11 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C12_VAL ((0x12 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C13_VAL ((0x13 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C14_VAL ((0x14 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C15_VAL ((0x15 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C16_VAL ((0x16 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+#define PLL_SHIFT_CNT_SLCT_C17_VAL ((0x17 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
+
+#define PLL_SHIFT_UP_DOWN_OFST (21)
+#define PLL_SHIFT_UP_DOWN_MSK (0x00000001 << PLL_SHIFT_UP_DOWN_OFST)
+#define PLL_SHIFT_UP_DOWN_NEG_VAL ((0x0 << PLL_SHIFT_UP_DOWN_OFST) & PLL_SHIFT_UP_DOWN_MSK)
+#define PLL_SHIFT_UP_DOWN_POS_VAL ((0x1 << PLL_SHIFT_UP_DOWN_OFST) & PLL_SHIFT_UP_DOWN_MSK)
+
+#define PLL_K_COUNTER_REG (0x07)
+#define PLL_BANDWIDTH_REG (0x08)
+#define PLL_CHARGEPUMP_REG (0x09)
+#define PLL_VCO_DIV_REG (0x1c)
+#define PLL_MIF_REG (0x1f)
+
+#define PLL_VCO_FREQ_MHZ 400
-#define NCHANS (NCHAN*NCHIP*NMAXMOD)
-#define NDACS (NDAC*NMAXMOD)
#endif /* SLSDETECTORSERVER_DEFS_H_ */
diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.c
deleted file mode 100755
index a38c95598..000000000
--- a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.c
+++ /dev/null
@@ -1,4996 +0,0 @@
-
-#include "sls_detector_defs.h"
-#include "slsDetectorServer_funcs.h"
-#include "slsDetectorFunctionList.h"
-#include "communication_funcs.h"
-#include "slsDetectorServer_defs.h"
-
-#include
-#include
-#include
-
-
-// Global variables
-extern int lockStatus;
-extern char lastClientIP[INET_ADDRSTRLEN];
-extern char thisClientIP[INET_ADDRSTRLEN];
-extern int differentClients;
-
-//defined in the detector specific Makefile
-#ifdef MYTHEND
-const enum detectorType myDetectorType=MYTHEN;
-#elif GOTTHARDD
-const enum detectorType myDetectorType=GOTTHARD;
-#elif EIGERD
-const enum detectorType myDetectorType=EIGER;
-#elif PICASSOD
-const enum detectorType myDetectorType=PICASSO;
-#elif MOENCHD
-const enum detectorType myDetectorType=MOENCH;
-#elif JUNGFRAUD
-const enum detectorType myDetectorType=JUNGFRAU;
-#elif MYTHEN3D
-const enum detectorType myDetectorType=MYTHEN3D;
-#else
-const enum detectorType myDetectorType=GENERIC;
-#endif
-
-int sockfd; // (updated in slsDetectorServer) as extern
-int (*flist[NUM_DET_FUNCTIONS])(int);
-char mess[MAX_STR_LENGTH];
-int dataBytes = 10;
-int isControlServer = 0;
-int debugflag = 0;
-
-int N_DAC=24;
-int N_PWR=5;
-
-int vPowerLimit = 1400; // mV
-
-/* initialization functions */
-
-int printSocketReadError() {
- cprintf(BG_RED, "Error reading from socket. Possible socket crash\n");
- return FAIL;
-}
-
-void basictests(int flag) {
- debugflag = flag;
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- checkFirmwareCompatibility(debugflag);
-#endif
-}
-
-
-void init_detector(int controlserver) {
-#ifdef VIRTUAL
- printf("This is a VIRTUAL detector\n");
-#endif
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- if (controlserver) {
- isControlServer = 1;
- initControlServer();
- }
- else initStopServer();
-#endif
- strcpy(mess,"dummy message");
- strcpy(lastClientIP,"none");
- strcpy(thisClientIP,"none1");
- lockStatus=0;
-}
-
-
-int decode_function(int file_des) {
- int fnum,n;
- int ret=FAIL;
-#ifdef VERBOSE
- printf( "\nreceive data\n");
-#endif
- n = receiveData(file_des,&fnum,sizeof(fnum),INT32);
- if (n <= 0) {
-#ifdef VERBOSE
- printf("ERROR reading from socket %d, %d %d (%s)\n", n, fnum, file_des, getFunctionName((enum detFuncs)fnum));
-#endif
- return FAIL;
- }
-#ifdef VERBOSE
- else
- printf("size of data received %d\n",n);
-#endif
-
-#ifdef VERBOSE
- printf(" calling function fnum=%d, (%s) located at 0x%x\n", fnum, getFunctionName((enum detFuncs)fnum), (unsigned int)flist[fnum]);
-#endif
- if (fnum<0 || fnum>=NUM_DET_FUNCTIONS) {
- cprintf(BG_RED,"Unknown function enum %d\n", fnum);
- ret=(M_nofunc)(file_des);
- }else
- ret=(*flist[fnum])(file_des);
- if (ret == FAIL)
- cprintf(RED, "Error executing the function = %d (%s)\n", fnum, getFunctionName((enum detFuncs)fnum));
- return ret;
-}
-
-
-const char* getFunctionName(enum detFuncs func) {
- switch (func) {
- case F_EXEC_COMMAND: return "F_EXEC_COMMAND";
- case F_GET_ERROR: return "F_GET_ERROR";
- case F_GET_DETECTOR_TYPE: return "F_GET_DETECTOR_TYPE";
- case F_SET_NUMBER_OF_MODULES: return "F_SET_NUMBER_OF_MODULES";
- case F_GET_MAX_NUMBER_OF_MODULES: return "F_GET_MAX_NUMBER_OF_MODULES";
- case F_SET_EXTERNAL_SIGNAL_FLAG: return "F_SET_EXTERNAL_SIGNAL_FLAG";
- case F_SET_EXTERNAL_COMMUNICATION_MODE: return "F_SET_EXTERNAL_COMMUNICATION_MODE";
- case F_GET_ID: return "F_GET_ID";
- case F_DIGITAL_TEST: return "F_DIGITAL_TEST";
- case F_ANALOG_TEST: return "F_ANALOG_TEST";
- case F_ENABLE_ANALOG_OUT: return "F_ENABLE_ANALOG_OUT";
- case F_CALIBRATION_PULSE: return "F_CALIBRATION_PULSE";
- case F_SET_DAC: return "F_SET_DAC";
- case F_GET_ADC: return "F_GET_ADC";
- case F_WRITE_REGISTER: return "F_WRITE_REGISTER";
- case F_READ_REGISTER: return "F_READ_REGISTER";
- case F_WRITE_MEMORY: return "F_WRITE_MEMORY";
- case F_READ_MEMORY: return "F_READ_MEMORY";
- case F_SET_CHANNEL: return "F_SET_CHANNEL";
- case F_GET_CHANNEL: return "F_GET_CHANNEL";
- case F_SET_ALL_CHANNELS: return "F_SET_ALL_CHANNELS";
- case F_SET_CHIP: return "F_SET_CHIP";
- case F_GET_CHIP: return "F_GET_CHIP";
- case F_SET_ALL_CHIPS: return "F_SET_ALL_CHIPS";
- case F_SET_MODULE: return "F_SET_MODULE";
- case F_GET_MODULE: return "F_GET_MODULE";
- case F_SET_ALL_MODULES: return "F_SET_ALL_MODULES";
- case F_SET_SETTINGS: return "F_SET_SETTINGS";
- case F_GET_THRESHOLD_ENERGY: return "F_GET_THRESHOLD_ENERGY";
- case F_SET_THRESHOLD_ENERGY: return "F_SET_THRESHOLD_ENERGY";
- case F_START_ACQUISITION: return "F_START_ACQUISITION";
- case F_STOP_ACQUISITION: return "F_STOP_ACQUISITION";
- case F_START_READOUT: return "F_START_READOUT";
- case F_GET_RUN_STATUS: return "F_GET_RUN_STATUS";
- case F_START_AND_READ_ALL: return "F_START_AND_READ_ALL";
- case F_READ_FRAME: return "F_READ_FRAME";
- case F_READ_ALL: return "F_READ_ALL";
- case F_SET_TIMER: return "F_SET_TIMER";
- case F_GET_TIME_LEFT: return "F_GET_TIME_LEFT";
- case F_SET_DYNAMIC_RANGE: return "F_SET_DYNAMIC_RANGE";
- case F_SET_READOUT_FLAGS: return "F_SET_READOUT_FLAGS";
- case F_SET_ROI: return "F_SET_ROI";
- case F_SET_SPEED: return "F_SET_SPEED";
- case F_EXECUTE_TRIMMING: return "F_EXECUTE_TRIMMING";
- case F_EXIT_SERVER: return "F_EXIT_SERVER";
- case F_LOCK_SERVER: return "F_LOCK_SERVER";
- case F_GET_LAST_CLIENT_IP: return "F_GET_LAST_CLIENT_IP";
- case F_SET_PORT: return "F_SET_PORT";
- case F_UPDATE_CLIENT: return "F_UPDATE_CLIENT";
- case F_CONFIGURE_MAC: return "F_CONFIGURE_MAC";
- case F_LOAD_IMAGE: return "F_LOAD_IMAGE";
- case F_SET_MASTER: return "F_SET_MASTER";
- case F_SET_SYNCHRONIZATION_MODE: return "F_SET_SYNCHRONIZATION_MODE";
- case F_READ_COUNTER_BLOCK: return "F_READ_COUNTER_BLOCK";
- case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK";
- case F_CALIBRATE_PEDESTAL: return "F_CALIBRATE_PEDESTAL";
- case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA";
- case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS";
- case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN";
- case F_WRITE_ADC_REG: return "F_WRITE_ADC_REG";
- case F_SET_COUNTER_BIT: return "F_SET_COUNTER_BIT";
- case F_PULSE_PIXEL: return "F_PULSE_PIXEL";
- case F_PULSE_PIXEL_AND_MOVE: return "F_PULSE_PIXEL_AND_MOVE";
- case F_PULSE_CHIP: return "F_PULSE_CHIP";
- case F_SET_RATE_CORRECT: return "F_SET_RATE_CORRECT";
- case F_GET_RATE_CORRECT: return "F_GET_RATE_CORRECT";
- case F_SET_NETWORK_PARAMETER: return "F_SET_NETWORK_PARAMETER";
- case F_PROGRAM_FPGA: return "F_PROGRAM_FPGA";
- case F_RESET_FPGA: return "F_RESET_FPGA";
- case F_POWER_CHIP: return "F_POWER_CHIP";
- case F_ACTIVATE: return "F_ACTIVATE";
- case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION";
- case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION";
- default: return "Unknown Function";
- }
-}
-
-void function_table() {
- flist[F_EXEC_COMMAND] = &exec_command;
- flist[F_GET_ERROR] = &get_error;
- flist[F_GET_DETECTOR_TYPE] = &get_detector_type;
- flist[F_SET_NUMBER_OF_MODULES] = &set_number_of_modules;
- flist[F_GET_MAX_NUMBER_OF_MODULES] = &get_max_number_of_modules;
- flist[F_SET_EXTERNAL_SIGNAL_FLAG] = &set_external_signal_flag;
- flist[F_SET_EXTERNAL_COMMUNICATION_MODE] = &set_external_communication_mode;
- flist[F_GET_ID] = &get_id;
- flist[F_DIGITAL_TEST] = &digital_test;
- flist[F_ANALOG_TEST] = &analog_test;
- flist[F_ENABLE_ANALOG_OUT] = &enable_analog_out;
- flist[F_CALIBRATION_PULSE] = &calibration_pulse;
- flist[F_SET_DAC] = &set_dac;
- flist[F_GET_ADC] = &get_adc;
- flist[F_WRITE_REGISTER] = &write_register;
- flist[F_READ_REGISTER] = &read_register;
- flist[F_WRITE_MEMORY] = &write_memory;
- flist[F_READ_MEMORY] = &read_memory;
- flist[F_SET_CHANNEL] = &set_channel;
- flist[F_GET_CHANNEL] = &get_channel;
- flist[F_SET_ALL_CHANNELS] = &set_all_channels;
- flist[F_SET_CHIP] = &set_chip;
- flist[F_GET_CHIP] = &get_chip;
- flist[F_SET_ALL_CHIPS] = &set_all_chips;
- flist[F_SET_MODULE] = &set_module;
- flist[F_GET_MODULE] = &get_module;
- flist[F_SET_ALL_MODULES] = &set_all_modules;
- flist[F_SET_SETTINGS] = &set_settings;
- flist[F_GET_THRESHOLD_ENERGY] = &get_threshold_energy;
- flist[F_SET_THRESHOLD_ENERGY] = &set_threshold_energy;
- flist[F_START_ACQUISITION] = &start_acquisition;
- flist[F_STOP_ACQUISITION] = &stop_acquisition;
- flist[F_START_READOUT] = &start_readout;
- flist[F_GET_RUN_STATUS] = &get_run_status;
- flist[F_START_AND_READ_ALL] = &start_and_read_all;
- flist[F_READ_FRAME] = &read_frame;
- flist[F_READ_ALL] = &read_all;
- flist[F_SET_TIMER] = &set_timer;
- flist[F_GET_TIME_LEFT] = &get_time_left;
- flist[F_SET_DYNAMIC_RANGE] = &set_dynamic_range;
- flist[F_SET_READOUT_FLAGS] = &set_readout_flags;
- flist[F_SET_ROI] = &set_roi;
- flist[F_SET_SPEED] = &set_speed;
- flist[F_EXECUTE_TRIMMING] = &execute_trimming;
- flist[F_EXIT_SERVER] = &exit_server;
- flist[F_LOCK_SERVER] = &lock_server;
- flist[F_GET_LAST_CLIENT_IP] = &get_last_client_ip;
- flist[F_SET_PORT] = &set_port;
- flist[F_UPDATE_CLIENT] = &update_client;
- flist[F_CONFIGURE_MAC] = &configure_mac;
- flist[F_LOAD_IMAGE] = &load_image;
- flist[F_SET_MASTER] = &set_master;
- flist[F_SET_SYNCHRONIZATION_MODE] = &set_synchronization;
- flist[F_READ_COUNTER_BLOCK] = &read_counter_block;
- flist[F_RESET_COUNTER_BLOCK] = &reset_counter_block;
- flist[F_CALIBRATE_PEDESTAL] = &calibrate_pedestal;
- flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga;
- flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits;
- flist[F_SET_CTB_PATTERN] = &set_ctb_pattern;
- flist[F_WRITE_ADC_REG] = &write_adc_register;
- flist[F_SET_COUNTER_BIT] = &set_counter_bit;
- flist[F_PULSE_PIXEL] = &pulse_pixel;
- flist[F_PULSE_PIXEL_AND_MOVE] = &pulse_pixel_and_move;
- flist[F_PULSE_CHIP] = &pulse_chip;
- flist[F_SET_RATE_CORRECT] = &set_rate_correct;
- flist[F_GET_RATE_CORRECT] = &get_rate_correct;
- flist[F_SET_NETWORK_PARAMETER] = &set_network_parameter;
- flist[F_PROGRAM_FPGA] = &program_fpga;
- flist[F_RESET_FPGA] = &reset_fpga;
- flist[F_POWER_CHIP] = &power_chip;
- flist[F_ACTIVATE] = &set_activate;
- flist[F_PREPARE_ACQUISITION] = &prepare_acquisition;
- flist[F_CLEANUP_ACQUISITION] = &cleanup_acquisition;
-
- // check
- if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) {
- cprintf(BG_RED,"The last detector function enum has reached its limit\nGoodbye!\n");
- exit(EXIT_FAILURE);
- }
-
-#ifdef VERYVERBOSE
- {
- int i=0;
- for (i = 0; i < NUM_DET_FUNCTIONS ; i++) {
- printf("function fnum=%d, (%s) located at 0x%x\n", i, getFunctionName((enum detFuncs)i), (unsigned int)flist[i]);
- }
- }
-#endif
-}
-
-
-int M_nofunc(int file_des){
- int ret=FAIL,ret1=FAIL;
- int n=0;
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- sprintf(mess,"Unrecognized Function. Please do not proceed.\n");
- cprintf(BG_RED,"Error: %s",mess);
- n = sendData(file_des,&ret1,sizeof(ret1),INT32);
- n = sendData(file_des,mess,sizeof(mess),OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-/* functions called by client */
-
-
-
-int exec_command(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- char cmd[MAX_STR_LENGTH]="";
- int sysret=0;
-
- // receive arguments
- n = receiveData(file_des,cmd,MAX_STR_LENGTH,OTHER);
- if (n < 0) return printSocketReadError();
-
- // execute action if the arguments correctly arrived
-#ifdef VERBOSE
- printf("executing command %s\n", cmd);
-#endif
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- } else {
- sysret=system(cmd);
- //should be replaced by popen
- if (sysret==0) {
- sprintf(mess,"Succeeded\n");
- } else {
- ret = FAIL;
- sprintf(mess,"Executing Command failed\n");
- cprintf(RED, "Warning: %s", mess);
- }
- }
-
- ret1=ret;
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-int get_error(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Get Error) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-int get_detector_type(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- enum detectorType retval=-1;
-
- // execute action
- retval=myDetectorType;
-#ifdef VERBOSE
- printf("Returning detector type %d\n",retval);
-#endif
-
- if (differentClients)
- ret=FORCE_UPDATE;
-
- // send ok / fail
- n += sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-
-
-}
-
-
-
-
-int set_number_of_modules(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=0;
- int arg[2]={-1,-1};
- sprintf(mess,"set number of modules failed\n");
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
- enum dimension dim=arg[0];
- int nm=arg[1];
-
- // execute action
-#ifdef VERBOSE
- printf("Setting the number of modules in dimension %d to %d\n",dim,nm );
-#endif
- if (lockStatus && differentClients && nm!=GET_FLAG) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- retval=setNMod(nm, dim);
- dataBytes=calculateDataBytes();
- }
-#endif
-
- if (retval==nm || nm==GET_FLAG) {
- ret=OK;
- if (differentClients)
- ret=FORCE_UPDATE;
- } else
- ret=FAIL;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int get_max_number_of_modules(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- enum dimension arg=0;
- sprintf(mess,"get max number of modules failed\n");
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
-#ifdef VERBOSE
- printf("Getting the max number of modules in dimension %d \n",arg);
-#endif
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- retval=getNModBoard(arg);
-#endif
-#ifdef VERBOSE
- printf("Max number of module in dimension %d is %d\n",arg,retval );
-#endif
- if (differentClients && ret==OK) {
- ret=FORCE_UPDATE;
- }
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int set_external_signal_flag(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- enum externalSignalFlag retval=GET_EXTERNAL_SIGNAL_FLAG;
- sprintf(mess,"set external signal flag failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Set External Signal Flag) is not implemented for this detector\n");
- cprintf(RED, "%s", mess);
-#else
-
- // receive arguments
- int arg[2]={-1,-1};
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- int signalindex=arg[0];
- enum externalSignalFlag flag=arg[1];
-
- // execute action
- if (lockStatus && differentClients && flag!=GET_EXTERNAL_SIGNAL_FLAG) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else{
-#ifdef VERBOSE
- printf("Setting external signal %d to flag %d\n",signalindex,flag);
-#endif
- switch (flag) {
- case GET_EXTERNAL_SIGNAL_FLAG:
- retval=getExtSignal(signalindex);
- break;
- default:
- retval=setExtSignal(signalindex,flag);
- if (retval!=flag) {
- ret=FAIL;
- sprintf(mess,"External signal %d flag should be 0x%04x but is 0x%04x\n", signalindex, flag, retval);
- cprintf(RED, "%s", mess);
- }
- break;
- }
-#ifdef VERBOSE
- printf("Set to flag %d\n",retval);
-#endif
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-
-}
-
-
-int set_external_communication_mode(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- enum externalCommunicationMode arg=GET_EXTERNAL_COMMUNICATION_MODE;
- enum externalCommunicationMode retval=GET_EXTERNAL_COMMUNICATION_MODE;
- sprintf(mess,"set external communication mode failed\n");
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
-#ifdef VERBOSE
- printf("Setting external communication mode to %d\n", arg);
-#endif
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- switch(arg){
-#ifdef EIGERD
- case GET_EXTERNAL_COMMUNICATION_MODE:
- case AUTO_TIMING:
- case TRIGGER_EXPOSURE:
- case GATE_FIX_NUMBER:
- case BURST_TRIGGER:
-#elif JUNGFRAUD
- case GET_EXTERNAL_COMMUNICATION_MODE:
- case AUTO_TIMING:
- case TRIGGER_EXPOSURE:
-#endif
- retval=setTiming(arg);
- break;
- default:
- ret = FAIL;
- sprintf(mess,"Timing mode (%d) is not implemented for this detector\n",(int)arg);
- cprintf(RED, "Warning: %s", mess);
- break;
- }
-#ifdef VERBOSE
- if(ret==OK)
- printf("retval:%d\n",retval);
-#endif
- if (ret==OK && differentClients==1)
- ret=FORCE_UPDATE;
-
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int get_id(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- enum idMode arg=0;
- int imod=-1;
- int64_t retval=-1;
- sprintf(mess,"get id failed\n");
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- if (arg == MODULE_FIRMWARE_VERSION) {
- n = receiveData(file_des,&imod,sizeof(imod),INT32);
- if (n < 0) return printSocketReadError();
- }
-
- // execute action
-#ifdef VERBOSE
- printf("Getting id %d\n", arg);
-#endif
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- switch (arg) {
-#ifdef MYTHEND
- case MODULE_SERIAL_NUMBER:
- case MODULE_FIRMWARE_VERSION:
-#ifdef VERBOSE
- printf("of module %d\n", imod);
-#endif
-
- if (imod>=0 && imod 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Digital Test) is not implemented for this detector\n");
- cprintf(RED, "%s", mess);
-#else
-
- enum digitalTestMode arg=0;
- int imod=-1;
- int ival=-1;
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- if (arg == CHIP_TEST) {
- n = receiveData(file_des,&imod,sizeof(imod),INT32);
- if (n < 0) return printSocketReadError();
- }
-
- if (arg == DIGITAL_BIT_TEST) {
- n = receiveData(file_des,&ival,sizeof(ival),INT32);
- if (n < 0) return printSocketReadError();
- }
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- } else {
-#ifdef VERBOSE
- printf("Digital test mode %d\n",arg );
-#endif
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- switch (arg) {
-
-#ifdef GOTTHARD
- case DIGITAL_BIT_TEST:
- retval=0;
- break;
-
-#elif MYTHEND
- case CHIP_TEST:
-#ifdef VERBOSE
- printf("of module %d\n", imod);
-#endif
- if (imod>=0 && imod 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-int enable_analog_out(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Enable Analog Out) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-int calibration_pulse(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Calibration Pulse) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int set_dac(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int arg[3]={-1,-1,-1};
- int val=-1;
- enum dacIndex ind=0;
- int imod=-1;
- double retval[2]={-1,-1};
- int mV=0;
- sprintf(mess,"set DAC failed\n");
-
- // receive arguments
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- ind=arg[0];
- imod=arg[1];
- mV=arg[2];
-
- if (mV)
- printf("DAC will be set in mV %d!\n",mV);
- else
- printf("DAC will be set in DACu! %d\n", mV);
-
- n = receiveData(file_des,&val,sizeof(val),INT32);
- if (n < 0) return printSocketReadError();
-
- // checks
-#ifdef MYTHEND
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- if (imod>=getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"Module number %d out of range\n",imod);
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
-#endif
- // check if dac exists for this detector
- enum DACINDEX idac=0;
-#ifdef JUNGFRAUD
- if ((ind != HV_NEW) && (ind >= NDAC_OLDBOARD)) { //for compatibility with old board
- ret = FAIL;
- sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind);
- cprintf(RED, "Warning: %s", mess);
- }else
- idac = ind;
-#else
- switch (ind) {
-#ifdef MYTHEND
- case TRIMBIT_SIZE: //ind = VTRIM;
- case THRESHOLD:
- case SHAPER1:
- case SHAPER2:
- case CALIBRATION_PULSE:
- case PREAMP:
- break;
-#elif GOTTHARDD
- case G_VREF_DS :
- break;
- case G_VCASCN_PB:
- break;
- case G_VCASCP_PB:
- break;
- case G_VOUT_CM:
- break;
- case G_VCASC_OUT:
- break;
- case G_VIN_CM:
- break;
- case G_VREF_COMP:
- break;
- case G_IB_TESTC:
- break;
- case HV_POT:
- break;
-#elif EIGERD
- case TRIMBIT_SIZE:
- idac = VTR;
- break;
- case THRESHOLD:
- idac = VTHRESHOLD;
- break;
- case E_SvP:
- idac = SVP;
- break;
- case E_SvN:
- idac = SVN;
- break;
- case E_Vtr:
- idac = VTR;
- break;
- case E_Vrf:
- idac = VRF;
- break;
- case E_Vrs:
- idac = VRS;
- break;
- case E_Vtgstv:
- idac = VTGSTV;
- break;
- case E_Vcmp_ll:
- idac = VCMP_LL;
- break;
- case E_Vcmp_lr:
- idac = VCMP_LR;
- break;
- case E_cal:
- idac = CAL;
- break;
- case E_Vcmp_rl:
- idac = VCMP_RL;
- break;
- case E_Vcmp_rr:
- idac = VCMP_RR;
- break;
- case E_rxb_rb:
- idac = RXB_RB;
- break;
- case E_rxb_lb:
- idac = RXB_LB;
- break;
- case E_Vcp:
- idac = VCP;
- break;
- case E_Vcn:
- idac = VCN;
- break;
- case E_Vis:
- idac = VIS;
- break;
- case HV_NEW:
- break;
- case IO_DELAY:
- break;
- /*
-#elif JUNGFRAUD
- case V_DAC0:
- idac = VB_COMP;
- break;
- case V_DAC1:
- idac = VDD_PROT;
- break;
- case V_DAC2:
- idac = VIN_COM;
- break;
- case V_DAC3:
- idac = VREF_PRECH;
- break;
- case V_DAC4:
- idac = VB_PIXBUF;
- break;
- case V_DAC5:
- idac = VB_DS;
- break;
- case V_DAC6:
- idac = VREF_DS;
- break;
- case V_DAC7:
- idac = VREF_COMP;
- break;
- case HV_POT:
- break;
- */
-#elif MYTHEN3D
- case M_vIpre:
- idac = vIpre;
- break;
- case M_Vrf:
- idac = Vrf;
- break;
- case M_VrfSh:
- idac = VrfSh;
- break;
- case M_Vth1:
- idac = Vth1;
- break;
- case M_Vth2:
- idac = Vth2;
- break;
- case M_Vth3:
- idac = Vth3;
- break;
- case M_VPL:
- idac = VPL;
- break;
- case M_VPH:
- idac = VPH;
- break;
- case M_Vtrim:
- idac = Vtrim;
- break;
- case V_POWER_A:
- case V_POWER_B:
- case V_POWER_C:
- case V_POWER_D:
- case V_POWER_IO:
- case V_POWER_CHIP:
- case V_LIMIT:
- break;
-#endif
- default:
- ret = FAIL;
- sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind);
- cprintf(RED, "Warning: %s", mess);
- break;
- }
-#endif
-
- // execute action
-#ifdef VERBOSE
- printf("Setting DAC %d of module %d to %d \n", idac, imod, val);
-#endif
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- double temp;
- if (ret==OK) {
- if (differentClients && lockStatus && val!=-1) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
- else {
-#ifdef EIGERD
- //iodelay
- if(ind == IO_DELAY)
- retval[0] = setIODelay(val,imod);
- //high voltage
- else
-#endif
-// if((ind == HV_POT) || (ind == HV_NEW)) {
-// retval[0] = setHighVoltage(val);
-// #ifdef EIGERD
-// if ((retval[0] != SLAVE_HIGH_VOLTAGE_READ_VAL) && (retval[0] < 0)) {
-// ret = FAIL;
-// if(retval[0] == -1)
-// sprintf(mess, "Setting high voltage failed.Bad value %d. The range is from 0 to 200 V.\n",val);
-// else if(retval[0] == -2)
-// strcpy(mess, "Setting high voltage failed. Serial/i2c communication failed.\n");
-// else if(retval[0] == -3)
-// strcpy(mess, "Getting high voltage failed. Serial/i2c communication failed.\n");
-// cprintf(RED, "Warning: %s", mess);
-// }
-// #endif
-// }
- if(ind == V_POWER_A || ind == V_POWER_B || ind == V_POWER_IO){
- if(mV){
-
- if( val >=0 && val <=vPowerLimit){
- retval[1] = setPower(ind,val); // in mV
- }
- else{
- printf("********power %d exceeds voltage limits", ind);
- }
- }
- else{
- printf("********power %d should be set in mV instead od DACu", ind);
- }
- }
- else if(ind == V_LIMIT){
- if(mV){ // without safetycheck
- retval[1] = setPower(ind, val);
- }
- else{
- printf("********power %d should be set in mV instead od DACu", ind);
- }
- }
- //dac:
- else{
- if(mV && (val>0 && val<2500)){ // val given in mV, check taht val is not out of range
- retval[1] = setDAC(idac,val,imod,mV);
- retval[0] = retval[1]*4095./2500.; // convert to DACu (for later printout)
- }
- else if(!mV && (val>0 && val<4095)){ // val given in DACu
- retval[0] = setDAC(idac,val,imod,mV);
- retval[1] = retval[0] *2500/4095; // convert to mV
- }
-
-#ifdef EIGERD
- if(val != -1) {
- //changing dac changes settings to undefined
- switch(idac){
- case VCMP_LL:
- case VCMP_LR:
- case VCMP_RL:
- case VCMP_RR:
- case VRF:
- case VCP:
- setSettings(UNDEFINED,-1);
- cprintf(RED,"Settings has been changed to undefined (changed specific dacs)\n");
- break;
- default:
- break;
- }
- }
-#endif
- //check
- if(retval[0]==-1 || retval[1] == -1){// something in setDAC failed (should never occur)
- ret = FAIL;
- sprintf(mess,"Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp);
- cprintf(RED, "Warning: %s", mess);
- }
- if(mV)
- temp = retval[1];
- else
- temp = retval[0];
- if ((abs(temp-val)<=5) || val==-1) { // ???
- ret=OK;
- }
- else {
- ret = FAIL;
- sprintf(mess,"Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp);
- cprintf(RED, "Warning: %s", mess);
- }
- } // end else dac
- } // end else "detector not locked"
- } // end if ret==OK
-#endif
-#ifdef VERBOSE
- printf("DAC set to %d in dac units and %d mV\n", retval[0],retval[1]);
-#endif
-
- if(ret == OK && differentClients)
- ret=FORCE_UPDATE;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-int get_adc(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int arg[2]={-1,-1};
- int retval=-1;
- enum dacIndex ind=0;
- int imod=-1;
- sprintf(mess,"get ADC failed\n");
-
- // receive arguments
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
- ind=arg[0];
- imod=arg[1];
-
-#ifdef MYTHEND
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- if (imod>=getTotalNumberOfModules() || imod<0) {
- ret = FAIL;
- sprintf(mess,"Module number %d out of range\n",imod);
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
-#endif
-
- enum ADCINDEX iadc=0;
- switch (ind) {
-#ifdef EIGERD
- case TEMPERATURE_FPGAEXT:
- iadc = TEMP_FPGAEXT;
- break;
- case TEMPERATURE_10GE:
- iadc = TEMP_10GE;
- break;
- case TEMPERATURE_DCDC:
- iadc = TEMP_DCDC;
- break;
- case TEMPERATURE_SODL:
- iadc = TEMP_SODL;
- break;
- case TEMPERATURE_SODR:
- iadc = TEMP_SODR;
- break;
- case TEMPERATURE_FPGA:
- iadc = TEMP_FPGA;
- break;
- case TEMPERATURE_FPGA2:
- iadc = TEMP_FPGAFEBL;
- break;
- case TEMPERATURE_FPGA3:
- iadc = TEMP_FPGAFEBR;
- break;
-#endif
-#if defined(GOTTHARD) || defined(JUNGFRAUD)
- case TEMPERATURE_FPGA:
- iadc = TEMP_FPGA;
- break;
- case TEMPERATURE_ADC:
- iadc = TEMP_ADC;
- break;
-#endif
- default:
- ret = FAIL;
- sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind);
- cprintf(RED, "Warning: %s", mess);
- break;
- }
-
-#ifdef VERBOSE
- printf("Getting ADC %d of module %d\n", iadc, imod);
-#endif
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- if (ret==OK)
- retval=getADC(iadc,imod);
-#endif
-#ifdef VERBOSE
- printf("ADC is %f\n", retval);
-#endif
-
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int write_register(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"write to register failed\n");
-
- // receive arguments
- int arg[2]={-1,-1};
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
- int addr=arg[0];
- int val=arg[1];
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("writing to register 0x%x data 0x%x\n", addr, val);
-#endif
- retval=writeRegister(addr,val);
- if (retval!=val) {
- ret = FAIL;
- sprintf(mess,"Writing to register 0x%x failed: wrote 0x%x but read 0x%x\n", addr, val, retval);
- cprintf(RED, "Warning: %s", mess);
- }
- }
-#endif
-#ifdef VERBOSE
- printf("Data set to 0x%x\n", retval);
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-
-}
-
-
-
-
-
-int read_register(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"read register failed\n");
-
- // receive arguments
- int arg=0;
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
- int addr=arg;
-
- // execute action
-#ifdef VERBOSE
- printf("reading register 0x%x\n", addr);
-#endif
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- retval=readRegister(addr);
-#endif
-#ifdef VERBOSE
- printf("Returned value 0x%x\n", retval);
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int write_memory(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Write Memory) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-int read_memory(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Read Memory) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-int set_channel(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"set channel failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Set Channel) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- sls_detector_channel myChan;
- n=receiveChannel(file_des, &myChan);
- if (n < 0) return printSocketReadError();
-
- // execute action
-#ifdef VERBOSE
- printf("Setting channel\n");
- printf("channel number is %d, chip number is %d, module number is %d, register is %lld\n", myChan.chan,myChan.chip, myChan.module, myChan.reg);
-#endif
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else if (myChan.chan>=getNumberOfChannelsPerChip()) {
- ret = FAIL;
- sprintf(mess,"channel number %d too large!\n",myChan.chan);
- cprintf(RED, "Warning: %s", mess);
- }
- else if (myChan.chip>=getNumberOfChipsPerModule()) {
- ret = FAIL;
- sprintf(mess,"chip number %d too large!\n",myChan.chip);
- cprintf(RED, "Warning: %s", mess);
- }
- else if (myChan.module>=getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"module number %d too large!\n",myChan.module);
- cprintf(RED, "Warning: %s", mess);
- }
- else
- retval=setChannel(myChan);
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int get_channel(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sls_detector_channel retval;
- sprintf(mess,"get channel failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Get Channel) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg[3]={-1,-1,-1};
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- int ichan=arg[0];
- int ichip=arg[1];
- int imod=arg[2];
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- if (ichan>=getNumberOfChannelsPerChip()) {
- ret=FAIL;
- sprintf(mess, "channel number %d too large!\n",myChan.chan);
- cprintf(RED, "Warning: %s", mess);
- } else
- retval.chan=ichan;
- if (ichip>=getNumberOfChipsPerModule()) {
- ret=FAIL;
- sprintf(mess, "chip number %d too large!\n",myChan.chip);
- cprintf(RED, "Warning: %s", mess);
- } else
- retval.chip=ichip;
-
- if (imod>=getTotalNumberOfModules()) {
- ret=FAIL;
- sprintf(mess, "module number %d too large!\n",myChan.module);
- cprintf(RED, "Warning: %s", mess);
- } else {
- retval.module=imod;
- ret=getChannel(&retval);
-#ifdef VERBOSE
- printf("Returning channel %d %d %d, 0x%llx\n", retval.chan, retval.chip, retval.mod, (retval.reg));
-#endif
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- ret=sendChannel(file_des, &retval);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-int set_all_channels(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Set All Channels) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int set_chip(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"set chip failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Set Channel) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
- sls_detector_chip myChip;
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- myChip.nchan=getNumberOfChannelsPerChip();
- int *ch(int*)malloc((myChip.nchan)*sizeof(int));
- myChip.chanregs=ch;
-
- // receive arguments
- n=receiveChip(file_des, &myChip);
-#ifdef VERBOSE
- printf("Chip received\n");
-#endif
- if(n < 0) return FAIL;
-
- // execute action
- if (differentClients==1 && lockStatus==1) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
- else{
-#ifdef VERBOSE
- printf("Setting chip\n");
- printf("chip number is %d, module number is %d, register is %d, nchan %d\n",myChip.chip, myChip.module, myChip.reg, myChip.nchan);
-#endif
- if (myChip.chip>=getNumberOfChipsPerModule()) {
- ret = FAIL;
- sprintf(mess,"chip number %d too large!\n",myChan.chip);
- cprintf(RED, "Warning: %s", mess);
- }
- else if (myChip.module>=getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"module number %d too large!\n",myChan.module);
- cprintf(RED, "Warning: %s", mess);
- }
- else
- retval=setChip(myChip);
- }
- free(ch);
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int get_chip(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sls_detector_chip retval;
- sprintf(mess,"get chip failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Set Channel) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg[2]={-1,-1};
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- int ichip=arg[0];
- int imod=arg[1];
-
- // execute action
- if (ichip>=getNumberOfChipsPerModule()) {
- ret = FAIL;
- sprintf(mess,"channel number %d too large!\n",myChan.chan);
- cprintf(RED, "Warning: %s", mess);
- } else
- retval.chip=ichip;
-
- if (imod>=getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"module number %d too large!\n",imod);
- cprintf(RED, "Warning: %s", mess);
- } else
- retval.module=imod;
-
- if (ret==OK)
- ret=getChip(&retval);
-#endif
-#ifdef VERBOSE
- printf("Returning chip %d %d\n", ichip, imod);
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- ret=sendChip(file_des, &retval);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int set_all_chips(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Set All Chips) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int set_module(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sls_detector_module myModule;
- int retval=-1;
-#ifdef EIGERD
- int myIODelay=-1;
- int myTau=-1;
- int myEV=-1;
-#endif
- sprintf(mess,"set module failed\n");
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- int *myDac=NULL;
- int *myAdc=NULL;
- int *myChip = NULL;
- int *myChan = NULL;
-
- myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int));
- if (getNumberOfDACsPerModule() > 0 && myDac == NULL) {
- ret = FAIL;
- sprintf(mess,"could not allocate dacs\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- myModule.dacs=myDac;
- myAdc=(int*)malloc(getNumberOfADCsPerModule()*sizeof(int));
- if (getNumberOfADCsPerModule() > 0 && myAdc == NULL) {
- ret = FAIL;
- sprintf(mess,"could not allocate adcs\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- myModule.adcs=myAdc;
- //no chips and chans allocated for jungfrau, too much memory
-#ifdef JUNGFRAUD
- myModule.chipregs=NULL;
- myModule.chanregs=NULL;
-#else
- myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int));
- if (getNumberOfChipsPerModule() > 0 && myChip == NULL) {
- ret = FAIL;
- sprintf(mess,"could not allocate chips\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- myModule.chipregs=myChip;
- myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int));
- if (getNumberOfChannelsPerModule() > 0 && myChan == NULL) {
- ret = FAIL;
- sprintf(mess,"could not allocate chans\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- myModule.chanregs=myChan;
-#endif
- myModule.nchip=getNumberOfChipsPerModule();
- myModule.nchan=getNumberOfChannelsPerModule();
- myModule.ndac=getNumberOfDACsPerModule();
- myModule.nadc=getNumberOfADCsPerModule();
-
-
- // receive arguments
-#ifdef VERBOSE
- printf("Setting module\n");
-#endif
- n=receiveModuleGeneral(file_des, &myModule,
-#ifdef JUNGFRAUD
- 0 //0 is to receive partially (without trimbits etc.)
-#else
- 1
-#endif
- );
- if (n<0) return FAIL;
-#ifdef VERBOSE
- printf("module number is %d,register is %d, nchan %d, nchip %d, ndac %d, nadc %d, gain %f, offset %f\n",
- myModule.module, myModule.reg, myModule.nchan, myModule.nchip, myModule.ndac, myModule.nadc, myModule.gain,myModule.offset);
-#endif
-#ifdef EIGERD
- n = receiveData(file_des,&myIODelay,sizeof(myIODelay),INT32);
- if (n<0) return FAIL;
- n = receiveData(file_des,&myTau,sizeof(myTau),INT32);
- if (n<0) return FAIL;
- n = receiveData(file_des,&myEV,sizeof(myEV),INT32);
- if (n<0) return FAIL;
-#ifdef VERBOSE
- printf("IO Delay:%d\n",myIODelay);
- printf("Tau:%d\n",myTau);
- printf("eV:%d\n",myEV);
-#endif
-#endif
-#ifndef JUNGFRAUD
- }
- }
-#endif
- }
- }
-
- //check settings index
- if (ret==OK) {
-#ifdef MYTHEND
- if (myModule.module>=getNModBoard()) {
- ret = FAIL;
- sprintf(mess,"Module Number to Set Module (%d) is too large\n", myModule.module);
- cprintf(RED, "Warning: %s", mess);
- }
- if (myModule.module<0)
- myModule.module=ALLMOD;
-#endif
-#if defined(JUNGFRAUD) || defined(EIGERD)
- switch(myModule.reg){
- case GET_SETTINGS:
- case UNINITIALIZED:
-#ifdef EIGERD
- case STANDARD:
- case HIGHGAIN:
- case LOWGAIN:
- case VERYHIGHGAIN:
- case VERYLOWGAIN:
-#elif JUNGFRAUD
- case DYNAMICGAIN:
- case DYNAMICHG0:
- case FIXGAIN1:
- case FIXGAIN2:
- case FORCESWITCHG1:
- case FORCESWITCHG2:
-#endif
- break;
- default:
- ret = FAIL;
- sprintf(mess,"Setting (%d) is not implemented for this detector\n", myModule.reg);
- cprintf(RED, "Warning: %s", mess);
- break;
- }
- }
-#endif
-
-
- // execute action
- if (ret==OK) {
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef EIGERD
- //set dacs, trimbits and iodelay
- ret=setModule(myModule, myIODelay);
- //set threshhold
- if (myEV >= 0)
- setThresholdEnergy(myEV,-1);
- else {
- //changes settings to undefined (loading a random trim file)
- setSettings(UNDEFINED,-1);
- cprintf(RED,"Settings has been changed to undefined (random trim file)\n");
- }
- //rate correction
- //switch off rate correction: no value read from load calib/load settings)
- if(myTau == -1){
- if(getRateCorrectionEnable()){
- setRateCorrection(0);
- ret = FAIL;
- strcat(mess,"Cannot set Rate correction. No default tau provided. Deactivating Rate Correction\n");
- cprintf(RED, "Warning: %s", mess);
- }
- }
- //normal tau value (only if enabled)
- else{
- setDefaultSettingsTau_in_nsec(myTau);
- if (getRateCorrectionEnable()){
- int64_t retvalTau = setRateCorrection(myTau);
- if(myTau != retvalTau){
- cprintf(RED,"%s",mess);
- ret=FAIL;
- }
- }
- }
- retval = getSettings();
-#else
- retval=setModule(myModule);
- if (retval != myModule.reg)
- ret = FAIL;
-#endif
- if(myChip != NULL) free(myChip);
- if(myChan != NULL) free(myChan);
- if(myDac != NULL) free(myDac);
- if(myAdc != NULL) free(myAdc);
- }
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-
-
-int get_module(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int arg=-1;
- int imod=-1;
- sls_detector_module myModule;
- sprintf(mess,"get module failed\n");
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
- imod=arg;
-
- // execute action
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- int *myDac=NULL;
- int *myAdc=NULL;
- int *myChip = NULL;
- int *myChan = NULL;
-
- if (imod<0 || imod>getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"Module Index (%d) is out of range\n", imod);
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int));
- if (getNumberOfDACsPerModule() > 0 && myDac == NULL) {
- ret = FAIL;
- sprintf(mess,"could not allocate dacs\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- myModule.dacs=myDac;
- myAdc=(int*)malloc(getNumberOfADCsPerModule()*sizeof(int));
- if (getNumberOfADCsPerModule() > 0 && myAdc == NULL) {
- ret = FAIL;
- sprintf(mess,"could not allocate adcs\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- myModule.adcs=myAdc;
- //no chips and chans allocated for jungfrau, too much memory
-#ifdef JUNGFRAUD
- myModule.chipregs=NULL;
- myModule.chanregs=NULL;
-#else
- myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int));
- if (getNumberOfChipsPerModule() > 0 && myChip == NULL) {
- ret = FAIL;
- sprintf(mess,"could not allocate chips\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- myModule.chipregs=myChip;
- myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int));
- if (getNumberOfChannelsPerModule() > 0 && myChan == NULL) {
- ret = FAIL;
- sprintf(mess,"could not allocate chans\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- myModule.chanregs=myChan;
-#endif
- myModule.nchip=getNumberOfChipsPerModule();
- myModule.nchan=getNumberOfChannelsPerModule();
- myModule.ndac=getNumberOfDACsPerModule();
- myModule.nadc=getNumberOfADCsPerModule();
- myModule.module=imod;
- getModule(&myModule);
-#ifdef VERBOSE
- printf("Returning module %d of register %x\n", imod, myModule.reg);
-#endif
-#ifndef JUNGFRAUD
- }
- }
-#endif
- }
- }
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- ret=sendModuleGeneral(file_des, &myModule,
-#ifdef JUNGFRAUD
- 0 //0 is to receive partially (without trimbits etc.)
-#else
- 1
-#endif
- );
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- if(myChip != NULL) free(myChip);
- if(myChan != NULL) free(myChan);
- if(myDac != NULL) free(myDac);
- if(myAdc != NULL) free(myAdc);
-#endif
-
- // return ok / fail
- return ret;
-
-}
-
-
-
-int set_all_modules(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Set All Modules) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int set_settings(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int arg[2]={-1,-1};
- int retval=-1;
- int imod=-1;
- enum detectorSettings isett=-1;
- sprintf(mess,"set settings failed\n");
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
- imod=arg[1];
- isett=arg[0];
-
- // execute action
- if (differentClients && lockStatus && isett!=GET_SETTINGS) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else if (imod>=getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"Module number %d out of range\n",imod);
- cprintf(RED, "Warning: %s", mess);
- }
- else {
-#ifdef VERBOSE
- printf("Changing settings of module %d to %d\n", imod, isett);
-#endif
- retval=setSettings(isett, imod);
-#ifdef VERBOSE
- printf("Settings changed to %d\n", isett);
-#endif
- if (retval==isett || isett<0) {
- ret=OK;
- } else {
- ret = FAIL;
- sprintf(mess,"Changing settings of module %d: wrote %d but read %d\n", imod, isett, retval);
- cprintf(RED, "Warning: %s", mess);
- }
- }
-#endif
-
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int get_threshold_energy(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"get threshold energy failed\n");
-
-#if !defined(MYTHEND) && !defined(EIGERD)
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Get Threshold Energy) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int imod=-1;
- n = receiveData(file_des,&imod,sizeof(imod),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
-#ifdef VERBOSE
- printf("Getting threshold energy of module %d\n", imod);
-#endif
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- if (imod>=getTotalNumberOfModules()) {
- ret=FAIL;
- sprintf(mess,"Module number %d out of range\n",imod);
- }
- else {
- retval=getThresholdEnergy(imod);
-#ifdef VERBOSE
- printf("Threshold is %d eV\n", retval);
-#endif
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int set_threshold_energy(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"set thhreshold energy failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
-#ifdef EIGERD
- sprintf(mess,"Function (Set Threshold Energy) is only implemented via Set Settings for this detector\n");
-#else
- sprintf(mess,"Function (Set Threshold Energy) is not implemented for this detector\n");
-#endif
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg[3]={-1,-1,-1};
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- int ethr=arg[0];
- int imod=arg[1];
- enum detectorSettings isett=arg[2];
- if (differentClients && lockStatus) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else if (imod>=getTotalNumberOfModules()) {
- ret=FAIL;
- sprintf(mess,"Module number %d out of range\n",imod);
- }
- else {
- printf("Setting threshold energy of module %d to %d eV with settings %d\n", imod, ethr, isett);
- retval=setThresholdEnergy(ethr, imod);
-#ifdef VERBOSE
- printf("Threshold set to %d eV\n", retval);
-#endif
- if (retval!=ethr) {
- ret=FAIL;
- sprintf(mess,"Setting threshold of module %d: wrote %d but read %d\n", imod, ethr, retval);
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int start_acquisition(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sprintf(mess,"start acquisition failed\n");
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- printf("Starting acquisition\n");
- ret=startStateMachine();
- if (ret==FAIL)
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-int stop_acquisition(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sprintf(mess,"stop acquisition failed\n");
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- printf("Stopping acquisition\n");
- ret=stopStateMachine();
- if (ret==FAIL)
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int start_readout(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sprintf(mess,"start readout failed\n");
-
-#ifdef JUNGFRAUD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Start Readout) is not implemented for this detector\n");
- cprintf(RED, "%s", mess);
-#else
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- printf("Starting readout\n");
- ret=startReadOut();
- if (ret==FAIL)
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-int get_run_status(int file_des) {
- int ret=OK,ret1=OK;
- enum runStatus s=ERROR;
-
- // execute action
-#ifdef VERBOSE
- printf("Getting status\n");
-#endif
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- s= getRunStatus();
-#endif
- if (differentClients)
- ret=FORCE_UPDATE;
-
- // send ok / fail
- sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- sendData(file_des,&s,sizeof(s),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int start_and_read_all(int file_des) {
- int dataret1=FAIL, dataret=FAIL;
-#ifdef VERBOSE
- printf("Starting and reading all frames\n");
-#endif
-
- // execute action
- if (differentClients && lockStatus) {
- dataret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- // ret could be swapped during sendData
- dataret1 = dataret;
- // send fail
- sendData(file_des,&dataret1,sizeof(dataret),INT32);
- // send return argument
- sendData(file_des,mess,sizeof(mess),OTHER);
- // return fail
- return dataret;
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- startStateMachine();
- read_all(file_des);
-#endif
- return OK;
-}
-
-
-
-
-int read_frame(int file_des) {
- int dataret1=FAIL, dataret=FAIL;
- int n=0;
- sprintf(mess, "read frame failed\n");
-
- // execute action
- if (differentClients && lockStatus) {
- dataret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- // ret could be swapped during sendData
- dataret1 = dataret;
- // send fail
- sendData(file_des,&dataret1,sizeof(dataret),INT32);
- // send return argument
- sendData(file_des,mess,sizeof(mess),OTHER);
- // return fail
- return dataret;
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- readFrame(&dataret, mess);
-#endif
- if(dataret == FAIL)
- cprintf(RED,"%s\n",mess);
- else
- cprintf(GREEN,"%s",mess);
-
- if (differentClients)
- dataret=FORCE_UPDATE;
-
- //dataret could be swapped during sendData
- dataret1 = dataret;
- // send finished / fail
- n=sendData(file_des,&dataret1,sizeof(dataret1),INT32);
- if (n<0) return FAIL; // if called from read_all, should fail to stop talking to a closed client socket
- // send return argument
- n=sendData(file_des,mess,sizeof(mess),OTHER);
- if (n<0) return FAIL; // if called from read_all, should fail to stop talking to a closed client socket
- // return finished / fail
- return dataret;
-}
-
-
-
-
-int read_all(int file_des) {
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- while(read_frame(file_des)==OK) {
-#ifdef VERBOSE
- printf("frame read\n");
-#endif
- ;
- }
-#endif
-#ifdef VERBOSE
- printf("Frames finished or failed\n");
-#endif
- return OK;
-}
-
-
-
-
-int set_timer(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- enum timerIndex ind=0;
- int64_t tns=-1;
- int64_t retval=-1;
- sprintf(mess,"set timer failed\n");
-
- // receive arguments
- n = receiveData(file_des,&ind,sizeof(ind),INT32);
- if (n < 0) return printSocketReadError();
-
- n = receiveData(file_des,&tns,sizeof(tns),INT64);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus && tns!=-1) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("setting timer %d to %lld ns\n",ind,tns);
-#endif
- switch(ind) {
-#ifdef EIGERD
- case SUBFRAME_ACQUISITION_TIME:
- if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){
- ret=FAIL;
- strcpy(mess,"Sub Frame exposure time should not exceed 5.368 seconds\n");
- break;
- }
-#endif
-#ifdef MYTHEN
- case PROBES_NUMBER:
- case GATES_NUMBER:
- case DELAY_AFTER_TRIGGER:
-#elif JUNGFRAUD
- case DELAY_AFTER_TRIGGER:
-#endif
- case FRAME_NUMBER:
- case ACQUISITION_TIME: // for all detectors
- case FRAME_PERIOD:
- case CYCLES_NUMBER:
- retval = setTimer(ind,tns);
- break;
- default:
- ret = FAIL;
- sprintf(mess,"Timer Index (%d) is not implemented for this detector\n", (int) ind);
- cprintf(RED, "%s", mess);
- break;
- }
-#if defined(MYTHEND) || defined(GOTTHARD)
- if (ret == OK && ind==FRAME_NUMBER) {
- ret=allocateRAM();
- if (ret!=OK) {
- ret = FAIL;
- sprintf(mess,"Could not allocate RAM for %lld frames\n", tns);
- cprintf(RED, "%s", mess);
- }
- }
-#endif
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT64);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-
-
-
-int get_time_left(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int64_t retval=-1;
- sprintf(mess,"get timer left failed\n");
-
-
-
-#ifdef EIGERD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Get Timer Left) is not implemented for this detector\n");
- cprintf(RED, "%s", mess);
-#else
-
- // receive arguments
- enum timerIndex ind=0;
- n = receiveData(file_des,&ind,sizeof(ind),INT32);
- if (n < 0) return printSocketReadError();
-
-#ifdef VERBOSE
- printf("getting time left on timer %d \n",ind);
-#endif
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- switch(ind) {
-#ifdef MYTHEND
- case PROBES_NUMBER:
-#endif
- case FRAME_NUMBER:
- case ACQUISITION_TIME:
- case FRAME_PERIOD:
- case DELAY_AFTER_TRIGGER:
-#ifndef JUNGFRAUD
- case GATES_NUMBER:
-#endif
- case CYCLES_NUMBER:
- case PROGRESS:
- case ACTUAL_TIME:
- case MEASUREMENT_TIME:
-#ifdef JUNGFRAUD
- case FRAMES_FROM_START:
- case FRAMES_FROM_START_PG:
-#endif
- retval=getTimeLeft(ind);
- break;
- default:
- ret = FAIL;
- sprintf(mess,"Timer Left Index (%d) is not implemented for this detector\n", (int)ind);
- cprintf(RED, "%s", mess);
- break;
- }
-#ifdef VERBOSE
- printf("Time left on timer %d is %lld\n",ind, retval);
-#endif
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT64);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-int set_dynamic_range(int file_des) {
- int ret=OK,ret1=OK;
- int rateret=OK,rateret1=OK;
- int n=0;
- int dr=-1;
- int retval=-1;
- sprintf(mess,"set dynamic range failed\n");
-
- // receive arguments
- n = receiveData(file_des,&dr,sizeof(dr),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus && dr>=0) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- switch(dr){
- case -1:
- case 16:
-#ifdef EIGERD
- case 4: case 8: case 32:
-#endif
- break;
- default:
- ret = FAIL;
- sprintf(mess,"Dynamic Range (%d) is not implemented for this detector\n", dr);
- cprintf(RED, "Warning: %s", mess);
- }
- }
- if(ret == OK){
-#ifdef EIGERD
- int old_dr = setDynamicRange(-1);
- retval=setDynamicRange(dr);
- if (dr>=0 && retval!=dr)
- ret=FAIL;
- //look at rate correction only if dr change worked
- if((ret==OK) && (dr!=32) && (dr!=16) && (dr!=-1) && (getRateCorrectionEnable())){
- setRateCorrection(0);
- rateret = FAIL;
- strcpy(mess,"Switching off Rate Correction. Must be in 32 or 16 bit mode\n");
- cprintf(RED,"%s",mess);
- }else{
- //setting it if dr changed from 16 to 32 or vice versa with tau value as in rate table
- if((dr!=-1) && (old_dr != dr) && getRateCorrectionEnable() && (dr == 16 || dr == 32)){
- setRateCorrection(-1); //tau_ns will not be -1 here
- if(!getRateCorrectionEnable()){
- ret = FAIL;
- strcpy(mess,"Deactivating Rate Correction. Could not set it.\n");
- cprintf(RED,"%s",mess);
- }
- }
- }
-
-#else
- retval = setDynamicRange(dr);
-#endif
- if (dr>=0) dataBytes=calculateDataBytes();
- }
-#endif
- if ((ret == OK) && dr>=0 && retval!=dr) {
- ret = FAIL;
- cprintf(RED,"%s",mess);
- }
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-
- //rate correction ret
- // ret could be swapped during sendData
- rateret1 = rateret;
- // send ok / fail
- n = sendData(file_des,&rateret1,sizeof(rateret1),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-int set_readout_flags(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- enum readOutFlags retval=-1;
- sprintf(mess,"set readout flags failed\n");
-
-#if !defined(MYTHEND) && !defined(EIGERD)
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret=FAIL;
- sprintf(mess,"Function (Set Read Out Flags) is not implemented for this detector\n");
- cprintf(RED, "%s",mess);
-#else
-
- // receive arguments
- enum readOutFlags arg=-1;
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus && arg!=GET_READOUT_FLAGS) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("setting readout flags to %d\n",arg);
-#endif
- switch(arg) {
- case GET_READOUT_FLAGS:
-#ifdef MYTHEND
- case TOT_MODE:
- case NORMAL_READOUT:
- case STORE_IN_RAM:
- case CONTINOUS_RO:
-#elif EIGERD
- case STORE_IN_RAM:
- case CONTINOUS_RO:
- case PARALLEL:
- case NONPARALLEL:
- case SAFE:
-#endif
- retval=setReadOutFlags(arg);
- break;
- default:
- ret = FAIL;
- sprintf(mess,"Readout Flag Index (%d) is not implemented for this detector\n", (int)arg);
- cprintf(RED, "Warning: %s", mess);
- break;
- }
-#endif
- if (ret==OK && ((retval == -1) || ((arg!=-1) && ((retval&arg)!=arg)))){
- ret = FAIL;
- sprintf(mess,"Could not change readout flag: should be 0x%x but is 0x%x\n", arg, retval);
- cprintf(RED, "Warning: %s", mess);
- }
-
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
- }
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-int set_roi(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- strcpy(mess,"set nroi failed\n");
-
-#ifndef GOTTHARDD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret=FAIL;
- sprintf(mess,"Function (Set ROI) is not implemented for this detector\n");
- cprintf(RED, "%s",mess);
-#else
-
- ROI* retval=0;
- int retvalsize=0,retvalsize1=0;
-
- // receive arguments
- int nroi=-1;
- ROI arg[MAX_ROIS];
- n = receiveData(file_des,&nroi,sizeof(nroi),INT32);
- if (n < 0) return printSocketReadError();
-
- {
- int i;
- if(nroi!=-1){
- for(i=0;i=0) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("setting speed variable %d to %d\n",arg,val);
-#endif
- switch (arg) {
-#ifdef JUNGFRAUD
- case ADC_PHASE:
- adcPhase(val);
- break;
-#endif
-#ifdef MYTHEND
- case CLOCK_DIVIDER:
- case WAIT_STATES:
- case SET_SIGNAL_LENGTH:
- case TOT_CLOCK_DIVIDER:
- case TOT_DUTY_CYCLE:
-#elif EIGERD
- case CLOCK_DIVIDER:
-#elif JUNGFRAUD
- case CLOCK_DIVIDER:
-#endif
- retval=setSpeed(arg, val);
- if ((retval!=val) && (val>=0)) {
- ret=FAIL;
- sprintf(mess,"could not change speed variable %d: should be %d but is %d \n",arg, val, retval);
- cprintf(RED, "Warning: %s", mess);
- }
- break;
- default:
- ret = FAIL;
- sprintf(mess,"Speed Index (%d) is not implemented for this detector\n",(int) arg);
- cprintf(RED, "Warning: %s", mess);
- break;
- }
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int execute_trimming(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sprintf(mess,"execute trimming failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Execute Trimming) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- int retval=-1;
-
- // receive arguments
- enum trimMode mode=0;
- int arg[3]={-1,-1,-1};
- n = receiveData(file_des,&mode,sizeof(mode),INT32);
- if (n < 0) return printSocketReadError();
-
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- int imod, par1,par2;
- imod=arg[0];
- par1=arg[1];
- par2=arg[2];
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else if (imod>=getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"Module Number (%d) is out of range\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
-#ifdef VERBOSE
- printf("trimming module %d mode %d, parameters %d %d \n",imod,mode, par1, par2);
-#endif
- switch(mode) {
- case NOISE_TRIMMING:
- case BEAM_TRIMMING:
- case IMPROVE_TRIMMING:
- case FIXEDSETTINGS_TRIMMING:
- retval=executeTrimming(mode, par1, par2, imod);
- if ((ret!=OK) && (retval>0)) {
- ret=FAIL;
- sprintf(mess,"Could not trim %d channels\n", retval);
- cprintf(RED, "Warning: %s", mess);
- }
- break;
- default:
- ret = FAIL;
- sprintf(mess,"Trimming Mode (%d) is not implemented for this detector\n", (int) mode);
- cprintf(RED, "Warning: %s", mess);
- break;
- }
-
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int exit_server(int file_des) {
- int ret=FAIL;
- sprintf(mess,"Closing Server\n");
- cprintf(BG_RED,"Error: %s",mess);
- // send ok / fail
- sendData(file_des,&ret,sizeof(ret),INT32);
- // send return argument
- sendData(file_des,mess,sizeof(mess),OTHER);
- return GOODBYE;
-}
-
-
-
-
-int lock_server(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int lock=0;
- sprintf(mess,"lock server failed\n");
-
- // receive arguments
- n = receiveData(file_des,&lock,sizeof(lock),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (lock>=0) {
- if (lockStatus==0 || strcmp(lastClientIP,thisClientIP)==0 || strcmp(lastClientIP,"none")==0) {
- lockStatus=lock;
- strcpy(lastClientIP,thisClientIP);
- } else {
- ret = FAIL;
- sprintf(mess,"Server already locked by %s\n", lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
- }
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&lockStatus,sizeof(lockStatus),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int get_last_client_ip(int file_des) {
- int ret=OK,ret1=OK;
- if (differentClients)
- ret=FORCE_UPDATE;
- // send ok / fail
- sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- sendData(file_des,lastClientIP,sizeof(lastClientIP),OTHER);
- // return ok / fail
- return ret;
-}
-
-
-
-
-int set_port(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- enum portType p_type=0;
- int p_number=-1;
- sprintf(mess,"set port failed\n");
-
- // receive arguments
- n = receiveData(file_des,&p_type,sizeof(p_type),INT32);
- if (n < 0) return printSocketReadError();
-
- n = receiveData(file_des,&p_number,sizeof(p_number),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- int sd=-1;
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- if (p_number<1024) {
- ret = FAIL;
- sprintf(mess,"Port Number (%d) too low\n", p_number);
- cprintf(RED, "Warning: %s", mess);
- }
- printf("set port %d to %d\n",p_type, p_number);
- sd=bindSocket(p_number);
- if (sd<0) {
- ret = FAIL;
- sprintf(mess,"Could not bind port %d\n", p_number);
- cprintf(RED, "Warning: %s", mess);
- if (sd==-10) {
- ret = FAIL;
- sprintf(mess,"Port %d already set\n", p_number);
- cprintf(RED, "Warning: %s", mess);
- }
- }
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
- }
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n = sendData(file_des,mess,sizeof(mess),OTHER);
- } else {
- n = sendData(file_des,&p_number,sizeof(p_number),INT32);
- closeConnection(file_des);
- exitServer(sockfd);
- sockfd=sd;
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int update_client(int file_des) {
- int ret=OK;
- sendData(file_des,&ret,sizeof(ret),INT32);
- return send_update(file_des);
-}
-
-
-
-
-int send_update(int file_des) {
- int n=0; // if (n<0) should fail to stop talking to a closed client socket
- int nm=0;
- int64_t retval = 0;
- enum detectorSettings t;
-
- n = sendData(file_des,lastClientIP,sizeof(lastClientIP),OTHER);
- if (n < 0) return printSocketReadError();
-
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- nm=setNMod(GET_FLAG,X);
-#endif
- n = sendData(file_des,&nm,sizeof(nm),INT32);
- if (n < 0) return printSocketReadError();
-
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- nm=setNMod(GET_FLAG,Y);
-#endif
- n = sendData(file_des,&nm,sizeof(nm),INT32);
- if (n < 0) return printSocketReadError();
-
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- nm=setDynamicRange(GET_FLAG);
-#endif
- n = sendData(file_des,&nm,sizeof(nm),INT32);
- if (n < 0) return printSocketReadError();
-
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- dataBytes=calculateDataBytes();
-#endif
- n = sendData(file_des,&dataBytes,sizeof(dataBytes),INT32);
- if (n < 0) return printSocketReadError();
-
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- t=setSettings(GET_SETTINGS, GET_FLAG);
-#endif
- n = sendData(file_des,&t,sizeof(t),INT32);
- if (n < 0) return printSocketReadError();
-
-
-#if defined(MYTHEND) || defined(EIGERD)
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- nm=getThresholdEnergy(GET_FLAG);
-#endif
- n = sendData(file_des,&nm,sizeof(nm),INT32);
- if (n < 0) return printSocketReadError();
-#endif
-
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- retval=setTimer(FRAME_NUMBER,GET_FLAG);
-#endif
- n = sendData(file_des,&retval,sizeof(int64_t),INT64);
- if (n < 0) return printSocketReadError();
-
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- retval=setTimer(ACQUISITION_TIME,GET_FLAG);
-#endif
- n = sendData(file_des,&retval,sizeof(int64_t),INT64);
- if (n < 0) return printSocketReadError();
-
-
-#ifdef EIGERD
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- retval=setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG);
-#endif
- n = sendData(file_des,&retval,sizeof(int64_t),INT64);
- if (n < 0) return printSocketReadError();
-#endif
-
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- retval=setTimer(FRAME_PERIOD,GET_FLAG);
-#endif
- n = sendData(file_des,&retval,sizeof(int64_t),INT64);
- if (n < 0) return printSocketReadError();
-
-
-#ifndef EIGERD
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- retval=setTimer(DELAY_AFTER_TRIGGER,GET_FLAG);
-#endif
- n = sendData(file_des,&retval,sizeof(int64_t),INT64);
- if (n < 0) return printSocketReadError();
-#endif
-
-
-#if !defined(EIGERD) && !defined(JUNGFRAUD)
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- retval=setTimer(GATES_NUMBER,GET_FLAG);
-#endif
- n = sendData(file_des,&retval,sizeof(int64_t),INT64);
- if (n < 0) return printSocketReadError();
-#endif
-
-
-#ifdef MYTHEND
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- retval=setTimer(PROBES_NUMBER,GET_FLAG);
-#endif
- n = sendData(file_des,&retval,sizeof(int64_t),INT64);
- if (n < 0) return printSocketReadError();
-#endif
-
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- retval=setTimer(CYCLES_NUMBER,GET_FLAG);
-#endif
- n = sendData(file_des,&retval,sizeof(int64_t),INT64);
- if (n < 0) return printSocketReadError();
-
-
- if (lockStatus==0) {
- strcpy(lastClientIP,thisClientIP);
- }
-
- return OK;
-}
-
-
-
-
-
-
-int configure_mac(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-100;
- sprintf(mess,"configure mac failed\n");
-
-#ifdef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- strcpy(mess,"Function (Configure MAC) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- char arg[6][50];
- memset(arg,0,sizeof(arg));
- n = receiveData(file_des,arg,sizeof(arg),OTHER);
-#if defined(JUNGFRAUD) || defined(EIGERD)
- int pos[3]={0,0,0};
- n = receiveData(file_des,pos,sizeof(pos),INT32);
-#endif
- if (n < 0) return printSocketReadError();
-
- uint32_t ipad;
- uint64_t imacadd;
- uint64_t idetectormacadd;
- uint32_t udpport;
- uint32_t udpport2;
- uint32_t detipad;
- sscanf(arg[0], "%x", &ipad);
-#ifdef VIRTUAL
- sscanf(arg[1], "%lx", &imacadd);
-#else
- sscanf(arg[1], "%llx", &imacadd);
-#endif
- sscanf(arg[2], "%x", &udpport);
-#ifdef VIRTUAL
- sscanf(arg[3], "%lx", &idetectormacadd);
-#else
- sscanf(arg[3], "%llx", &idetectormacadd);
-#endif
- sscanf(arg[4], "%x", &detipad);
- sscanf(arg[5], "%x", &udpport2);
-
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- int i;
- //#ifdef GOTTHARD
- //printf("\ndigital_test_bit in server %d\t",digitalTestBit);
- //#endif
- printf("\nipadd %x\t",ipad);
- printf("destination ip is %d.%d.%d.%d = 0x%x \n",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff,ipad);
- printf("macad:%llx\n",imacadd);
- for (i=0;i<6;i++)
- printf("mac adress %d is 0x%x \n",6-i,(unsigned int)(((imacadd>>(8*i))&0xFF)));
- printf("udp port:0x%x\n",udpport);
- printf("detector macad:%llx\n",idetectormacadd);
- for (i=0;i<6;i++)
- printf("detector mac adress %d is 0x%x \n",6-i,(unsigned int)(((idetectormacadd>>(8*i))&0xFF)));
- printf("detipad %x\n",detipad);
- printf("udp port2:0x%x\n",udpport2);
- printf("\n");
- printf("Configuring MAC of module %d at port %x\n", imod, udpport);
-
-#if defined(JUNGFRAUD) || defined(EIGERD)
- printf("Position: [%d,%d,%d]\n", pos[0],pos[1],pos[2]);
-#endif
-#endif
- if(getRunStatus() == RUNNING){
- ret = stopStateMachine();
- }
- if(ret==FAIL) {
- sprintf(mess,"Could not stop detector acquisition to configure mac\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- retval=configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport,udpport2,0); //digitalTestBit);
- if(retval==-1) {
- ret = FAIL;
- sprintf(mess,"Configure Mac failed\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- printf("Configure MAC successful\n");
-#if defined(JUNGFRAUD) || defined(EIGERD)
- ret = setDetectorPosition(pos);
- if (ret == FAIL) {
- sprintf(mess,"could not set detector position\n");
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- }
-#ifdef VERBOSE
- printf("Configured MAC with retval %d\n", retval);
-#endif
- }
-
- }
-#endif
- if (differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int load_image(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"Loading image failed\n");
-
-#ifndef GOTTHARDD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Load Image) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- enum imageType index=0;
- char ImageVals[dataBytes];
- memset(ImageVals,0,dataBytes);
- n = receiveData(file_des,&index,sizeof(index),INT32);
- if (n < 0) return printSocketReadError();
-
- n = receiveData(file_des,ImageVals,dataBytes,OTHER);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- switch (index) {
- case DARK_IMAGE :
-#ifdef VERBOSE
- printf("Loading Dark image\n");
-#endif
- case GAIN_IMAGE :
-#ifdef VERBOSE
- printf("Loading Gain image\n");
-#endif
- retval=loadImage(index,ImageVals);
- if (retval==-1) {
- ret = FAIL;
- cprintf(RED, "Warning: %s", mess);
- }
- break;
- default:
- ret = FAIL;
- sprintf(mess,"Load Image Index (%d) is not implemented for this detector\n", (int)index);
- cprintf(RED, "Warning: %s", mess);
- break;
- }
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int set_master(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- enum masterFlags arg=GET_MASTER;
- enum masterFlags retval=GET_MASTER;
- sprintf(mess,"set master failed\n");
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus && ((int)arg!=(int)GET_MASTER)) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("setting master flags to %d\n",arg);
-#endif
- retval=setMaster(arg);
- if (retval==GET_MASTER)
- ret=FAIL;
-
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
- }
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-
-int set_synchronization(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- enum synchronizationMode arg=GET_SYNCHRONIZATION_MODE;
- enum synchronizationMode retval=GET_SYNCHRONIZATION_MODE;
- sprintf(mess,"synchronization mode failed\n");
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus && ((int)arg!=(int)GET_SYNCHRONIZATION_MODE)) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("setting master flags to %d\n",arg);
-#endif
- retval=setSynchronization(arg);
- if (retval==GET_SYNCHRONIZATION_MODE)
- ret=FAIL;
-
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
- }
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int read_counter_block(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- char CounterVals[dataBytes];
- memset(CounterVals,0,dataBytes);
- sprintf(mess,"Read counter block failed\n");
-
-#ifndef GOTTHARDD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Read Counter Block) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int startACQ=-1;
- n = receiveData(file_des,&startACQ,sizeof(startACQ),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- ret=readCounterBlock(startACQ,CounterVals);
- if (ret == FAIL)
- cprintf(RED, "Warning: %s", mess);
-#ifdef VERBOSE
- int i;
- for(i=0;i<6;i++)
- printf("%d:%d\t",i,CounterVals[i]);
-#endif
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,CounterVals,dataBytes,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int reset_counter_block(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sprintf(mess,"Reset counter block failed\n");
-
-#ifndef GOTTHARDD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Reset Counter Block) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int startACQ=-1;
- n = receiveData(file_des,&startACQ,sizeof(startACQ),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- ret=resetCounterBlock(startACQ);
- if (ret == FAIL)
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int calibrate_pedestal(int file_des){
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"calibrate pedestal failed\n");
-
-
-#ifndef GOTTHARDD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Calibrate Pedestal) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int frames=-1;
- n = receiveData(file_des,&frames,sizeof(frames),INT32);
- if (n < 0) return printSocketReadError();
-
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- ret=calibratePedestal(frames);
- if (ret == FAIL)
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if(ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-
-
-int enable_ten_giga(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"Enabling/disabling 10GbE failed\n");
-
- // execute action
-#ifndef EIGERD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Enable 10 GbE) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg=-1;
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus && arg!=-1) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("Enabling/Disabling 10Gbe :%d \n",arg);
-#endif
- retval=enableTenGigabitEthernet(arg);
- if((arg != -1) && (retval != arg)) {
- ret=FAIL;
- cprintf(RED, "Warning: %s", mess);
- }
- else if (differentClients)
- ret=FORCE_UPDATE;
- }
-#endif
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int set_all_trimbits(int file_des){
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"setting all trimbits failed\n");
-
-#ifndef EIGERD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Set All Trimbits) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg=-1;
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
-
- // execute action
- if (differentClients && lockStatus && arg!=-1) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("setting all trimbits to %d\n",arg);
-#endif
- if(arg < -1){
- ret = FAIL;
- strcpy(mess,"Cant set trimbits to this value\n");
- cprintf(RED, "Warning: %s", mess);
- }else {
- if(arg >= 0){
- ret = setAllTrimbits(arg);
- //changes settings to undefined
- setSettings(UNDEFINED,-1);
- cprintf(RED,"Settings has been changed to undefined (change all trimbits)\n");
- }
- retval = getAllTrimbits();
- if (arg!=-1 && arg!=retval) {
- ret=FAIL;
- sprintf(mess,"Could not set all trimbits: should be %d but is %d\n", arg, retval);
- cprintf(RED, "Warning: %s", mess);
- }
- }
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-int set_ctb_pattern(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Set CTB Pattern) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-int write_adc_register(int file_des) {
- int ret=OK, ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"write to adc register failed\n");
-
-#ifndef JUNGFRAUD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Write ADC Register) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg[2]={-1,-1};
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
- int addr=arg[0];
- int val=arg[1];
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
- else {
-#ifdef VERBOSE
- printf("writing to register 0x%x data 0x%x\n", addr, val);
-#endif
- setAdc(addr,val);
-#ifdef VERBOSE
- printf("Data set to 0x%x\n", retval);
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
- }
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int set_counter_bit(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"set counter bit failed \n");
-
-#ifndef EIGERD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- strcpy(mess,"Function (Set Counter Bit) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg=-1;
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus && arg!=-1) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("Getting/Setting/Resetting counter bit :%d \n",arg);
-#endif
- retval=setCounterBit(arg);
- if((arg != -1) && (retval != arg)) {
- ret=FAIL;
- cprintf(RED, "Warning: %s", mess);
- }
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
- }
-#endif
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int pulse_pixel(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sprintf(mess,"pulse pixel failed\n");
-
-#ifndef EIGERD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- strcpy(mess,"Function (Pulse Pixel) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg[3]={-1,-1,-1};
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- ret=pulsePixel(arg[0],arg[1],arg[2]);
- if (ret == FAIL)
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int pulse_pixel_and_move(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sprintf(mess,"pulse pixel and move failed\n");
-
-#ifndef EIGERD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- strcpy(mess,"Function (Pulse Pixel and Move) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg[3]={-1,-1,-1};
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- ret=pulsePixelNMove(arg[0],arg[1],arg[2]);
- if (ret == FAIL)
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if(ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-int pulse_chip(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sprintf(mess,"pulse chip failed\n");
-
-#ifndef EIGERD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- strcpy(mess,"Function (Pulse Chip) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg = -1;
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- ret=pulseChip(arg);
- if (ret == FAIL)
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if(ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int set_rate_correct(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sprintf(mess,"Set rate correct failed\n");
-
-#ifndef EIGERD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret=FAIL;
- sprintf(mess,"Function (Rate Correction) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int64_t tau_ns=-1;
- n = receiveData(file_des,&tau_ns,sizeof(tau_ns),INT64);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- printf("Setting rate correction to %lld ns\n",(long long int)tau_ns);
- //set rate
- //wrong bit mode
- if((setDynamicRange(-1)!=32) && (setDynamicRange(-1)!=16) && (tau_ns!=0)){
- ret=FAIL;
- strcpy(mess,"Rate correction Deactivated, must be in 32 or 16 bit mode\n");
- cprintf(RED, "Warning: %s", mess);
- }
- //16 or 32 bit mode
- else{
- if(tau_ns < 0)
- tau_ns = getDefaultSettingsTau_in_nsec();
- else if(tau_ns > 0){
- //changing tau to a user defined value changes settings to undefined
- setSettings(UNDEFINED,-1);
- cprintf(RED,"Settings has been changed to undefined (tau changed)\n");
- }
-
- int64_t retval = setRateCorrection(tau_ns);
- if(tau_ns != retval){
- ret=FAIL;
- cprintf(RED, "Warning: %s", mess);
- }
- }
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n = sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int get_rate_correct(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int64_t retval=-1;
- sprintf(mess,"Get Rate correct failed\n");
-
-#ifndef EIGERD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret=FAIL;
- sprintf(mess,"Function (Get Rate Correction) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
-
- // execute action
- retval = getCurrentTau();
- printf("Getting rate correction %lld\n",(long long int)retval);
-
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT64);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int set_network_parameter(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"set network parameter failed\n");
-
-#ifndef EIGERD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret=FAIL;
- sprintf(mess,"Function(Set Network Parmaeter) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- enum NETWORKINDEX index;
-
- // receive arguments
- enum networkParameter mode=0;
- int value=-1;
- n = receiveData(file_des,&mode,sizeof(mode),INT32);
- if (n < 0) return printSocketReadError();
-
- n = receiveData(file_des,&value,sizeof(value),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus && value<0) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("setting network parameter mode %d to %d\n",(int)mode,value);
-#endif
- switch (mode) {
- case DETECTOR_TXN_DELAY_LEFT:
- index = TXN_LEFT;
- break;
- case DETECTOR_TXN_DELAY_RIGHT:
- index = TXN_RIGHT;
- break;
- case DETECTOR_TXN_DELAY_FRAME:
- index = TXN_FRAME;
- break;
- case FLOW_CONTROL_10G:
- index = FLOWCTRL_10G;
- break;
- default:
- ret=FAIL;
- sprintf(mess,"Network Parameter Index (%d) is not implemented for this detector\n",(int) mode);
- cprintf(RED, "Warning: %s", mess);
- break;
- }
- if (ret==OK) {
- retval=setNetworkParameter(index, value);
- if ((retval!=value) && (value>=0)) {
- ret=FAIL;
- sprintf(mess,"could not change network parameter mode %d: should be %d but is %d \n",index, value, retval);
- cprintf(RED, "Warning: %s", mess);
- }
- }
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-int program_fpga(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sprintf(mess,"program FPGA failed\n");
-
-
-#ifndef JUNGFRAUD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret=FAIL;
- sprintf(mess,"Function (Program FPGA) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- size_t filesize = 0;
- size_t totalsize = 0;
- size_t unitprogramsize = 0;
- char* fpgasrc = NULL;
- FILE* fp = NULL;
-
- // receive arguments - filesize
- n = receiveData(file_des,&filesize,sizeof(filesize),INT32);
- if (n < 0) return printSocketReadError();
- totalsize = filesize;
-#ifdef VERY_VERBOSE
- printf("\n\n Total size is:%d\n",totalsize);
-#endif
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- //opening file pointer to flash and telling FPGA to not touch flash
- if(startWritingFPGAprogram(&fp) != OK) {
- ret=FAIL;
- sprintf(mess,"Could not write to flash. Error at startup.\n");
- cprintf(RED,"%s",mess);
- }
-
- //---------------- first ret ----------------
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
- //---------------- first ret ----------------
-
- if(ret!=FAIL) {
- //erasing flash
- eraseFlash();
- fpgasrc = (char*)malloc(MAX_FPGAPROGRAMSIZE);
- }
-
- //writing to flash part by part
- while(ret != FAIL && filesize){
-
- unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb
- if(unitprogramsize > filesize) //less than 2mb
- unitprogramsize = filesize;
- #ifdef VERY_VERBOSE
- printf("unit size to receive is:%d\n",unitprogramsize);
- printf("filesize:%d currentpointer:%d\n",filesize,currentPointer);
- #endif
-
- //receive
- n = receiveData(file_des,fpgasrc,unitprogramsize,OTHER);
- if (n < 0) return printSocketReadError();
-
- if(!(unitprogramsize - filesize)){
- fpgasrc[unitprogramsize]='\0';
- filesize-=unitprogramsize;
- unitprogramsize++;
- }else
- filesize-=unitprogramsize;
-
- ret = writeFPGAProgram(fpgasrc,unitprogramsize,fp);
-
- //---------------- middle rets ----------------
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- cprintf(RED,"Failure: Breaking out of program receiving\n");
- }
- //---------------- middle rets ----------------
-
- if(ret != FAIL){
- //print progress
- printf("Writing to Flash:%d%%\r",(int) (((double)(totalsize-filesize)/totalsize)*100) );
- fflush(stdout);
- }
- }
-
- printf("\n");
-
- //closing file pointer to flash and informing FPGA
- stopWritingFPGAprogram(fp);
-
- //free resources
- if(fpgasrc != NULL)
- free(fpgasrc);
- if(fp!=NULL)
- fclose(fp);
-#ifdef VERY_VERBOSE
- printf("Done with program receiving command\n");
-#endif
- if (isControlServer)
- basictests(debugflag);
- init_detector(isControlServer);
- }
-#endif
- if (ret==OK)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int reset_fpga(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sprintf(mess,"Reset FPGA unsuccessful\n");
-
-#ifndef JUNGFRAUD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Start Readout) is not implemented for this detector\n");
- cprintf(RED, "%s", mess);
-#else
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- if (isControlServer)
- basictests(debugflag);
- init_detector(isControlServer);
- ret = FORCE_UPDATE;
- }
-#endif
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-int power_chip(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"power chip failed\n");
-
-#ifndef JUNGFRAUD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Power Chip) is not implemented for this detector\n");
- cprintf(RED, "%s", mess);
-#else
-
- // receive arguments
- int arg=-1;
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus && arg!=-1) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("Power chip to %d\n", arg);
-#endif
- retval=powerChip(arg);
-
-#ifdef VERBOSE
- printf("Chip powered: %d\n",retval);
-#endif
- if (retval==arg || arg<0) {
- ret=OK;
- } else {
- ret=FAIL;
- sprintf(mess,"Powering chip failed, wrote %d but read %d\n", arg, retval);
- cprintf(RED, "Warning: %s", mess);
- }
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int set_activate(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"Activate/Deactivate failed\n");
-
-#ifndef EIGERD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret=FAIL;
- sprintf(mess,"Function (Set Activate) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg=-1;
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus && arg!=-1) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("Setting activate mode of detector to %d\n",arg);
-#endif
- retval=activate(arg);
- if ((retval!=arg) && (arg!=-1)) {
- ret=FAIL;
- sprintf(mess,"Could not set activate mode to %d, is set to %d\n",arg, retval);
- cprintf(RED, "Warning: %s", mess);
- }
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int prepare_acquisition(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- strcpy(mess,"prepare acquisition failed\n");
-
-#if !defined(GOTTHARDD) && !defined(EIGERD)
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Prepare Acquisition) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- ret = prepareAcquisition();
- if (ret == FAIL)
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if(ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-int cleanup_acquisition(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- strcpy(mess,"prepare acquisition failed\n");
-
-#ifndef GOTTHARDD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Cleanup Acquisition) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {//to be implemented when used here
- ret = FAIL;
- sprintf(mess,"Function (Cleanup Acquisition) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if(ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.c
new file mode 120000
index 000000000..a7532ccd4
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.c
@@ -0,0 +1 @@
+../slsDetectorServer/slsDetectorServer_funcs.c
\ No newline at end of file
diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.h
deleted file mode 100755
index e98feb57f..000000000
--- a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef SERVER_FUNCS_H
-#define SERVER_FUNCS_H
-
-#include "sls_receiver_defs.h"
-#include
-
-// initialization functions
-int printSocketReadError();
-void basictests(int);
-void init_detector(int);
-int decode_function(int);
-const char* getFunctionName(enum detFuncs func);
-void function_table();
-int M_nofunc(int);
-
-// functions called by client
-int exec_command(int);
-int get_error(int);
-int get_detector_type(int);
-int set_number_of_modules(int);
-int get_max_number_of_modules(int);
-int set_external_signal_flag(int);
-int set_external_communication_mode(int);
-int get_id(int);
-int digital_test(int);
-int analog_test(int);
-int enable_analog_out(int);
-int calibration_pulse(int);
-int set_dac(int);
-int get_adc(int);
-int write_register(int);
-int read_register(int);
-int write_memory(int);
-int read_memory(int);
-int set_channel(int);
-int get_channel(int);
-int set_all_channels(int);
-int set_chip(int);
-int get_chip(int);
-int set_all_chips(int);
-int set_module(int);
-int get_module(int);
-int set_all_modules(int);
-int set_settings(int);
-int get_threshold_energy(int);
-int set_threshold_energy(int);
-int start_acquisition(int);
-int stop_acquisition(int);
-int start_readout(int);
-int get_run_status(int);
-int start_and_read_all(int);
-int read_frame(int);
-int read_all(int);
-int set_timer(int);
-int get_time_left(int);
-int set_dynamic_range(int);
-int set_readout_flags(int);
-int set_roi(int);
-int set_speed(int);
-int execute_trimming(int);
-int exit_server(int);
-int lock_server(int);
-int get_last_client_ip(int);
-int set_port(int);
-int update_client(int);
-int send_update(int);
-int configure_mac(int);
-int load_image(int);
-int set_master(int);
-int set_synchronization(int);
-int read_counter_block(int);
-int reset_counter_block(int);
-int calibrate_pedestal(int);
-int enable_ten_giga(int);
-int set_all_trimbits(int);
-int set_ctb_pattern(int);
-int write_adc_register(int);
-int set_counter_bit(int);
-int pulse_pixel(int);
-int pulse_pixel_and_move(int);
-int pulse_chip(int);
-int set_rate_correct(int);
-int get_rate_correct(int);
-int set_network_parameter(int);
-int program_fpga(int);
-int reset_fpga(int);
-int power_chip(int);
-int set_activate(int);
-int prepare_acquisition(int);
-int cleanup_acquisition(int);
-
-
-#endif
diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.h
new file mode 120000
index 000000000..7569daf47
--- /dev/null
+++ b/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.h
@@ -0,0 +1 @@
+../slsDetectorServer/slsDetectorServer_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetector_stopServer.c b/slsDetectorSoftware/mythen3DetectorServer/slsDetector_stopServer.c
deleted file mode 100755
index 1772ce2b6..000000000
--- a/slsDetectorSoftware/mythen3DetectorServer/slsDetector_stopServer.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* A simple server in the internet domain using TCP
- The port number is passed as an argument */
-#include "communication_funcs.h"
-
-#include "slsDetectorFunctionList.h"/*#include "slsDetector_firmware.h" for the time being*/
-#include "slsDetectorServer_defs.h"
-
-#include
-#include
-
-int sockfd;
-
-int main(int argc, char *argv[])
-{
- int portno;
- int retval=0;
- int sd,fd;
-
- portno = DEFAULT_PORTNO;
-
-
- sd=bindSocket(portno); //defined in communication_funcs
- if (getServerError(sd)) //defined in communication_funcs
- return -1;
-
-
-
- /* waits for connection */
- while(retval!=GOODBYE) {
-#ifdef VERBOSE
- printf("\n");
-#endif
-#ifdef VERY_VERBOSE
- printf("Stop server: waiting for client call\n");
-#endif
- fd=acceptConnection(sd); //defined in communication_funcs
- retval=stopStateMachine();//defined in slsDetectorFirmare_funcs
- closeConnection(fd); //defined in communication_funcs
- }
-
- exitServer(sd); //defined in communication_funcs
- printf("Goodbye!\n");
-
- return 0;
-}
-
diff --git a/slsDetectorSoftware/mythen3DetectorServer/sls_detector_defs.h b/slsDetectorSoftware/mythen3DetectorServer/sls_detector_defs.h
deleted file mode 100755
index a8dca1ea5..000000000
--- a/slsDetectorSoftware/mythen3DetectorServer/sls_detector_defs.h
+++ /dev/null
@@ -1,599 +0,0 @@
-#ifndef SLS_DETECTOR_DEFS_H
-#define SLS_DETECTOR_DEFS_H
-
-
-#ifdef __CINT__
-#define MYROOT
-#define __cplusplus
-#endif
-
-//#include
-#include "sls_receiver_defs.h"
-
-/** default maximum string length */
-#define MAX_SCAN_STEPS 2000
-/** maxmimum number of modules per controller*/
-#define MAXMODS 24
-/** maxmimum number of detectors ina multidetector structure*/
-#define MAXDET 100
-/** header length for data :gotthard*/
-#define HEADERLENGTH 12
-
-/** maximum rois */
-#define MAX_ROIS 100
-
-/** maximum unit size of program sent to detector */
-#define MAX_FPGAPROGRAMSIZE (2 * 1024 *1024)
-
-
-
-#define MAX_SCAN_LEVELS 2
-
-typedef char mystring[MAX_STR_LENGTH];
-typedef double mysteps[MAX_SCAN_STEPS];
-
-
-
-#ifndef DACS_FLOAT
-typedef int dacs_t;
-#else
-typedef float dacs_t;
-#endif
-
-#define DEFAULT_DET_MAC "00:aa:bb:cc:dd:ee"
-#define DEFAULT_DET_IP "129.129.202.46"
-
-
-/**
- \file sls_detector_defs.h
-This file contains all the basic definitions common to the slsDetector class
-and to the server programs running on the detector
-
-
- * @author Anna Bergamaschi
- * @version 0.1alpha (any string)
- * @see slsDetector
-
-$Revision: 824 $
-
-*/
-
-
-/** get flag form most functions */
-#define GET_FLAG -1
-
-
-#ifdef __cplusplus
-
-/** @short class containing all the structures, constants and enum definitions */
-class slsDetectorDefs: public virtual slsReceiverDefs{
- public:
-
- slsDetectorDefs(){};
-
-#endif
-
-
- enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, enCalLog, angCalLog, MAX_ACTIONS};
-
-
-
-/**
- @short structure for a detector channel
-
- should not be used by unexperienced users
-
- \see ::channelRegisterBit
-*/
- typedef struct {
- int chan; /**< is the channel number */
- int chip; /**< is the chip number */
- int module; /**< is the module number */
- int64_t reg; /**< is the is the channel register (e.g. trimbits, calibration enable, comparator enable...) */
- } sls_detector_channel;
-
- /**
- @short structure for a detector chip
-
- should not be used by unexperienced users
- \see ::chipRegisterBit ::channelRegisterBit
-*/
- typedef struct {
- int chip; /**< is the chip number */
- int module; /**< is the module number */
- int nchan; /**< is the number of channels in the chip */
- int reg; /***/
- M_Vrf, /**< mythen 3 >*/
- M_VrfSh, /**< mythen 3 >*/
- M_Vth1, /**< mythen 3 >*/
- M_Vth2, /**< mythen 3 >*/
- M_Vth3, /**< mythen 3 >*/
- M_Vtrim, /**< mythen 3 >*/
- M_VPL, /**< mythen 3 >*/
- M_VPH, /**< mythen 3 >*/
- V_POWER_A = 100, /**new chiptest board */
- V_POWER_B = 101, /**new chiptest board */
- V_POWER_C = 102, /**new chiptest board */
- V_POWER_D = 103, /**new chiptest board */
- V_POWER_IO =104, /**new chiptest board */
- V_POWER_CHIP=105 ,/**new chiptest board */
- I_POWER_A=106 , /**new chiptest board */
- I_POWER_B=107 , /**new chiptest board */
- I_POWER_C=108 , /**new chiptest board */
- I_POWER_D=109 , /**new chiptest board */
- I_POWER_IO=110 , /**new chiptest board */
- V_LIMIT=111 /**new chiptest board */
-};
-
-/**
- detector settings indexes
-*/
-enum detectorSettings{
- GET_SETTINGS=-1, /**< return current detector settings */
- STANDARD, /**< standard settings */
- FAST, /**< fast settings */
- HIGHGAIN, /**< highgain settings */
- DYNAMICGAIN, /**< dynamic gain settings */
- LOWGAIN, /**< low gain settings */
- MEDIUMGAIN, /**< medium gain settings */
- VERYHIGHGAIN, /**< very high gain settings */
- LOWNOISE, /**< low noise settings */
- DYNAMICHG0, /**< dynamic high gain 0 */
- FIXGAIN1, /**< fix gain 1 */
- FIXGAIN2, /**< fix gain 2 */
- FORCESWITCHG1, /**< force switch gain 1 */
- FORCESWITCHG2, /**< force switch gain 2 */
- VERYLOWGAIN, /**< very low gain settings */
- UNDEFINED=200, /**< undefined or custom settings */
- UNINITIALIZED /**< uninitialiazed (status at startup) */
-};
-/**
- meaning of the channel register bits
- \see ::sls_detector_channel
-*/
-enum channelRegisterBit {
- TRIMBIT_OFF=0, /**< offset of trimbit value in the channel register */
- COMPARATOR_ENABLE=0x100, /**< mask of the comparator enable bit */
- ANALOG_SIGNAL_ENABLE=0x200, /**< mask of the analogue output enable bit */
- CALIBRATION_ENABLE=0x300, /**< mask of the calibration input enable bit */
-};
-
-#define TRIMBITMASK 0x3f
-/**
- meaning of the chip register bits
- \see ::sls_detector_chip
-*/
-enum chipRegisterBit {
- ENABLE_ANALOG_OUTPUT=0x1, /**< mask of the analogue output enable bit */
- CHIP_OUTPUT_WIDTH=0x2 /**< mask of the chip output width */
-};
-/**
- meaning of the module register bits
-*/
-enum moduleRegisterBit {
- MY_MODULE_REGISTER_BIT, /**< possible module register bit meaning */
- MODULE_OUTPUT_WIDTH /**< possibly module dynamic range */
-};
-
-
-/**
- important speed parameters
-*/
-enum speedVariable {
- CLOCK_DIVIDER, /**< readout clock divider */
- WAIT_STATES, /**< wait states for bus read */
- TOT_CLOCK_DIVIDER, /**< wait states for bus read */
- TOT_DUTY_CYCLE, /**< wait states for bus read */
- SET_SIGNAL_LENGTH, /**< set/clear signal length */
- PHASE_SHIFT, /**< adds phase shift */
- OVERSAMPLING, /**< oversampling for analog detectors */
- ADC_CLOCK, /**< adc clock divider */
- ADC_PHASE, /**< adc clock phase */
- ADC_PIPELINE, /**< adc pipeline */
- DBIT_CLOCK, /**< adc clock divider */
- DBIT_PHASE, /**< adc clock phase */
- DBIT_PIPELINE /**< adc pipeline */
-};
-
-
-/**
- readout flags
-*/
-enum readOutFlags {
- GET_READOUT_FLAGS=-1, /**< return readout flags */
- NORMAL_READOUT=0, /**< no flag */
- STORE_IN_RAM=0x1, /**< data are stored in ram and sent only after end of acquisition for faster frame rate */
- READ_HITS=0x2, /**< return only the number of the channel which counted ate least one */
- ZERO_COMPRESSION=0x4,/**< returned data are 0-compressed */
- PUMP_PROBE_MODE=0x8,/** gitInfo.txt
+ cd ../../
+ ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE
+ cd $WD
+fi
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetector/gitInfoLib.h b/slsDetectorSoftware/slsDetector/gitInfoLib.h
index 61d748cf1..997240797 100644
--- a/slsDetectorSoftware/slsDetector/gitInfoLib.h
+++ b/slsDetectorSoftware/slsDetector/gitInfoLib.h
@@ -1,6 +1,6 @@
-#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git"
-#define GITREPUUID "c4a242e10a4aafd102cc9a2a7ddae4ac92b8ba99"
-#define GITAUTH "Dhanya_Maliakal"
-#define GITREV 0x3187
-#define GITDATE 0x20171206
-#define GITBRANCH "3.0.1"
+#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
+#define GITREPUUID "b58c3e8951625ed9124669404f6b68aca340a1b8"
+#define GITAUTH "Dhanya_Thattil"
+#define GITREV 0x3727
+#define GITDATE 0x20180314
+#define GITBRANCH "developer"
diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp
index d98119b63..89d80025d 100644
--- a/slsDetectorSoftware/slsDetector/slsDetector.cpp
+++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp
@@ -1161,18 +1161,19 @@ int slsDetector::sendModule(sls_detector_module *myMod) {
ts+=controlSocket->SendDataOnly(&(myMod->ndac),sizeof(myMod->ndac));
ts+=controlSocket->SendDataOnly(&(myMod->nadc),sizeof(myMod->nadc));
ts+=controlSocket->SendDataOnly(&(myMod->reg),sizeof(myMod->reg));
- ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(myMod->ndac));
- ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(myMod->nadc));
-
- if(thisDetector->myDetectorType != JUNGFRAU){
- ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(myMod->nchip));
- ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(myMod->nchan));
+ // only for sending structures like in old mythen server
+ if (thisDetector->myDetectorType == MYTHEN) {
+ ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(myMod->ndac));
+ ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(myMod->nadc));
+ ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(myMod->nchip));
+ ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(myMod->nchan));
}
ts+=controlSocket->SendDataOnly(&(myMod->gain),sizeof(myMod->gain));
ts+=controlSocket->SendDataOnly(&(myMod->offset), sizeof(myMod->offset));
+
+ // actual data to the pointers
ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(dacs_t)*(myMod->ndac));
ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(dacs_t)*(myMod->nadc));
-
if(thisDetector->myDetectorType != JUNGFRAU){
ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip));
ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan));
@@ -1229,13 +1230,14 @@ int slsDetector::receiveModule(sls_detector_module* myMod) {
ts+=controlSocket->ReceiveDataOnly(&(myMod->ndac),sizeof(myMod->ndac));
ts+=controlSocket->ReceiveDataOnly(&(myMod->nadc),sizeof(myMod->nadc));
ts+=controlSocket->ReceiveDataOnly(&(myMod->reg),sizeof(myMod->reg));
- ts+=controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(myMod->ndac));
- ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(myMod->nadc));
-
- if(thisDetector->myDetectorType != JUNGFRAU){
- ts+=controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(myMod->nchip));
- ts+=controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(myMod->nchan));
+ // only for sending structures like in old mythen server
+ if (thisDetector->myDetectorType == MYTHEN) {
+ ts+=controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(myMod->ndac));
+ ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(myMod->nadc));
+ ts+=controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(myMod->nchip));
+ ts+=controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(myMod->nchan));
}
+
ts+=controlSocket->ReceiveDataOnly(&(myMod->gain), sizeof(myMod->gain));
ts+=controlSocket->ReceiveDataOnly(&(myMod->offset), sizeof(myMod->offset));
@@ -2395,13 +2397,13 @@ int slsDetector::digitalTest( digitalTestMode mode, int imod){
/* write or read register */
-int slsDetector::writeRegister(int addr, int val){
+uint32_t slsDetector::writeRegister(uint32_t addr, uint32_t val){
- int retval=-1;
+ uint32_t retval = 0;
int fnum=F_WRITE_REGISTER;
int ret=FAIL;
char mess[MAX_STR_LENGTH]="";
- int arg[2];
+ uint32_t arg[2];
arg[0]=addr;
arg[1]=val;
@@ -2444,7 +2446,7 @@ int slsDetector::writeAdcRegister(int addr, int val){
int ret=FAIL;
char mess[MAX_STR_LENGTH]="";
- int arg[2];
+ uint32_t arg[2];
arg[0]=addr;
arg[1]=val;
@@ -2483,13 +2485,13 @@ int slsDetector::writeAdcRegister(int addr, int val){
-int slsDetector::readRegister(int addr){
+uint32_t slsDetector::readRegister(uint32_t addr){
- int retval=-1;
+ uint32_t retval = 0;
int fnum=F_READ_REGISTER;
int ret=FAIL;
char mess[MAX_STR_LENGTH]="";
- int arg;
+ uint32_t arg;
arg=addr;
@@ -2526,25 +2528,24 @@ int slsDetector::readRegister(int addr){
}
-int slsDetector::setBit(int addr, int n) {
+uint32_t slsDetector::setBit(uint32_t addr, int n) {
if (n<0 || n>31) {
std::cout << "Bit number out of Range" << std:: endl;
setErrorMask((getErrorMask())|(REGISER_WRITE_READ));
}
// normal bit range
+ //TODO! (Erik) Check for errors! cannot use value since reg is 32bits
else {
- int val = readRegister(addr);
- if (val != -1) {
- writeRegister(addr,val | 1<31) {
std::cout << "Bit number out of Range" << std:: endl;
setErrorMask((getErrorMask())|(REGISER_WRITE_READ));
@@ -2552,10 +2553,8 @@ int slsDetector::clearBit(int addr, int n) {
// normal bit range
else {
- int val = readRegister(addr);
- if (val != -1) {
- writeRegister(addr,val & ~(1<onlineFlag==ONLINE_FLAG) {
+ if (connectStop() == OK){
+ stopSocket->SendDataOnly(&fnum,sizeof(fnum));
+ stopSocket->SendDataOnly(arg,sizeof(arg));
+ stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
+ if (ret!=FAIL) {
+ stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
+#ifdef VERBOSE
+ std::cout<< "Threshold Temperature returned "<< retval << std::endl;
+#endif
+ } else {
+ stopSocket->ReceiveDataOnly(mess,sizeof(mess));
+ std::cout<< "Detector returned error: " << mess << std::endl;
+ setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL));
+ }
+ disconnectStop();
+ }
+ }
+
+ return retval;
+}
+
+
+
+int slsDetector::setTemperatureControl(int val, int imod) {
+
+ int retval = -1;
+ int fnum = F_TEMP_CONTROL;
+ int ret = FAIL;
+ char mess[MAX_STR_LENGTH] = "";
+
+ int arg[2];
+ arg[0]=val;
+ arg[1]=imod;
+
+
+#ifdef VERBOSE
+ std::cout<< std::endl;
+ std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " << imod << std::endl;
+#endif
+ if (thisDetector->onlineFlag==ONLINE_FLAG) {
+ if (connectStop() == OK){
+ stopSocket->SendDataOnly(&fnum,sizeof(fnum));
+ stopSocket->SendDataOnly(arg,sizeof(arg));
+ stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
+ if (ret!=FAIL) {
+ stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
+#ifdef VERBOSE
+ std::cout<< "Threshold Temperature returned "<< retval << std::endl;
+#endif
+ } else {
+ stopSocket->ReceiveDataOnly(mess,sizeof(mess));
+ std::cout<< "Detector returned error: " << mess << std::endl;
+ setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL));
+ }
+ disconnectStop();
+ }
+ }
+
+ return retval;
+}
+
+
+
+
+int slsDetector::setTemperatureEvent(int val, int imod) {
+
+ int retval = -1;
+ int fnum = F_TEMP_EVENT;
+ int ret = FAIL;
+ char mess[MAX_STR_LENGTH] = "";
+
+ int arg[2];
+ arg[0]=val;
+ arg[1]=imod;
+
+
+#ifdef VERBOSE
+ std::cout<< std::endl;
+ std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " << imod << std::endl;
+#endif
+ if (thisDetector->onlineFlag==ONLINE_FLAG) {
+ if (connectStop() == OK){
+ stopSocket->SendDataOnly(&fnum,sizeof(fnum));
+ stopSocket->SendDataOnly(arg,sizeof(arg));
+ stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
+ if (ret!=FAIL) {
+ stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
+#ifdef VERBOSE
+ std::cout<< "Threshold Temperature returned "<< retval << std::endl;
+#endif
+ } else {
+ stopSocket->ReceiveDataOnly(mess,sizeof(mess));
+ std::cout<< "Detector returned error: " << mess << std::endl;
+ setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL));
+ }
+ disconnectStop();
+ }
+ }
+
+ return retval;
+}
+
+
/*
configure single channel
enum channelRegisterBit {
@@ -3114,7 +3236,7 @@ int slsDetector::setModule(int reg, int imod){
int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval, int* offsetval, int tb){
int fnum=F_SET_MODULE;
- int retval;
+ int retval=-1;
int ret=FAIL;
char mess[MAX_STR_LENGTH]="";
@@ -3220,6 +3342,9 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int
offset[i+imod*thisDetector->nOffset]=offsetval[i];
}
+ if (e_eV != -1)
+ thisDetector->currentThresholdEV = e_eV;
+
}
#ifdef VERBOSE
@@ -3424,7 +3549,7 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
//currently only for eiger
if (thisDetector->myDetectorType == EIGER) {
setThresholdEnergyAndSettings(e_eV,isettings,tb);
- return thisDetector->currentThresholdEV;
+ return thisDetector->currentThresholdEV;
}
int fnum= F_SET_THRESHOLD_ENERGY;
@@ -3828,11 +3953,11 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
std::cout<< thisDetector->settingsDir<calDir <settingsDir << ssettings <<"/noise.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
+ oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
+ break;
+ default:
//settings is saved in myMod.reg
myMod->reg=thisDetector->currentSettings;
ostfn << thisDetector->settingsDir << ssettings <<"/settings.sn";// << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
@@ -3841,9 +3966,6 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
std::cout<< thisDetector->settingsDir<calDir <settingsDir << ssettings <<"/noise.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
- oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
}
@@ -3856,17 +3978,13 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
//if it didnt open, try default settings file
ostringstream ostfn_default;
switch(thisDetector->myDetectorType){
- case MOENCH:
- case GOTTHARD:
- case PROPIX:
- case JUNGFRAU:
- case JUNGFRAUCTB:
+ case EIGER:
+ case MYTHEN:
+ ostfn_default << thisDetector->settingsDir << ssettings << ssettings << ".trim";
+ break;
+ default:
ostfn_default << thisDetector->settingsDir << ssettings << ssettings << ".settings";
break;
- case EIGER:
- default:
- ostfn_default << thisDetector->settingsDir << ssettings << ssettings << ".trim";
- break;
}
settingsfname=ostfn_default.str();
#ifdef VERBOSE
@@ -6337,9 +6455,9 @@ string slsDetector::setReceiverUDPMAC(string udpmac){
#else
;
#endif
- else if(setUDPConnection()==FAIL){
+ /* else if(setUDPConnection()==FAIL){ commented out to be replaced by user defined udpmac
std::cout<< "Warning: UDP connection set up failed" << std::endl;
- }
+ }*/
}else{
setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER));
std::cout << "Warning: receiver udp mac address should be in xx:xx:xx:xx:xx:xx format" << std::endl;
@@ -6798,8 +6916,41 @@ int slsDetector::configureMAC(){
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
}
- else
+ else {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
+ if (thisDetector->myDetectorType == EIGER) {
+ //rewrite detectormac, detector ip
+ char arg[2][50];
+ memset(arg,0,sizeof(arg));
+ uint64_t idetectormac = 0;
+ uint32_t idetectorip = 0;
+ controlSocket->ReceiveDataOnly(arg,sizeof(arg));
+ sscanf(arg[0], "%lx", &idetectormac);
+ sscanf(arg[1], "%x", &idetectorip);
+ sprintf(arg[0],"%02x:%02x:%02x:%02x:%02x:%02x",
+ (unsigned int)((idetectormac>>40)&0xFF),
+ (unsigned int)((idetectormac>>32)&0xFF),
+ (unsigned int)((idetectormac>>24)&0xFF),
+ (unsigned int)((idetectormac>>16)&0xFF),
+ (unsigned int)((idetectormac>>8)&0xFF),
+ (unsigned int)((idetectormac>>0)&0xFF));
+ sprintf(arg[1],"%d.%d.%d.%d",
+ (idetectorip>>24)&0xff,
+ (idetectorip>>16)&0xff,
+ (idetectorip>>8)&0xff,
+ (idetectorip)&0xff);
+ if (strcasecmp(arg[0],thisDetector->detectorMAC)) {
+ memset(thisDetector->detectorMAC, 0, MAX_STR_LENGTH);
+ strcpy(thisDetector->detectorMAC, arg[0]);
+ cprintf(RESET,"%d: Detector MAC updated to %s\n", detId, thisDetector->detectorMAC);
+ }
+ if (strcasecmp(arg[1],thisDetector->detectorIP)) {
+ memset(thisDetector->detectorIP, 0, MAX_STR_LENGTH);
+ strcpy(thisDetector->detectorIP, arg[1]);
+ cprintf(RESET,"%d: Detector IP updated to %s\n", detId, thisDetector->detectorIP);
+ }
+ }
+ }
disconnectControl();
if (ret==FORCE_UPDATE)
updateDetector();
@@ -7614,6 +7765,43 @@ int slsDetector::powerChip(int ival){
return retval;
}
+
+
+int slsDetector::setAutoComparatorDisableMode(int ival){
+ int ret=FAIL;
+ int fnum=F_AUTO_COMP_DISABLE;
+ char mess[MAX_STR_LENGTH]="";
+ int retval=-1;
+
+ if(thisDetector->myDetectorType != JUNGFRAU){
+ std::cout << "Not implemented for this detector" << std::endl;
+ return FAIL;
+ }
+#ifdef VERBOSE
+ std::cout<< "Enabling/disabling Auto comp disable mode " << endl;
+#endif
+ if (thisDetector->onlineFlag==ONLINE_FLAG) {
+ if (connectControl() == OK){
+ controlSocket->SendDataOnly(&fnum,sizeof(fnum));
+ controlSocket->SendDataOnly(&ival,sizeof(ival));
+ //check opening error
+ controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
+ if (ret==FAIL) {
+ controlSocket->ReceiveDataOnly(mess,sizeof(mess));
+ std::cout<< "Detector returned error: " << mess << std::endl;
+ setErrorMask((getErrorMask())|(AUTO_COMP_DISABLE));
+ }else
+ controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
+ disconnectControl();
+ if (ret==FORCE_UPDATE)
+ updateDetector();
+ }
+ }
+ return retval;
+
+}
+
+
int slsDetector::loadSettingsFile(string fname, int imod) {
sls_detector_module *myMod=NULL;
@@ -7631,15 +7819,21 @@ int slsDetector::loadSettingsFile(string fname, int imod) {
for (int im=mmin; immyDetectorType != EIGER){
- if (fname.find(".sn")==string::npos && fname.find(".trim")==string::npos && fname.find(".settings")==string::npos) {
- ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
- fn=ostfn.str();
- }
- }else if (fname.find(".sn")==string::npos && fname.find(".trim")==string::npos && fname.find(".settings")==string::npos) {
- ostfn << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER, im);
- fn=ostfn.str();
+ switch (thisDetector->myDetectorType) {
+ case MYTHEN:
+ if (fname.find(".sn")==string::npos && fname.find(".trim")==string::npos && fname.find(".settings")==string::npos) {
+ ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
+ }
+ break;
+ case EIGER:
+ if (fname.find(".sn")==string::npos && fname.find(".trim")==string::npos && fname.find(".settings")==string::npos) {
+ ostfn << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER, im);
+ }
+ break;
+ default:
+ break;
}
+ fn=ostfn.str();
myMod=readSettingsFile(fn, thisDetector->myDetectorType,iodelay, tau, myMod);
if (myMod) {
@@ -7669,18 +7863,27 @@ int slsDetector::saveSettingsFile(string fname, int imod) {
mmax=imod+1;
}
for (int im=mmin; immyDetectorType == EIGER){
- ostfn << fname << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER);
- } else
- ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER,im);
+ ostfn << fname;
+ switch (thisDetector->myDetectorType) {
+ case MYTHEN:
+ ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER,im);
+ break;
+ case EIGER:
+ ostfn << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER);
+ break;
+ default:
+ break;
+ }
+ fn=ostfn.str();
if ((myMod=getModule(im))) {
if(thisDetector->myDetectorType == EIGER){
iodelay = (int)setDAC((dacs_t)-1,IO_DELAY,0,-1);
tau = (int64_t)getRateCorrectionTau();
}
- ret=writeSettingsFile(ostfn.str(), thisDetector->myDetectorType, *myMod, iodelay, tau);
+ ret=writeSettingsFile(fn, thisDetector->myDetectorType, *myMod, iodelay, tau);
deleteModule(myMod);
}
}
@@ -7763,14 +7966,22 @@ int slsDetector::loadCalibrationFile(string fname, int imod) {
mmax=imod+1;
}
for (int im=mmin; immyDetectorType != EIGER){
- if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) {
- ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
- }
- }else if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) {
- ostfn << "." << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER);
+ switch (thisDetector->myDetectorType) {
+ case MYTHEN:
+ if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) {
+ ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
+ }
+ break;
+ case EIGER:
+ if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) {
+ ostfn << "." << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER);
+ }
+ break;
+ default:
+ break;
}
fn=ostfn.str();
if((myMod=getModule(im))){
@@ -7807,18 +8018,27 @@ int slsDetector::saveCalibrationFile(string fname, int imod) {
mmax=imod+1;
}
for (int im=mmin; immyDetectorType == EIGER)
- ostfn << fname << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER);
- else
- ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER,im);
+ ostfn << fname;
+ switch (thisDetector->myDetectorType) {
+ case MYTHEN:
+ ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER,im);
+ break;
+ case EIGER:
+ ostfn << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER);
+ break;
+ default:
+ break;
+ }
+ fn=ostfn.str();
if ((myMod=getModule(im))) {
//extra gain and offset
if(thisDetector->nGain)
- ret=writeCalibrationFile(ostfn.str(),gain, offset);
+ ret=writeCalibrationFile(fn,gain, offset);
//normal gain and offset inside sls_detector_module
else
- ret=writeCalibrationFile(ostfn.str(),myMod->gain, myMod->offset);
+ ret=writeCalibrationFile(fn,myMod->gain, myMod->offset);
deleteModule(myMod);
}else
diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h
index 0c733ace1..5dd98aafb 100644
--- a/slsDetectorSoftware/slsDetector/slsDetector.h
+++ b/slsDetectorSoftware/slsDetector/slsDetector.h
@@ -541,13 +541,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
/**
returns currently the loaded trimfile/settingsfile name
*/
- const char *getSettingsFile(){\
+ string getSettingsFile(){\
string s(thisDetector->settingsFile); \
if (s.length()>6) {\
if (s.substr(s.length()-6,3)==string(".sn") && s.substr(s.length()-3)!=string("xxx") ) \
- return s.substr(0,s.length()-6).c_str(); \
+ return s.substr(0,s.length()-6); \
} \
- return thisDetector->settingsFile;\
+ return string(thisDetector->settingsFile);\
};
@@ -568,6 +568,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/
int powerChip(int ival= -1);
+ /** automatic comparator disable for Jungfrau only
+ \param ival on is 1, off is 0, -1 to get
+ \returns OK or FAIL
+ */
+ int setAutoComparatorDisableMode(int ival= -1);
+
/** loads the modules settings/trimbits reading from a file
\param fname file name . If not specified, extension is automatically generated!
@@ -886,7 +892,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
\returns current register value
*/
- int writeRegister(int addr, int val);
+ uint32_t writeRegister(uint32_t addr, uint32_t val);
/**
@@ -904,7 +910,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
\returns current register value
*/
- int readRegister(int addr);
+ uint32_t readRegister(uint32_t addr);
/**
sets a bit in a register
@@ -914,7 +920,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
DO NOT USE!!! ONLY EXPERT USER!!!
*/
- int setBit(int addr, int n);
+ uint32_t setBit(uint32_t addr, int n);
/**
@@ -925,7 +931,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
DO NOT USE!!! ONLY EXPERT USER!!!
*/
- int clearBit(int addr, int n);
+ uint32_t clearBit(uint32_t addr, int n);
/**
set dacs value
@@ -944,7 +950,31 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
\returns current ADC value (temperature for eiger and jungfrau in millidegrees)
*/
dacs_t getADC(dacIndex index, int imod=0);
+
+ /**
+ set/gets threshold temperature (Jungfrau only)
+ \param val value in millidegrees, -1 gets
+ \param imod module number, -1 is all
+ \returns threshold temperature in millidegrees
+ */
+ int setThresholdTemperature(int val=-1, int imod=-1);
+ /**
+ enables/disables temperature control (Jungfrau only)
+ \param val value, -1 gets
+ \param imod module number, -1 is all
+ \returns temperature control enable
+ */
+ int setTemperatureControl(int val=-1, int imod=-1);
+
+ /**
+ Resets/ gets over-temperature event (Jungfrau only)
+ \param val value, -1 gets
+ \param imod module number, -1 is all
+ \returns over-temperature event
+ */
+ int setTemperatureEvent(int val=-1, int imod=-1);
+
/**
configure channel
\param reg channel register
diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp
index ee811e7ee..f99f69747 100644
--- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp
+++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp
@@ -234,7 +234,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
-
/*! \page config Configuration commands
Commands to configure the detector. these commands are often left to the configuration file.
- \ref configstructure "Data Structure": commands to configure detector data structure
@@ -469,6 +468,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
++i;
+ /*! \page config
+ - auto_comp_disable i Currently not implemented. this mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). 1 enables mode, 0 disables mode. By default, mode is disabled (comparator is enabled throughout). (JUNGFRAU only). \c Returns \c (int)
+ */
+ descrToFuncMap[i].m_pFuncName="auto_comp_disable"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
+ ++i;
+
/*! \page config
- pulse [n] [x] [y] pulses pixel at coordinates (x,y) n number of times. Used in EIGER only. Only put! \c Returns \c ("successful", "unsuccessful")
*/
@@ -848,7 +854,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
*/
/*! \page data
- flatfield [fn] \c put sets flatfield file to \c fn (relative to \c ffdir). \get returns the flatfield file name relative to \c ffdir (string). If \fn is specified, it writes the flat field correction factors and errors to \c fn. \c Returns \c (string) fn
-\c none disables flat field corrections.
+ \c none disables flat field corrections.
*/
descrToFuncMap[i].m_pFuncName="flatfield"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFlatField;
@@ -966,6 +972,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
- \ref settingssett "Settings and Threshold": commands to configure settings and threshold of detector
- \ref settingsdacs "DACs": commands to configure DACs of detector
- \ref settingsadcs "ADCs": commands to readout ADCs of detector
+ - \ref settingstmp "Temp Control": commands to monitor and handle temperature overshoot (only JUNGFRAU)
*/
/* trim/cal directories */
@@ -1420,6 +1427,78 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
++i;
+
+
+ /* MYTHEN 3.01
+ all values are in DACu */
+
+
+ descrToFuncMap[i].m_pFuncName="vIpre"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ descrToFuncMap[i].m_pFuncName="VcdSh"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ /*! \page settings
+ - Vth1 Sets/gets first detector threshold voltage for Mythen 3.01. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
+ */
+ descrToFuncMap[i].m_pFuncName="Vth1"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ /*! \page settings
+ - Vth1 Sets/gets second detector threshold voltage for Mythen 3.01. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
+ */
+ descrToFuncMap[i].m_pFuncName="Vth2"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ /*! \page settings
+ - Vth1 Sets/gets third detector threshold voltage for Mythen 3.01. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
+ */
+ descrToFuncMap[i].m_pFuncName="Vth3"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ descrToFuncMap[i].m_pFuncName="VPL"; // baseline for analog pulsing
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ descrToFuncMap[i].m_pFuncName="Vtrim"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ descrToFuncMap[i].m_pFuncName="vIbias"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ descrToFuncMap[i].m_pFuncName="vIinSh"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ descrToFuncMap[i].m_pFuncName="cas"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ descrToFuncMap[i].m_pFuncName="casSh"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ descrToFuncMap[i].m_pFuncName="vIbiasSh"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ descrToFuncMap[i].m_pFuncName="vIcin"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+ descrToFuncMap[i].m_pFuncName="vIpreOut"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
+ ++i;
+
+
/* r/w timers */
/*! \page settings
\section settingsadcs ADCs
@@ -1569,6 +1648,32 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
++i;
+ /* temperature control */
+ /*! \page settings
+ \section settingstmp Temp Control
+ commands to monitor and handle temperature overshoot (only JUNGFRAU)
+ */
+
+ /*! \page settings
+ - temp_threshold Sets/gets the threshold temperature. JUNGFRAU ONLY. \c Returns \c (double"°C")
+ */
+ descrToFuncMap[i].m_pFuncName="temp_threshold"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTempControl;
+ ++i;
+
+ /*! \page settings
+ - temp_control Enables/Disables the temperature control. 1 enables, 0 disables. JUNGFRAU ONLY. \c Returns \c int
+ */
+ descrToFuncMap[i].m_pFuncName="temp_control"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTempControl;
+ ++i;
+
+ /*! \page settings
+ - temp_event Resets/gets over-temperative event. Put only with option 0 to clear event. Gets 1 if temperature went over threshold and control is enabled, else 0. /Disables the temperature control. JUNGFRAU ONLY. \c Returns \c int
+ */
+ descrToFuncMap[i].m_pFuncName="temp_event"; //
+ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTempControl;
+ ++i;
/* file name */
@@ -4528,7 +4633,7 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
myDet->loadSettingsFile(sval,-1);
}
}
- return string(myDet->getSettingsFile());
+ return myDet->getSettingsFile();
} else if (cmd=="trim") {
if (action==GET_ACTION)
return string("cannot get!");
@@ -5055,6 +5160,35 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) {
dac=V_POWER_CHIP;
else if (cmd== "v_limit")
dac=V_LIMIT;
+ else if (cmd== "vIpre")
+ dac=M_vIpre;
+ else if (cmd== "vIbias")
+ dac=M_vIbias;
+ else if (cmd== "vIinSh")
+ dac=M_vIinSh;
+ else if (cmd== "VcdSh")
+ dac=M_VdcSh;
+ else if (cmd== "Vth1")
+ dac=THRESHOLD;
+ else if (cmd== "Vth2")
+ dac=M_Vth2;
+ else if (cmd== "Vth3")
+ dac=M_Vth3;
+ else if (cmd== "VPL")
+ dac=M_VPL;
+ else if (cmd== "Vtrim")
+ dac=TRIMBIT_SIZE;
+ else if (cmd== "casSh")
+ dac=M_casSh;
+ else if (cmd== "cas")
+ dac=M_cas;
+ else if (cmd== "vIcin")
+ dac=M_vIcin;
+ else if (cmd== "vIbiasSh")
+ dac=M_vIbiasSh;
+ else if (cmd== "vIpreOut")
+ dac=M_vIpreOut;
+
else
return string("cannot decode dac ")+cmd;
@@ -5340,6 +5474,80 @@ string slsDetectorCommand::helpADC(int narg, char *args[], int action) {
return os.str();
}
+
+
+
+string slsDetectorCommand::cmdTempControl(int narg, char *args[], int action) {
+ char answer[1000]="";
+ int val = -1;
+
+ if (action==HELP_ACTION)
+ return helpTempControl(narg, args, action);
+
+ myDet->setOnline(ONLINE_FLAG);
+
+ if (cmd == "temp_threshold") {
+ if (action==PUT_ACTION) {
+ double fval=0.0;
+ if (!sscanf(args[1],"%lf", &fval))
+ return string("cannot scan temp control value ")+string(args[1]);
+ val = fval * 1000;
+ myDet->setThresholdTemperature(val);
+ }
+ val = myDet->setThresholdTemperature();
+ if (val == -1)
+ sprintf(answer,"%d",val);
+ else
+ sprintf(answer,"%.2f°C", (double)val/1000.000);
+ }
+
+ else if (cmd == "temp_control") {
+ if (action==PUT_ACTION) {
+ if (!sscanf(args[1],"%d", &val))
+ return string("cannot scan temp control value ")+string(args[1]);
+ if ((val!=0) && (val!=1))
+ return string ("temp_control option must be 0 or 1");
+ myDet->setTemperatureControl(val);
+ }
+ sprintf(answer,"%d", myDet->setTemperatureControl());
+ }
+
+ else if (cmd == "temp_event") {
+ if (action==PUT_ACTION) {
+ if (!sscanf(args[1],"%d", &val))
+ return string("cannot scan temp control value ")+string(args[1]);
+ if (val!=0)
+ return string ("temp_event option must be 0 to clear event");
+ myDet->setTemperatureEvent(val);
+ }
+ sprintf(answer,"%d", myDet->setTemperatureEvent());
+ }
+
+ else
+ return string ("cannot scan command " + cmd);
+
+ return string(answer);
+}
+
+
+
+string slsDetectorCommand::helpTempControl(int narg, char *args[], int action) {
+ ostringstream os;
+ if (action==PUT_ACTION || action==HELP_ACTION) {
+ os << "temp_threshold t \t sets the threshold temperature. Jungfrau only" << std::endl;
+ os << "temp_control t \t Enables/Disables the temperature control. 1 enables, 0 disables. JUNGFRAU ONLY" << std::endl;
+ os << "temp_event t \t Resets over-temperative event. Put only with option 0 to clear event. JUNGFRAU ONLY." << std::endl;
+ }
+ if (action==GET_ACTION || action==HELP_ACTION) {
+ os << "temp_threshold \t gets the threshold temperature. Jungfrau only." << std::endl;
+ os << "temp_control \t gets temperature control enable. 1 enabled, 0 disabled. JUNGFRAU ONLY" << std::endl;
+ os << "temp_event \t gets over-temperative event. Gets 1 if temperature went over threshold and control is enabled, else 0. /Disables the temperature control. JUNGFRAU ONLY." << std::endl;
+ }
+ return os.str();
+}
+
+
+
string slsDetectorCommand::cmdTiming(int narg, char *args[], int action){
#ifdef VERBOSE
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
@@ -5622,6 +5830,7 @@ string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action) {
}
+
myDet->setOnline(ONLINE_FLAG);
ret=myDet->setSpeed(index,t);
@@ -5796,7 +6005,9 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
}
sprintf(ans,"%d",myDet->powerChip());
return string(ans);
- } else if (cmd=="led") {
+ }
+
+ else if (cmd=="led") {
char ans[100];
int val=0;
myDet->setOnline(ONLINE_FLAG);
@@ -5810,6 +6021,19 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
sprintf(ans,"%d",~(myDet->readRegister(0x4d))&1);
return string(ans);
}
+
+ else if (cmd=="auto_comp_disable") {
+ char ans[100];
+ myDet->setOnline(ONLINE_FLAG);
+ if (action==PUT_ACTION){
+ int ival = -1;
+ if (!sscanf(args[1],"%d",&ival))
+ return string("could not scan auto_comp_control parameter " + string(args[1]));
+ myDet->setAutoComparatorDisableMode(ival);
+ }
+ sprintf(ans,"%d",myDet->setAutoComparatorDisableMode());
+ return string(ans);
+ }
else
return string("unknown command ")+cmd;
@@ -5829,6 +6053,7 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
os << "led s \t sets led status (0 off, 1 on)" << std::endl;
os << "powerchip i \t powers on or off the chip. i = 1 for on, i = 0 for off" << std::endl;
+ os << "auto_comp_disable i \t Currently not implemented. this mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). 1 enables mode, 0 disables mode. By default, mode is disabled (comparator is enabled throughout). (JUNGFRAU only). " << std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION) {
@@ -5838,6 +6063,7 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
os << "led \t returns led status (0 off, 1 on)" << std::endl;
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl;
os << "powerchip \t gets if the chip has been powered on or off" << std::endl;
+ os << "auto_comp_disable \t Currently not implemented. gets if the automatic comparator diable mode is enabled/disabled" << std::endl;
}
return os.str();
diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h
index dd8b4c73c..0c69ac923 100644
--- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h
+++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h
@@ -82,6 +82,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
static string helpImage(int narg, char *args[], int action);
static string helpCounter(int narg, char *args[], int action);
static string helpADC(int narg, char *args[], int action);
+ static string helpTempControl(int narg, char *args[], int action);
static string helpEnablefwrite(int narg, char *args[], int action);
static string helpOverwrite(int narg, char *args[], int action);
static string helpReceiver(int narg, char *args[], int action);
@@ -155,6 +156,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
string cmdImage(int narg, char *args[], int action);
string cmdCounter(int narg, char *args[], int action);
string cmdADC(int narg, char *args[], int action);
+ string cmdTempControl(int narg, char *args[], int action);
string cmdEnablefwrite(int narg, char *args[], int action);
string cmdOverwrite(int narg, char *args[], int action);
string cmdReceiver(int narg, char *args[], int action);
diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h
index bf64462bc..1ac5e5b14 100644
--- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h
+++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h
@@ -295,7 +295,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/**
returns currently the loaded trimfile/settingsfile name
*/
- virtual const char *getSettingsFile()=0;
+ virtual string getSettingsFile()=0;
/**
@@ -537,7 +537,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
DO NOT USE!!! ONLY EXPERT USER!!!
*/
- virtual int writeRegister(int addr, int val)=0;
+ virtual uint32_t writeRegister(uint32_t addr, uint32_t val)=0;
/**
@@ -548,7 +548,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
DO NOT USE!!! ONLY EXPERT USER!!!
*/
- virtual int writeAdcRegister(int addr, int val)=0;
+ virtual int writeAdcRegister(int addr, int val)=0;
/**
@@ -558,7 +558,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
DO NOT USE!!! ONLY EXPERT USER!!!
*/
- virtual int readRegister(int addr)=0;
+ virtual uint32_t readRegister(uint32_t addr)=0;
/**
@@ -569,7 +569,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
DO NOT USE!!! ONLY EXPERT USER!!!
*/
- virtual int setBit(int addr, int n)=0;
+ virtual uint32_t setBit(uint32_t addr, int n)=0;
/**
@@ -580,7 +580,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
DO NOT USE!!! ONLY EXPERT USER!!!
*/
- virtual int clearBit(int addr, int n)=0;
+ virtual uint32_t clearBit(uint32_t addr, int n)=0;
/**
@@ -622,6 +622,12 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/
virtual int powerChip(int ival= -1)=0;
+ /** automatic comparator disable for Jungfrau only
+ \param ival on is 1, off is 0, -1 to get
+ \returns OK or FAIL
+ */
+ virtual int setAutoComparatorDisableMode(int ival= -1)=0;
+
/** saves the modules settings/trimbits writing to a file
\param fname file name . Axtension is automatically generated!
\param imod module number, -1 means all modules
@@ -658,6 +664,30 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/
virtual dacs_t getADC(dacIndex index, int imod=-1)=0;
+ /**
+ set/gets threshold temperature (Jungfrau only)
+ \param val value in millidegrees, -1 gets
+ \param imod module number, -1 is all
+ \returns threshold temperature in millidegrees
+ */
+ virtual int setThresholdTemperature(int val=-1, int imod=-1)=0;
+
+ /**
+ enables/disables temperature control (Jungfrau only)
+ \param val value, -1 gets
+ \param imod module number, -1 is all
+ \returns temperature control enable
+ */
+ virtual int setTemperatureControl(int val=-1, int imod=-1)=0;
+
+ /**
+ Resets/ gets over-temperature event (Jungfrau only)
+ \param val value, -1 gets
+ \param imod module number, -1 is all
+ \returns over-temperature event
+ */
+ virtual int setTemperatureEvent(int val=-1, int imod=-1)=0;
+
/**
get the maximum size of the detector
\param d dimension
diff --git a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp
index 9afe150f1..cb709058d 100644
--- a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp
+++ b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp
@@ -149,8 +149,8 @@ slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detector
enum eiger_DacIndex{SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS};
//Copy other dacs
- int num_dacs_to_copy = 10;
- int dacs_to_copy[] = {SVP,VTR,VRS,SVN,VTGSTV,CAL,RXB_RB,RXB_LB,VCN,VIS};
+ int num_dacs_to_copy = 9;
+ int dacs_to_copy[] = {SVP,VTR,SVN,VTGSTV,CAL,RXB_RB,RXB_LB,VCN,VIS};
for (int i = 0; i < num_dacs_to_copy; ++i) {
if(a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) {
deleteModule(myMod);
@@ -160,8 +160,8 @@ slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detector
}
//Interpolate vrf, vcmp, vcp
- int num_dacs_to_interpolate = 6;
- int dacs_to_interpolate[] = {VRF,VCMP_LL,VCMP_LR,VCMP_RL,VCMP_RR,VCP};
+ int num_dacs_to_interpolate = 7;
+ int dacs_to_interpolate[] = {VRF,VCMP_LL,VCMP_LR,VCMP_RL,VCMP_RR,VCP, VRS};
for (int i = 0; i < num_dacs_to_interpolate; ++i) {
myMod->dacs[dacs_to_interpolate[i]] = linearInterpolation(energy, e1, e2,
a->dacs[dacs_to_interpolate[i]], b->dacs[dacs_to_interpolate[i]]);
diff --git a/slsDetectorSoftware/slsDetectorClient/CMakeLists.txt b/slsDetectorSoftware/slsDetectorClient/CMakeLists.txt
index 0dcc2fb9a..aa65dcf79 100644
--- a/slsDetectorSoftware/slsDetectorClient/CMakeLists.txt
+++ b/slsDetectorSoftware/slsDetectorClient/CMakeLists.txt
@@ -68,3 +68,4 @@ set_target_properties(sls_detector_help PROPERTIES
COMPILE_DEFINITIONS HELP=1
)
+install(TARGETS sls_detector_put sls_detector_get sls_detector_acquire sls_detector_help DESTINATION bin)
diff --git a/slsDetectorSoftware/slsDetectorServer/blackfin.h b/slsDetectorSoftware/slsDetectorServer/blackfin.h
index 55b3a39b1..841dee257 100755
--- a/slsDetectorSoftware/slsDetectorServer/blackfin.h
+++ b/slsDetectorSoftware/slsDetectorServer/blackfin.h
@@ -9,9 +9,10 @@
/* global variables */
-u_int32_t CSP0BASE = 0;
+u_int64_t CSP0BASE = 0;
#define CSP0 0x20200000
#define MEM_SIZE 0x100000
+#define MEM_MAP_SHIFT 1
@@ -103,7 +104,7 @@ int64_t set64BitReg(int64_t value, int aLSB, int aMSB){
* @retuns 32 bit data read
*/
u_int32_t readRegister(u_int32_t offset) {
- return bus_r(offset << 11);
+ return bus_r(offset << MEM_MAP_SHIFT);
}
/**
@@ -112,7 +113,7 @@ u_int32_t readRegister(u_int32_t offset) {
* @param data 32 bit data
*/
u_int32_t writeRegister(u_int32_t offset, u_int32_t data) {
- bus_w(offset << 11, data);
+ bus_w(offset << MEM_MAP_SHIFT, data);
return readRegister(offset);
}
@@ -122,10 +123,14 @@ u_int32_t writeRegister(u_int32_t offset, u_int32_t data) {
*/
int mapCSP0(void) {
// if not mapped
- if (!CSP0BASE) {
+ if (CSP0BASE == 0) {
printf("Mapping memory\n");
#ifdef VIRTUAL
CSP0BASE = malloc(MEM_SIZE);
+ if (CSP0BASE == NULL) {
+ cprintf(BG_RED, "Error: Could not allocate virtual memory.\n");
+ return FAIL;
+ }
printf("memory allocated\n");
#else
int fd;
@@ -137,14 +142,15 @@ int mapCSP0(void) {
#ifdef VERBOSE
printf("/dev/mem opened\n");
#endif
- CSP0BASE = (u_int32_t)mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, CSP0);
- if (CSP0BASE == (u_int32_t)MAP_FAILED) {
+ CSP0BASE = mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, CSP0);
+ if (CSP0BASE == MAP_FAILED) {
cprintf(BG_RED, "Error: Can't map memmory area\n");
return FAIL;
}
- printf("CSPOBASE mapped from %08x to %08x\n",CSP0BASE,CSP0BASE+MEM_SIZE);
#endif
+ printf("CSPOBASE mapped from 0x%llx to 0x%llx\n",CSP0BASE, CSP0BASE+MEM_SIZE);
printf("Status Register: %08x\n",bus_r(STATUS_REG));
+
}else
printf("Memory already mapped before\n");
return OK;
diff --git a/slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h b/slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h
index 4122fb7cf..55d30b8c4 100755
--- a/slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h
+++ b/slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h
@@ -6,55 +6,68 @@
#endif
/* global variables */
-void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) {
-#ifdef VERBOSE
- if (numbitstosend == 16)
- printf("Writing to SPI Register: 0x%04x\n",val);
- else
- printf("Writing to SPI Register: 0x%08x\n", val);
-#endif
- u_int32_t valw;
+void SPIChipSelect (u_int32_t* valw, u_int32_t addr, u_int32_t csmask) {
- // start point
- valw = 0xffffffff; // old board compatibility (not using specific bits)
- bus_w (addr, valw);
+ // start point
+ (*valw) = 0xffffffff; // old board compatibility (not using specific bits)
+ bus_w (addr, (*valw));
- // chip sel bar down
- valw &= ~csmask; /* todo with test: done a bit different, not with previous value */
- bus_w (addr, valw);
-
- {
- int i = 0;
- for (i = 0; i < numbitstosend; ++i) {
-
- // clk down
- valw &= ~clkmask;
- bus_w (addr, valw);
-
- // write data (i)
- valw = ((valw & ~digoutmask) + // unset bit
- (((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb
- bus_w (addr, valw);
-
- // clk up
- valw |= clkmask ;
- bus_w (addr, valw);
- }
- }
-
- // chip sel bar up
- valw |= csmask; /* todo with test: not done for spi */
- bus_w (addr, valw);
-
- //clk down
- valw &= ~clkmask;
- bus_w (addr, valw);
-
- // stop point = start point of course
- valw = 0xffffffff; // old board compatibility (not using specific bits)
- bus_w (addr, valw);
+ // chip sel bar down
+ (*valw) &= ~csmask; /* todo with test: done a bit different, not with previous value */
+ bus_w (addr, (*valw));
}
+void SPIChipDeselect (u_int32_t* valw, u_int32_t addr, u_int32_t csmask, u_int32_t clkmask) {
+ // chip sel bar up
+ (*valw) |= csmask; /* todo with test: not done for spi */
+ bus_w (addr, (*valw));
+
+ //clk down
+ (*valw) &= ~clkmask;
+ bus_w (addr, (*valw));
+
+ // stop point = start point of course
+ (*valw) = 0xffffffff; // old board compatibility (not using specific bits)
+ bus_w (addr, (*valw));
+}
+
+void sendDataToSPI (u_int32_t* valw, u_int32_t addr, u_int32_t val, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) {
+ int i = 0;
+ for (i = 0; i < numbitstosend; ++i) {
+
+ // clk down
+ (*valw) &= ~clkmask;
+ bus_w (addr, (*valw));
+
+ // write data (i)
+ (*valw) = (((*valw) & ~digoutmask) + // unset bit
+ (((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb
+ bus_w (addr, (*valw));
+
+ // clk up
+ (*valw) |= clkmask ;
+ bus_w (addr, (*valw));
+ }
+}
+
+
+void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) {
+#ifdef VERBOSE
+ if (numbitstosend == 16)
+ printf("Writing to SPI Register: 0x%04x\n",val);
+ else
+ printf("Writing to SPI Register: 0x%08x\n", val);
+#endif
+
+ u_int32_t valw;
+
+ SPIChipSelect (&valw, addr, csmask);
+
+ sendDataToSPI(&valw, addr, val, numbitstosend, clkmask, digoutmask, digofset);
+
+ SPIChipDeselect(&valw, addr, csmask, clkmask);
+}
+
#endif //COMMON_SERVER_FUNCTIONS_H
diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h
index 4da4a3d8b..3e65ff53f 100644
--- a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h
+++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h
@@ -18,14 +18,16 @@ Here are the definitions, but the actual implementation should be done for each
// basic tests
void checkFirmwareCompatibility(int flag);
-#ifdef JUNGFRAUD
+#if defined(MYTHEN3D) || defined(JUNGFRAUD)
int checkType();
u_int32_t testFpga(void);
int testBus(void);
#endif
-#if defined(MYTHEND) || defined(JUNGFRAUD)
+#if defined(MYTHEND) || defined(JUNGFRAUD) || defined(MYTHEN3D)
int moduleTest( enum digitalTestMode arg, int imod);
+#endif
+#if defined(MYTHEND) || defined(JUNGFRAUD)
int detectorTest( enum digitalTestMode arg);
#endif
@@ -35,10 +37,13 @@ u_int64_t getFirmwareVersion();
#ifdef MYTHEND
int64_t getModuleId(enum idMode arg, int imod);
#elif JUNGFRAUD
+u_int64_t getFirmwareAPIVersion();
u_int16_t getHardwareVersionNumber();
u_int16_t getHardwareSerialNumber();
#endif
+#ifndef MYTHEN3D
u_int32_t getDetectorNumber();
+#endif
u_int64_t getDetectorMAC();
u_int32_t getDetectorIP();
@@ -66,11 +71,18 @@ uint32_t readRegister(uint32_t offset);
// firmware functions (resets)
-#ifdef JUNGFRAUD
+#if defined(MYTHEN3D) || defined(JUNGFRAUD)
int powerChip (int on);
void cleanFifos();
void resetCore();
void resetPeripheral();
+#endif
+#ifdef MYTHEN3D
+int getPhase(int i);
+int configurePhase(int val, enum CLKINDEX i);
+int configureFrequency(int val, int i);
+#elif JUNGFRAUD
+int autoCompDisable(int on);
int adcPhase(int st);
int getPhase();
#endif
@@ -123,16 +135,33 @@ int setThresholdEnergy(int ev, int imod);
#endif
// parameters - dac, adc, hv
-#ifdef JUNGFRAUD
+#if defined(MYTHEN3D) || defined(JUNGFRAUD)
void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset);
void initDac(int dacnum);
-extern void setAdc(int addr, int val); // AD9257.h
-int voltageToDac(int value);
-int dacToVoltage(unsigned int digital);
+int voltageToDac(int value);
+int dacToVoltage(unsigned int digital);
#endif
+#ifdef MYTHEN3D
+int setPower(enum DACINDEX ind, int val);
+int powerToDac(int value, int chip);
+int dacToPower(int value, int chip);
+#endif
+
+#ifdef JUNGFRAUD
+extern void setAdc(int addr, int val); // AD9257.h
+#endif
+
void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]);
+#ifdef MYTHEN3D
+int getVLimit();
+void setDacRegister(int dacnum,int dacvalue);
+int getDacRegister(int dacnum);
+#endif
+#ifndef MYTHEN3D
int getADC(enum ADCINDEX ind, int imod);
-#ifndef MYTHEND
+#endif
+
+#if !defined(MYTHEN3D) && !defined(MYTHEND)
int setHighVoltage(int val);
#endif
@@ -149,7 +178,7 @@ enum externalCommunicationMode setTiming( enum externalCommunicationMode arg);
#ifdef JUNGFRAUD
long int calcChecksum(int sourceip, int destip);
#endif
-#ifndef MYTHEND
+#if !defined(MYTHEN3D) && !defined(MYTHEND)
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival);
#endif
#if defined(JUNGFRAUD) || defined(EIGERD)
@@ -167,10 +196,13 @@ int resetCounterBlock(int startACQ);
int calibratePedestal(int frames);
// jungfrau specific - pll, flashing firmware
-#elif JUNGFRAUD
+#elif defined(JUNGFRAUD) || defined(MYTHEN3D)
void resetPLL();
u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val);
void configurePll();
+int setThresholdTemperature(int val);
+int setTemperatureControl(int val);
+int setTemperatureEvent(int val);
extern void eraseFlash(); // programfpga.h
extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h
extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h
@@ -194,7 +226,9 @@ int setAllTrimbits(int val);
int getAllTrimbits();
int getBebFPGATemp();
int activate(int enable);
-int setNetworkParameter(enum NETWORKINDEX mode, int value);
+#endif
+#if defined(JUNGFRAUD) || defined(EIGERD)
+int setNetworkParameter(enum NETWORKINDEX mode, int value);
#endif
diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c
index 5de718a47..c11201893 100755
--- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c
+++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c
@@ -12,7 +12,6 @@
#include
#include
-
extern int sockfd;
@@ -30,14 +29,13 @@ int main(int argc, char *argv[]){
// subsequent read/write to socket gives error - must handle locally
signal(SIGPIPE, SIG_IGN);
- // circumvent the basic tests
- if(argc > 1) {
- if(!strcasecmp(argv[1],"-debug")){
- debugflag = 1;
- argc=1;
- }
- }
-
+ // circumvent the basic tests
+ if(argc > 1) {
+ if(!strcasecmp(argv[1],"-debug")){
+ debugflag = 1;
+ argc=1;
+ }
+ }
#ifdef STOP_SERVER
char cmd[100];
@@ -85,8 +83,10 @@ int main(int argc, char *argv[]){
printf("function table assigned \n");
#endif
-
- printf("\nReady...\n\n");
+ if (b)
+ printf("\nControl Server Ready...\n\n");
+ else
+ printf("\nStop Server Ready...\n\n");
/* waits for connection */
while(retval!=GOODBYE) {
diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c
index 8d6df11df..5dca4b587 100755
--- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c
+++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c
@@ -29,6 +29,8 @@ const enum detectorType myDetectorType=PICASSO;
const enum detectorType myDetectorType=MOENCH;
#elif JUNGFRAUD
const enum detectorType myDetectorType=JUNGFRAU;
+#elif MYTHEN3D
+const enum detectorType myDetectorType=MYTHEN3;
#else
const enum detectorType myDetectorType=GENERIC;
#endif
@@ -48,7 +50,7 @@ int printSocketReadError() {
}
void basictests(int flag) {
- debugflag = flag;
+ debugflag = flag;
#ifdef SLS_DETECTOR_FUNCTION_LIST
checkFirmwareCompatibility(debugflag);
#endif
@@ -62,7 +64,7 @@ void init_detector(int controlserver) {
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (controlserver) {
- isControlServer = 1;
+ isControlServer = 1;
initControlServer();
}
else initStopServer();
@@ -181,6 +183,11 @@ const char* getFunctionName(enum detFuncs func) {
case F_ACTIVATE: return "F_ACTIVATE";
case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION";
case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION";
+ case F_THRESHOLD_TEMP: return "F_THRESHOLD_TEMP";
+ case F_TEMP_CONTROL: return "F_TEMP_CONTROL";
+ case F_TEMP_EVENT: return "F_TEMP_EVENT";
+ case F_AUTO_COMP_DISABLE: return "F_AUTO_COMP_DISABLE";
+
default: return "Unknown Function";
}
}
@@ -259,6 +266,10 @@ void function_table() {
flist[F_ACTIVATE] = &set_activate;
flist[F_PREPARE_ACQUISITION] = &prepare_acquisition;
flist[F_CLEANUP_ACQUISITION] = &cleanup_acquisition;
+ flist[F_THRESHOLD_TEMP] = &threshold_temp;
+ flist[F_TEMP_CONTROL] = &temp_control;
+ flist[F_TEMP_EVENT] = &temp_event;
+ flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable;
// check
if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) {
@@ -877,134 +888,134 @@ int calibration_pulse(int file_des) {
int set_dac(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int arg[3]={-1,-1,-1};
- int val=-1;
- enum dacIndex ind=0;
- int imod=-1;
- int retval[2]={-1,-1};
- int mV=0;
- sprintf(mess,"set DAC failed\n");
+ int ret=OK,ret1=OK;
+ int n=0;
+ int arg[3]={-1,-1,-1};
+ int val=-1;
+ enum dacIndex ind=0;
+ int imod=-1;
+ int retval[2]={-1,-1};
+ int mV=0;
+ sprintf(mess,"set DAC failed\n");
- // receive arguments
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
- ind=arg[0];
- imod=arg[1];
- mV=arg[2];
+ // receive arguments
+ n = receiveData(file_des,arg,sizeof(arg),INT32);
+ if (n < 0) return printSocketReadError();
+ ind=arg[0];
+ imod=arg[1];
+ mV=arg[2];
- n = receiveData(file_des,&val,sizeof(val),INT32);
- if (n < 0) return printSocketReadError();
+ n = receiveData(file_des,&val,sizeof(val),INT32);
+ if (n < 0) return printSocketReadError();
- // checks
+ // checks
#ifdef MYTHEND
#ifdef SLS_DETECTOR_FUNCTION_LIST
- if (imod>=getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"Module number %d out of range\n",imod);
- cprintf(RED, "Warning: %s", mess);
- }
+ if (imod>=getTotalNumberOfModules()) {
+ ret = FAIL;
+ sprintf(mess,"Module number %d out of range\n",imod);
+ cprintf(RED, "Warning: %s", mess);
+ }
#endif
#endif
- // check if dac exists for this detector
- enum DACINDEX idac=0;
+ // check if dac exists for this detector
+ enum DACINDEX idac=0;
#ifdef JUNGFRAUD
- if ((ind != HV_NEW) && (ind >= NDAC_OLDBOARD)) { //for compatibility with old board
- ret = FAIL;
- sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind);
- cprintf(RED, "Warning: %s", mess);
- }else
- idac = ind;
+ if ((ind != HV_NEW) && (ind >= NDAC_OLDBOARD)) { //for compatibility with old board
+ ret = FAIL;
+ sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind);
+ cprintf(RED, "Warning: %s", mess);
+ }else
+ idac = ind;
#else
- switch (ind) {
+ switch (ind) {
#ifdef MYTHEND
- case TRIMBIT_SIZE: //ind = VTRIM;
- case THRESHOLD:
- case SHAPER1:
- case SHAPER2:
- case CALIBRATION_PULSE:
- case PREAMP:
- break;
+ case TRIMBIT_SIZE: //ind = VTRIM;
+ case THRESHOLD:
+ case SHAPER1:
+ case SHAPER2:
+ case CALIBRATION_PULSE:
+ case PREAMP:
+ break;
#elif GOTTHARDD
- case G_VREF_DS :
- break;
- case G_VCASCN_PB:
- break;
- case G_VCASCP_PB:
- break;
- case G_VOUT_CM:
- break;
- case G_VCASC_OUT:
- break;
- case G_VIN_CM:
- break;
- case G_VREF_COMP:
- break;
- case G_IB_TESTC:
- break;
- case HV_POT:
- break;
+ case G_VREF_DS :
+ break;
+ case G_VCASCN_PB:
+ break;
+ case G_VCASCP_PB:
+ break;
+ case G_VOUT_CM:
+ break;
+ case G_VCASC_OUT:
+ break;
+ case G_VIN_CM:
+ break;
+ case G_VREF_COMP:
+ break;
+ case G_IB_TESTC:
+ break;
+ case HV_POT:
+ break;
#elif EIGERD
- case TRIMBIT_SIZE:
- idac = VTR;
- break;
- case THRESHOLD:
- idac = VTHRESHOLD;
- break;
- case E_SvP:
- idac = SVP;
- break;
- case E_SvN:
- idac = SVN;
- break;
- case E_Vtr:
- idac = VTR;
- break;
- case E_Vrf:
- idac = VRF;
- break;
- case E_Vrs:
- idac = VRS;
- break;
- case E_Vtgstv:
- idac = VTGSTV;
- break;
- case E_Vcmp_ll:
- idac = VCMP_LL;
- break;
- case E_Vcmp_lr:
- idac = VCMP_LR;
- break;
- case E_cal:
- idac = CAL;
- break;
- case E_Vcmp_rl:
- idac = VCMP_RL;
- break;
- case E_Vcmp_rr:
- idac = VCMP_RR;
- break;
- case E_rxb_rb:
- idac = RXB_RB;
- break;
- case E_rxb_lb:
- idac = RXB_LB;
- break;
- case E_Vcp:
- idac = VCP;
- break;
- case E_Vcn:
- idac = VCN;
- break;
- case E_Vis:
- idac = VIS;
- break;
- case HV_NEW:
- break;
- case IO_DELAY:
- break;
- /*
+ case TRIMBIT_SIZE:
+ idac = VTR;
+ break;
+ case THRESHOLD:
+ idac = VTHRESHOLD;
+ break;
+ case E_SvP:
+ idac = SVP;
+ break;
+ case E_SvN:
+ idac = SVN;
+ break;
+ case E_Vtr:
+ idac = VTR;
+ break;
+ case E_Vrf:
+ idac = VRF;
+ break;
+ case E_Vrs:
+ idac = VRS;
+ break;
+ case E_Vtgstv:
+ idac = VTGSTV;
+ break;
+ case E_Vcmp_ll:
+ idac = VCMP_LL;
+ break;
+ case E_Vcmp_lr:
+ idac = VCMP_LR;
+ break;
+ case E_cal:
+ idac = CAL;
+ break;
+ case E_Vcmp_rl:
+ idac = VCMP_RL;
+ break;
+ case E_Vcmp_rr:
+ idac = VCMP_RR;
+ break;
+ case E_rxb_rb:
+ idac = RXB_RB;
+ break;
+ case E_rxb_lb:
+ idac = RXB_LB;
+ break;
+ case E_Vcp:
+ idac = VCP;
+ break;
+ case E_Vcn:
+ idac = VCN;
+ break;
+ case E_Vis:
+ idac = VIS;
+ break;
+ case HV_NEW:
+ break;
+ case IO_DELAY:
+ break;
+ /*
#elif JUNGFRAUD
case V_DAC0:
idac = VB_COMP;
@@ -1032,107 +1043,233 @@ int set_dac(int file_des) {
break;
case HV_POT:
break;
- */
+ */
+#elif MYTHEN3D
+ case M_vIpre:
+ idac = vIpre;
+ break;
+ case M_vIbias:
+ idac = vIbias;
+ break;
+ case PREAMP:
+ idac = Vrf;
+ break;
+ case SHAPER1:
+ idac = VrfSh;
+ break;
+ case M_vIinSh:
+ idac = vIinSh;
+ break;
+ case M_VdcSh:
+ idac = VdcSh;
+ break;
+ case M_Vth2:
+ idac = Vth2;
+ break;
+ case M_VPL:
+ idac = VPL;
+ break;
+ case THRESHOLD:
+ idac = Vth1;
+ break;
+ case M_Vth3:
+ idac = Vth3;
+ break;
+ case TRIMBIT_SIZE:
+ idac = Vtrim;
+ break;
+ case M_casSh:
+ idac = casSh;
+ break;
+ case M_cas:
+ idac = cas;
+ break;
+ case M_vIbiasSh:
+ idac = vIbiasSh;
+ break;
+ case M_vIcin:
+ idac = vIcin;
+ break;
+ case CALIBRATION_PULSE: // !!! pulse height + 1400 DACu
+ idac = VPH;
+ break;
+ case M_vIpreOut:
+ idac = vIpreOut;
+ break;
+ case V_POWER_A:
+ idac = V_A;
+ break;
+ case V_POWER_B:
+ ipwr = V_B;
+ break;
+ case V_POWER_IO:
+ idac = V_IO;
+ break;
+ case V_POWER_CHIP:
+ idac = V_CHIP;
+ break;
+ case V_LIMIT:
+ idac = V_LIM;
+ break;
#endif
- default:
- ret = FAIL;
- sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind);
- cprintf(RED, "Warning: %s", mess);
- break;
- }
+ default:
+ ret = FAIL;
+ sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind);
+ cprintf(RED, "Warning: %s", mess);
+ break;
+ }
#endif
- // execute action
+ // execute action
#ifdef VERBOSE
- printf("Setting DAC %d of module %d to %d \n", idac, imod, val);
+ printf("Setting DAC %d of module %d to %d \n", idac, imod, val);
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
- int temp;
- if (ret==OK) {
- if (differentClients && lockStatus && val!=-1) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- } else {
+ int temp;
+ if (ret==OK) {
+ if (differentClients && lockStatus && val!=-1) {
+ ret = FAIL;
+ sprintf(mess,"Detector locked by %s\n",lastClientIP);
+ cprintf(RED, "Warning: %s", mess);
+ } else {
#ifdef EIGERD
- //iodelay
- if(ind == IO_DELAY)
- retval[0] = setIODelay(val,imod);
- //high voltage
- else
+ //iodelay
+ if(ind == IO_DELAY)
+ retval[0] = setIODelay(val,imod);
+ //high voltage
+ else
#endif
- if((ind == HV_POT) || (ind == HV_NEW)) {
- retval[0] = setHighVoltage(val);
+ if((ind == HV_POT) || (ind == HV_NEW)) {
+ retval[0] = setHighVoltage(val);
#ifdef EIGERD
- if ((retval[0] != SLAVE_HIGH_VOLTAGE_READ_VAL) && (retval[0] < 0)) {
- ret = FAIL;
- if(retval[0] == -1)
- sprintf(mess, "Setting high voltage failed.Bad value %d. The range is from 0 to 200 V.\n",val);
- else if(retval[0] == -2)
- strcpy(mess, "Setting high voltage failed. Serial/i2c communication failed.\n");
- else if(retval[0] == -3)
- strcpy(mess, "Getting high voltage failed. Serial/i2c communication failed.\n");
- cprintf(RED, "Warning: %s", mess);
- }
+ if ((retval[0] != SLAVE_HIGH_VOLTAGE_READ_VAL) && (retval[0] < 0)) {
+ ret = FAIL;
+ if(retval[0] == -1)
+ sprintf(mess, "Setting high voltage failed.Bad value %d. The range is from 0 to 200 V.\n",val);
+ else if(retval[0] == -2)
+ strcpy(mess, "Setting high voltage failed. Serial/i2c communication failed.\n");
+ else if(retval[0] == -3)
+ strcpy(mess, "Getting high voltage failed. Serial/i2c communication failed.\n");
+ cprintf(RED, "Warning: %s", mess);
+ }
#endif
- }
- //dac
- else{
- setDAC(idac,val,imod,mV,retval);
+ }
+#ifdef MYTHEN3D
+ else if ((ind >= V_POWER_A && ind <= V_POWER_CHIP) || ind == V_LIMIT) {
+ printf("Setting a power %d to %d\n",ind, val);
+
+ if (!mV) {
+ ret = FAIL;
+ strcpy(mess, "Power of index %d should be set in mV instead of DACu", idac);
+ cprintf(RED, "Warning: %s", mess);
+ val = -1;
+ }
+
+ int lim = getVLimit();
+ if (ind != V_LIMIT && lim != -1 && val > lim) {
+ ret = FAIL;
+ strcpy(mess, "Power of index %d is %d, should be less than %dmV\n", idac, val, lim);
+ cprintf(RED, "Warning: %s", mess);
+ val = -1;
+ }
+
+ retval[1] = retval[0] = setPower(idac,val);
+ if (val >= 0 && retval[1] != val) {
+ ret = FAIL;
+ sprintf(mess,"Setting power %d failed: wrote %d but read %d\n", idac, val, retval[1]);
+ cprintf(RED, "Warning: %s", mess);
+ }
+ }
+#endif
+ //dac
+ else{
+#ifdef MYTHEN3D
+ if( mV && val > MAX_DACVOLTVAL) {
+ ret = FAIL;
+ strcpy(mess, "Dac of index %d should be less than %dmV\n", idac, val, MAX_DACVOLTVAL);
+ cprintf(RED, "Warning: %s", mess);
+ val = -1;
+ }
+ else if( !mV && val >= MAX_DACVAL) {
+ ret = FAIL;
+ strcpy(mess, "Dac of index %d should be less than %d (dac value)\n", idac, val, MAX_DACVAL);
+ cprintf(RED, "Warning: %s", mess);
+ val = -1;
+ }
+
+ if (val >= 0) {
+ // conver to mV
+ int v = val;
+ if (!mV)
+ v = dacToVoltage(val);
+
+ //checkvlimit compliant
+ int lim = getVLimit();
+ if (lim!= -1 && v > lim) {
+ ret = FAIL;
+ strcpy(mess, "Dac of index %d should be less than %dmV (%d dac value)\n", idac, lim, voltageToDac(lim));
+ cprintf(RED, "Warning: %s", mess);
+ val = -1;
+ }
+ }
+#endif
+ setDAC(idac,val,imod,mV,retval);
#ifdef EIGERD
- if(val != -1) {
- //changing dac changes settings to undefined
- switch(idac){
- case VCMP_LL:
- case VCMP_LR:
- case VCMP_RL:
- case VCMP_RR:
- case VRF:
- case VCP:
- setSettings(UNDEFINED,-1);
- cprintf(RED,"Settings has been changed to undefined (changed specific dacs)\n");
- break;
- default:
- break;
- }
- }
+ if(val != -1) {
+ //changing dac changes settings to undefined
+ switch(idac){
+ case VCMP_LL:
+ case VCMP_LR:
+ case VCMP_RL:
+ case VCMP_RR:
+ case VRF:
+ case VCP:
+ setSettings(UNDEFINED,-1);
+ cprintf(RED,"Settings has been changed to undefined (changed specific dacs)\n");
+ break;
+ default:
+ break;
+ }
+ }
#endif
- //check
- if(mV)
- temp = retval[1];
- else
- temp = retval[0];
- if ((abs(temp-val)<=5) || val==-1) {
- ret=OK;
- } else {
- ret = FAIL;
- sprintf(mess,"Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp);
- cprintf(RED, "Warning: %s", mess);
- }
- }
- }
- }
+ //check
+ if (ret == OK) {
+ if(mV)
+ temp = retval[1];
+ else
+ temp = retval[0];
+ if ((abs(temp-val)<=5) || val==-1) {
+ ret = OK;
+ } else {
+ ret = FAIL;
+ sprintf(mess,"Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp);
+ cprintf(RED, "Warning: %s", mess);
+ }
+ }
+ }
+ }
+ }
#endif
#ifdef VERBOSE
- printf("DAC set to %d in dac units and %d mV\n", retval[0],retval[1]);
+ printf("DAC set to %d in dac units and %d mV\n", retval[0],retval[1]);
#endif
- if(ret == OK && differentClients)
- ret=FORCE_UPDATE;
+ if(ret == OK && differentClients)
+ ret=FORCE_UPDATE;
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
+ // ret could be swapped during sendData
+ ret1 = ret;
+ // send ok / fail
+ n = sendData(file_des,&ret1,sizeof(ret),INT32);
+ // send return argument
+ if (ret!=FAIL) {
+ n += sendData(file_des,&retval,sizeof(retval),INT32);
+ } else {
+ n += sendData(file_des,mess,sizeof(mess),OTHER);
+ }
- // return ok / fail
- return ret;
+ // return ok / fail
+ return ret;
}
@@ -1149,6 +1286,15 @@ int get_adc(int file_des) {
int imod=-1;
sprintf(mess,"get ADC failed\n");
+#ifdef MYTHEN3D
+ //to receive any arguments
+ while (n > 0)
+ n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
+ ret = FAIL;
+ sprintf(mess,"Function (Get ADC) is not implemented for this detector\n");
+ cprintf(RED, "Warning: %s", mess);
+#else
+
// receive arguments
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
@@ -1217,6 +1363,7 @@ int get_adc(int file_des) {
#endif
#ifdef VERBOSE
printf("ADC is %f\n", retval);
+#endif
#endif
if (ret==OK && differentClients)
@@ -1244,7 +1391,7 @@ int get_adc(int file_des) {
int write_register(int file_des) {
int ret=OK,ret1=OK;
int n=0;
- int retval=-1;
+ uint32_t retval=-1;
sprintf(mess,"write to register failed\n");
// receive arguments
@@ -1252,7 +1399,7 @@ int write_register(int file_des) {
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
int addr=arg[0];
- int val=arg[1];
+ uint32_t val=arg[1];
// execute action
if (differentClients && lockStatus) {
@@ -1302,7 +1449,7 @@ int write_register(int file_des) {
int read_register(int file_des) {
int ret=OK,ret1=OK;
int n=0;
- int retval=-1;
+ uint32_t retval=-1;
sprintf(mess,"read register failed\n");
// receive arguments
@@ -1553,7 +1700,7 @@ int set_chip(int file_des) {
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
- sprintf(mess,"Function (Set Channel) is not implemented for this detector\n");
+ sprintf(mess,"Function (Set Chip) is not implemented for this detector\n");
cprintf(RED, "Warning: %s", mess);
#else
sls_detector_chip myChip;
@@ -1629,7 +1776,7 @@ int get_chip(int file_des) {
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
- sprintf(mess,"Function (Set Channel) is not implemented for this detector\n");
+ sprintf(mess,"Function (Get Chip) is not implemented for this detector\n");
cprintf(RED, "Warning: %s", mess);
#else
@@ -1718,6 +1865,17 @@ int set_module(int file_des) {
#endif
sprintf(mess,"set module failed\n");
+
+#ifdef MYTHEN3D
+ //to receive any arguments
+ while (n > 0)
+ n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
+ ret = FAIL;
+ sprintf(mess,"Function (Set Module) is not implemented for this detector\n");
+ cprintf(RED, "Warning: %s", mess);
+#else
+
+
#ifdef SLS_DETECTOR_FUNCTION_LIST
int *myDac=NULL;
int *myAdc=NULL;
@@ -1896,6 +2054,7 @@ int set_module(int file_des) {
}
if (ret==OK && differentClients)
ret=FORCE_UPDATE;
+#endif
#endif
// ret could be swapped during sendData
@@ -1928,6 +2087,15 @@ int get_module(int file_des) {
sls_detector_module myModule;
sprintf(mess,"get module failed\n");
+#ifdef MYTHEN3D
+ //to receive any arguments
+ while (n > 0)
+ n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
+ ret = FAIL;
+ sprintf(mess,"Function (Get Module) is not implemented for this detector\n");
+ cprintf(RED, "Warning: %s", mess);
+#else
+
// receive arguments
n = receiveData(file_des,&arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
@@ -2000,6 +2168,7 @@ int get_module(int file_des) {
}
}
}
+#endif
#endif
if (ret==OK && differentClients)
ret=FORCE_UPDATE;
@@ -2064,6 +2233,16 @@ int set_settings(int file_des) {
enum detectorSettings isett=-1;
sprintf(mess,"set settings failed\n");
+#ifdef MYTHEN3D
+ //to receive any arguments
+ while (n > 0)
+ n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
+ ret = FAIL;
+ sprintf(mess,"Function (Set Settings) is not implemented for this detector\n");
+ cprintf(RED, "Warning: %s", mess);
+#else
+
+
// receive arguments
n = receiveData(file_des,&arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
@@ -2098,6 +2277,7 @@ int set_settings(int file_des) {
cprintf(RED, "Warning: %s", mess);
}
}
+#endif
#endif
if (ret==OK && differentClients)
@@ -2536,6 +2716,11 @@ int set_timer(int file_des) {
case DELAY_AFTER_TRIGGER:
#elif JUNGFRAUD
case DELAY_AFTER_TRIGGER:
+#elif MYTHEN3D
+ case DELAY_AFTER_TRIGGER:
+ case GATES_NUMBER:
+ case PROBES_NUMBER:
+ case SAMPLES_JCTB:
#endif
case FRAME_NUMBER:
case ACQUISITION_TIME:
@@ -2615,22 +2800,25 @@ int get_time_left(int file_des) {
switch(ind) {
#ifdef MYTHEND
case PROBES_NUMBER:
+#elif JUNGFRAUD
+ case FRAMES_FROM_START:
+ case FRAMES_FROM_START_PG:
+#elif MYTHEN3D
+ case GATES_NUMBER:
+ case PROBES_NUMBER:
+ case SAMPLES_JCTB:
+#endif
+#ifndef JUNGFRAUD
+ case GATES_NUMBER:
#endif
case FRAME_NUMBER:
case ACQUISITION_TIME:
case FRAME_PERIOD:
case DELAY_AFTER_TRIGGER:
-#ifndef JUNGFRAUD
- case GATES_NUMBER:
-#endif
case CYCLES_NUMBER:
case PROGRESS:
case ACTUAL_TIME:
case MEASUREMENT_TIME:
-#ifdef JUNGFRAUD
- case FRAMES_FROM_START:
- case FRAMES_FROM_START_PG:
-#endif
retval=getTimeLeft(ind);
break;
default:
@@ -2978,7 +3166,12 @@ int set_speed(int file_des) {
switch (arg) {
#ifdef JUNGFRAUD
case ADC_PHASE:
- adcPhase(val);
+ retval = adcPhase(val);
+ if ((val != 100000) && (retval!=val) && (val>=0)) {
+ ret=FAIL;
+ sprintf(mess,"could not change set adc phase: should be %d but is %d \n", val, retval);
+ cprintf(RED, "Warning: %s", mess);
+ }
break;
#endif
#ifdef MYTHEND
@@ -2991,6 +3184,9 @@ int set_speed(int file_des) {
case CLOCK_DIVIDER:
#elif JUNGFRAUD
case CLOCK_DIVIDER:
+#elif MYTHEN3D
+ case DBIT_CLOCK:
+ case DBIT_PHASE:
#endif
retval=setSpeed(arg, val);
if ((retval!=val) && (val>=0)) {
@@ -3473,6 +3669,26 @@ int configure_mac(int file_des) {
cprintf(RED, "Warning: %s", mess);
}
else {
+#ifdef EIGERD
+ // change mac to hardware mac, (for 1 gbe) change ip to hardware ip
+ if (idetectormacadd != getDetectorMAC()){
+ printf("*************************************************\n");
+ printf("WARNING: actual detector mac address %llx does not match the one from client %llx\n",getDetectorMAC(),idetectormacadd);
+ idetectormacadd = getDetectorMAC();
+ printf("WARNING: Matched detectormac to the hardware mac now\n");
+ printf("*************************************************\n");
+ }
+ //only for 1Gbe
+ if(!enableTenGigabitEthernet(-1)){
+ if (detipad != getDetectorIP()){
+ printf("*************************************************\n");
+ printf("WARNING: actual detector ip address %x does not match the one from client %x\n",getDetectorIP(),detipad);
+ detipad = getDetectorIP();
+ printf("WARNING: Matched detector ip to the hardware ip now\n");
+ printf("*************************************************\n");
+ }
+ }
+#endif
retval=configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport,udpport2,0); //digitalTestBit);
if(retval==-1) {
ret = FAIL;
@@ -3507,9 +3723,16 @@ int configure_mac(int file_des) {
// send return argument
if (ret==FAIL) {
n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
+ } else {
n += sendData(file_des,&retval,sizeof(retval),INT32);
-
+#ifdef EIGERD
+ char arg[2][50];
+ memset(arg,0,sizeof(arg));
+ sprintf(arg[0],"%llx",idetectormacadd);
+ sprintf(arg[1],"%x",detipad);
+ n += sendData(file_des,arg,sizeof(arg),OTHER);
+#endif
+ }
// return ok / fail
return ret;
}
@@ -4003,20 +4226,182 @@ int set_all_trimbits(int file_des){
int set_ctb_pattern(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Set CTB Pattern) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
+ int ret=OK,ret1=OK;
+ int n=0;
+ sprintf(mess,"Could not set pattern\n");
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
+#ifndef MYTHEN3D
+ //to receive any arguments
+ while (n > 0)
+ n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
+ ret = FAIL;
+ sprintf(mess,"Function (Set CTB Pattern) is not implemented for this detector\n");
+ cprintf(RED, "Error: %s", mess);
- // return ok / fail
- return ret;
+ // ret could be swapped during sendData
+ ret1 = ret;
+ // send ok / fail
+ n = sendData(file_des,&ret1,sizeof(ret),INT32);
+ // send return argument
+ n += sendData(file_des,mess,sizeof(mess),OTHER);
+
+ return ret;
+
+#else
+
+ int retval=-1;
+ int mode = -1;
+ int addr = -1, level = -1, nl = -1, start = -1, stop = -1;
+ uint64_t word = -1,retval64 = -1, t = -1;
+
+ n = receiveDataOnly(file_des, &mode, sizeof(mode));
+ printf("pattern mode is %d\n",mode);
+
+ switch (mode) {
+
+ case 0: //sets word
+ n = receiveDataOnly(file_des,&addr,sizeof(addr));
+ n = receiveDataOnly(file_des,&word,sizeof(word));
+ ret=OK;
+
+ printf("pattern addr is %d %llx\n",addr, word);
+ switch (addr) {
+ case -1:
+ retval64=writePatternIOControl(word);
+ break;
+ case -2:
+ retval64=writePatternClkControl(word);
+ break;
+ default:
+ retval64=writePatternWord(addr,word);
+ };
+
+
+ //write word;
+ //@param addr address of the word, -1 is I/O control register, -2 is clk control register
+ //@param word 64bit word to be written, -1 gets
+
+ n = sendDataOnly(file_des,&ret,sizeof(ret));
+ if (ret==FAIL)
+ n += sendDataOnly(file_des,mess,sizeof(mess));
+ else
+ n += sendDataOnly(file_des,&retval64,sizeof(retval64));
+ break;
+
+ case 1: //pattern loop
+ // printf("loop\n");
+ n = receiveDataOnly(file_des,&level,sizeof(level));
+ n = receiveDataOnly(file_des,&start,sizeof(start));
+ n = receiveDataOnly(file_des,&stop,sizeof(stop));
+ n = receiveDataOnly(file_des,&nl,sizeof(nl));
+
+
+
+ // printf("level %d start %x stop %x nl %d\n",level, start, stop, nl);
+ /** Sets the pattern or loop limits in the CTB
+ @param level -1 complete pattern, 0,1,2, loop level
+ @param start start address if >=0
+ @param stop stop address if >=0
+ @param n number of loops (if level >=0)
+ @returns OK/FAIL
+ */
+ ret=setPatternLoop(level, &start, &stop, &nl);
+
+ n = sendDataOnly(file_des,&ret,sizeof(ret));
+ if (ret==FAIL)
+ n += sendDataOnly(file_des,mess,sizeof(mess));
+ else {
+ n += sendDataOnly(file_des,&start,sizeof(start));
+ n += sendDataOnly(file_des,&stop,sizeof(stop));
+ n += sendDataOnly(file_des,&nl,sizeof(nl));
+ }
+ break;
+
+
+
+ case 2: //wait address
+ printf("wait\n");
+ n = receiveDataOnly(file_des,&level,sizeof(level));
+ n = receiveDataOnly(file_des,&addr,sizeof(addr));
+
+
+
+ /** Sets the wait address in the CTB
+ @param level 0,1,2, wait level
+ @param addr wait address, -1 gets
+ @returns actual value
+ */
+ printf("wait addr %d %x\n",level, addr);
+ retval=setPatternWaitAddress(level,addr);
+ printf("ret: wait addr %d %x\n",level, retval);
+ ret=OK;
+ n = sendDataOnly(file_des,&ret,sizeof(ret));
+ if (ret==FAIL)
+ n += sendDataOnly(file_des,mess,sizeof(mess));
+ else {
+ n += sendDataOnly(file_des,&retval,sizeof(retval));
+
+ }
+
+
+ break;
+
+
+ case 3: //wait time
+ printf("wait time\n");
+ n = receiveDataOnly(file_des,&level,sizeof(level));
+ n = receiveDataOnly(file_des,&t,sizeof(t));
+
+
+ /** Sets the wait time in the CTB
+ @param level 0,1,2, wait level
+ @param t wait time, -1 gets
+ @returns actual value
+ */
+
+ ret=OK;
+
+ retval64=setPatternWaitTime(level,t);
+
+ n = sendDataOnly(file_des,&ret,sizeof(ret));
+ if (ret==FAIL)
+ n += sendDataOnly(file_des,mess,sizeof(mess));
+ else
+ n += sendDataOnly(file_des,&retval64,sizeof(retval64));
+
+ break;
+
+
+
+ case 4:
+ n = receiveDataOnly(file_des,pat,sizeof(pat));
+ for (addr=0; addr<1024; addr++)
+ writePatternWord(addr,word);
+ ret=OK;
+ retval=0;
+ n = sendDataOnly(file_des,&ret,sizeof(ret));
+ if (ret==FAIL)
+ n += sendDataOnly(file_des,mess,sizeof(mess));
+ else
+ n += sendDataOnly(file_des,&retval64,sizeof(retval64));
+
+ break;
+
+
+
+ default:
+ ret=FAIL;
+ printf(mess);
+ sprintf(mess,"%s - wrong mode %d\n",mess, mode);
+ n = sendDataOnly(file_des,&ret,sizeof(ret));
+ n += sendDataOnly(file_des,mess,sizeof(mess));
+ }
+
+
+ // return ok / fail
+ return ret;
+#endif
}
@@ -4421,7 +4806,7 @@ int set_network_parameter(int file_des) {
int retval=-1;
sprintf(mess,"set network parameter failed\n");
-#ifndef EIGERD
+#if !defined(EIGERD) && !defined(JUNGFRAUD)
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
@@ -4442,7 +4827,7 @@ int set_network_parameter(int file_des) {
if (n < 0) return printSocketReadError();
// execute action
- if (differentClients && lockStatus && value<0) {
+ if (differentClients && lockStatus && value >= 0) {
ret = FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
cprintf(RED, "Warning: %s", mess);
@@ -4453,17 +4838,27 @@ int set_network_parameter(int file_des) {
printf("setting network parameter mode %d to %d\n",(int)mode,value);
#endif
switch (mode) {
+
+#ifdef EIGERD
+ case FLOW_CONTROL_10G:
+ index = FLOWCTRL_10G;
+ break;
case DETECTOR_TXN_DELAY_LEFT:
index = TXN_LEFT;
break;
case DETECTOR_TXN_DELAY_RIGHT:
index = TXN_RIGHT;
break;
+#endif
case DETECTOR_TXN_DELAY_FRAME:
index = TXN_FRAME;
- break;
- case FLOW_CONTROL_10G:
- index = FLOWCTRL_10G;
+#ifdef JUNGFRAUD
+ if (value > MAX_TIMESLOT_VAL) {
+ ret=FAIL;
+ sprintf(mess,"Transmission delay %d should be in range: 0 - %d\n", value, MAX_TIMESLOT_VAL);
+ cprintf(RED, "Warning: %s", mess);
+ }
+#endif
break;
default:
ret=FAIL;
@@ -4621,9 +5016,9 @@ int program_fpga(int file_des) {
#ifdef VERY_VERBOSE
printf("Done with program receiving command\n");
#endif
- if (isControlServer)
- basictests(debugflag);
- init_detector(isControlServer);
+ if (isControlServer)
+ basictests(debugflag);
+ init_detector(isControlServer);
}
#endif
if (ret==OK)
@@ -4669,9 +5064,9 @@ int reset_fpga(int file_des) {
}
#ifdef SLS_DETECTOR_FUNCTION_LIST
else {
- if (isControlServer)
- basictests(debugflag);
- init_detector(isControlServer);
+ if (isControlServer)
+ basictests(debugflag);
+ initControlServer(isControlServer);
ret = FORCE_UPDATE;
}
#endif
@@ -4732,7 +5127,10 @@ int power_chip(int file_des) {
ret=OK;
} else {
ret=FAIL;
- sprintf(mess,"Powering chip failed, wrote %d but read %d\n", arg, retval);
+ if(setTemperatureEvent(-1) == 1)
+ sprintf(mess,"Powering chip failed due to over-temperature event. Clear event & power chip again. Wrote %d, read %d \n", arg, retval);
+ else
+ sprintf(mess,"Powering chip failed, wrote %d but read %d\n", arg, retval);
cprintf(RED, "Warning: %s", mess);
}
}
@@ -4908,3 +5306,255 @@ int cleanup_acquisition(int file_des) {
}
+
+
+int threshold_temp(int file_des) {
+ int ret=OK,ret1=OK;
+ int n=0;
+ int retval=-1;
+ sprintf(mess,"could not set/get threshold temperature\n");
+
+#ifndef JUNGFRAUD
+ //to receive any arguments
+ while (n > 0)
+ n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
+ ret = FAIL;
+ sprintf(mess,"Function (Threshold Temp) is not implemented for this detector\n");
+ cprintf(RED, "%s", mess);
+#else
+ int arg[2]={-1,-1};
+ int val=-1;
+
+ // receive arguments
+ n = receiveData(file_des,arg,sizeof(arg),INT32);
+ if (n < 0) return printSocketReadError();
+ val=arg[0];
+ //ignoring imod
+ if (val > MAX_THRESHOLD_TEMP_VAL) {
+ ret=FAIL;
+ sprintf(mess,"Threshold Temp %d should be in range: 0 - %d\n", val, MAX_THRESHOLD_TEMP_VAL);
+ cprintf(RED, "Warning: %s", mess);
+ }
+
+
+#ifdef SLS_DETECTOR_FUNCTION_LIST
+ if (ret==OK) {
+#ifdef VERBOSE
+ printf("Setting Threshold Temperature to %d\n", val);
+#endif
+ retval=setThresholdTemperature(val);
+ }
+#endif
+#ifdef VERBOSE
+ printf("Threshold temperature is %d\n", retval);
+#endif
+
+ if (ret==OK && differentClients && val >= 0)
+ ret=FORCE_UPDATE;
+#endif
+
+ // ret could be swapped during sendData
+ ret1 = ret;
+ // send ok / fail
+ n = sendData(file_des,&ret1,sizeof(ret),INT32);
+ // send return argument
+ if (ret!=FAIL) {
+ n += sendData(file_des,&retval,sizeof(retval),INT32);
+ } else {
+ n += sendData(file_des,mess,sizeof(mess),OTHER);
+ }
+
+ // return ok / fail
+ return ret;
+}
+
+
+
+int temp_control(int file_des) {
+ int ret=OK,ret1=OK;
+ int n=0;
+ int retval=-1;
+ sprintf(mess,"could not set/get temperature control\n");
+
+#ifndef JUNGFRAUD
+ //to receive any arguments
+ while (n > 0)
+ n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
+ ret = FAIL;
+ sprintf(mess,"Function (Temperature control) is not implemented for this detector\n");
+ cprintf(RED, "%s", mess);
+#else
+ int arg[2]={-1,-1};
+ int val=-1;
+
+ // receive arguments
+ n = receiveData(file_des,arg,sizeof(arg),INT32);
+ if (n < 0) return printSocketReadError();
+ val=arg[0];
+ //ignoring imod
+
+
+#ifdef SLS_DETECTOR_FUNCTION_LIST
+ if (ret==OK) {
+#ifdef VERBOSE
+ printf("Setting Temperature control to %d\n", val);
+#endif
+ retval=setTemperatureControl(val);
+ }
+#endif
+#ifdef VERBOSE
+ printf("Temperature control is %d\n", retval);
+#endif
+ if (ret==OK && differentClients && val >= 0)
+ ret=FORCE_UPDATE;
+#endif
+
+ // ret could be swapped during sendData
+ ret1 = ret;
+ // send ok / fail
+ n = sendData(file_des,&ret1,sizeof(ret),INT32);
+ // send return argument
+ if (ret!=FAIL) {
+ n += sendData(file_des,&retval,sizeof(retval),INT32);
+ } else {
+ n += sendData(file_des,mess,sizeof(mess),OTHER);
+ }
+
+ // return ok / fail
+ return ret;
+}
+
+
+
+
+int temp_event(int file_des) {
+ int ret=OK,ret1=OK;
+ int n=0;
+ int retval=-1;
+ sprintf(mess,"could not set/get temperature event\n");
+
+#ifndef JUNGFRAUD
+ //to receive any arguments
+ while (n > 0)
+ n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
+ ret = FAIL;
+ sprintf(mess,"Function (Temperature Event) is not implemented for this detector\n");
+ cprintf(RED, "%s", mess);
+#else
+ int arg[2]={-1,-1};
+ int val=-1;
+
+ // receive arguments
+ n = receiveData(file_des,arg,sizeof(arg),INT32);
+ if (n < 0) return printSocketReadError();
+ val=arg[0];
+ //ignoring imod
+
+#ifdef SLS_DETECTOR_FUNCTION_LIST
+ if (ret==OK) {
+#ifdef VERBOSE
+ printf("Setting Temperature Event to %d\n", val);
+#endif
+ retval=setTemperatureEvent(val);
+ }
+#endif
+#ifdef VERBOSE
+ printf("Temperature Event is %d\n", retval);
+#endif
+
+ if (ret==OK && differentClients && val >= 0)
+ ret=FORCE_UPDATE;
+#endif
+
+ // ret could be swapped during sendData
+ ret1 = ret;
+ // send ok / fail
+ n = sendData(file_des,&ret1,sizeof(ret),INT32);
+ // send return argument
+ if (ret!=FAIL) {
+ n += sendData(file_des,&retval,sizeof(retval),INT32);
+ } else {
+ n += sendData(file_des,mess,sizeof(mess),OTHER);
+ }
+
+ // return ok / fail
+ return ret;
+}
+
+
+
+
+
+int auto_comp_disable(int file_des) {
+ int ret=OK,ret1=OK;
+ int n=0;
+ int retval=-1;
+ sprintf(mess,"auto comp disable failed\n");
+
+#ifndef JUNGFRAUD
+ //to receive any arguments
+ while (n > 0)
+ n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
+ ret = FAIL;
+ sprintf(mess,"Function (Auto Comp Disable) is not implemented for this detector\n");
+ cprintf(RED, "%s", mess);
+#else
+
+ //to receive any arguments
+ while (n > 0)
+ n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
+ ret = FAIL;
+ sprintf(mess,"Function (Auto Comp Disable) is not yet implemented for this detector\n");
+ cprintf(RED, "%s", mess);
+
+ /* will be connected after teh fpga upgrade
+
+ // receive arguments
+ int arg=-1;
+ n = receiveData(file_des,&arg,sizeof(arg),INT32);
+ if (n < 0) return printSocketReadError();
+
+ // execute action
+ if (differentClients && lockStatus && arg!=-1) {
+ ret = FAIL;
+ sprintf(mess,"Detector locked by %s\n",lastClientIP);
+ cprintf(RED, "Warning: %s", mess);
+ }
+#ifdef SLS_DETECTOR_FUNCTION_LIST
+ else {
+#ifdef VERBOSE
+ printf("Auto Comp Disable to %d\n", arg);
+#endif
+ retval=autoCompDisable(arg);
+
+#ifdef VERBOSE
+ printf("Auto comp disable set to: %d\n",retval);
+#endif
+ if (retval==arg || arg<0) {
+ ret=OK;
+ } else {
+ ret=FAIL;
+ sprintf(mess,"Atuo Comp Disable failed, wrote %d but read %d\n", arg, retval);
+ cprintf(RED, "Warning: %s", mess);
+ }
+ }
+#endif
+ if (ret==OK && differentClients)
+ ret=FORCE_UPDATE;
+ */
+#endif
+
+ // ret could be swapped during sendData
+ ret1 = ret;
+ // send ok / fail
+ n = sendData(file_des,&ret1,sizeof(ret),INT32);
+ // send return argument
+ if (ret==FAIL) {
+ n += sendData(file_des,mess,sizeof(mess),OTHER);
+ } else
+ n += sendData(file_des,&retval,sizeof(retval),INT32);
+
+ // return ok / fail
+ return ret;
+}
+
diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h
index e98feb57f..e593b0bf4 100755
--- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h
+++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h
@@ -88,6 +88,9 @@ int power_chip(int);
int set_activate(int);
int prepare_acquisition(int);
int cleanup_acquisition(int);
-
+int threshold_temp(int);
+int temp_control(int);
+int temp_event(int);
+int auto_comp_disable(int);
#endif
diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt
index 9a5bb6019..a7de05eed 100644
--- a/slsReceiverSoftware/CMakeLists.txt
+++ b/slsReceiverSoftware/CMakeLists.txt
@@ -61,9 +61,21 @@ add_library(slsReceiverShared SHARED
${SOURCES}
${HEADERS}
)
+
+set(PUBLICHEADERS
+ include/sls_receiver_defs.h
+ include/ansi.h
+ include/sls_receiver_funcs.h
+ include/MySocketTCP.h
+ include/genericSocket.h
+
+)
+
+
set_target_properties(slsReceiverShared PROPERTIES
LIBRARY_OUTPUT_NAME SlsReceiver
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+ PUBLIC_HEADER "${PUBLICHEADERS}"
)
add_executable(slsReceiver
@@ -82,3 +94,11 @@ target_link_libraries(slsReceiver
if (HDF5_FOUND)
target_link_libraries(slsReceiver ${HDF5_LIBRARIES})
endif ()
+
+
+
+install(TARGETS slsReceiverShared slsReceiverStatic slsReceiver
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ PUBLIC_HEADER DESTINATION include)
\ No newline at end of file
diff --git a/slsReceiverSoftware/gitInfo.txt b/slsReceiverSoftware/gitInfo.txt
index 12becbdbe..abab2e22b 100644
--- a/slsReceiverSoftware/gitInfo.txt
+++ b/slsReceiverSoftware/gitInfo.txt
@@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsReceiverSoftware
-URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
-Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
-Repsitory UUID: 7436d6c8d3538cef443e0fa76bc01762fd6cc246
-Revision: 688
-Branch: 3.0.1
-Last Changed Author: Dhanya_Maliakal
-Last Changed Rev: 3186
-Last Changed Date: 2017-12-06 08:45:14.000000002 +0100 ./src/UDPStandardImplementation.cpp
+URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
+Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
+Repsitory UUID: b58c3e8951625ed9124669404f6b68aca340a1b8
+Revision: 764
+Branch: developer
+Last Changed Author: Dhanya_Thattil
+Last Changed Rev: 3727
+Last Changed Date: 2018-03-13 10:29:32.000000002 +0100 ./src/slsReceiverTCPIPInterface.cpp
diff --git a/slsReceiverSoftware/include/gitInfoReceiver.h b/slsReceiverSoftware/include/gitInfoReceiver.h
index 12e1df72b..0d471e36c 100644
--- a/slsReceiverSoftware/include/gitInfoReceiver.h
+++ b/slsReceiverSoftware/include/gitInfoReceiver.h
@@ -1,6 +1,6 @@
-#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git"
-#define GITREPUUID "7436d6c8d3538cef443e0fa76bc01762fd6cc246"
-#define GITAUTH "Dhanya_Maliakal"
-#define GITREV 0x3186
-#define GITDATE 0x20171206
-#define GITBRANCH "3.0.1"
+#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
+#define GITREPUUID "b58c3e8951625ed9124669404f6b68aca340a1b8"
+#define GITAUTH "Dhanya_Thattil"
+#define GITREV 0x3727
+#define GITDATE 0x20180313
+#define GITBRANCH "developer"
diff --git a/slsReceiverSoftware/include/sls_receiver_defs.h b/slsReceiverSoftware/include/sls_receiver_defs.h
index 27c303fe5..0e4df0593 100755
--- a/slsReceiverSoftware/include/sls_receiver_defs.h
+++ b/slsReceiverSoftware/include/sls_receiver_defs.h
@@ -196,6 +196,7 @@ public:
case JUNGFRAU: return std::string("Jungfrau"); \
case JUNGFRAUCTB: return std::string("JungfrauCTB"); \
case PROPIX: return std::string("Propix"); \
+ case MYTHEN3: return std::string("Mythen3"); \
default: return std::string("Unknown"); \
}};
@@ -213,6 +214,7 @@ public:
if (type=="Jungfrau") return JUNGFRAU; \
if (type=="JungfrauCTB") return JUNGFRAUCTB; \
if (type=="Propix") return PROPIX; \
+ if (type=="Mythen3") return MYTHEN3; \
return GENERIC; \
};
diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp
index 936a92bd1..22c123ce7 100644
--- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp
+++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp
@@ -631,17 +631,18 @@ int slsReceiverTCPIPInterface::send_update() {
char defaultVal[MAX_STR_LENGTH];
memset(defaultVal, 0, sizeof(defaultVal));
char* path = NULL;
+ int n = 0;
- mySock->SendDataOnly(mySock->lastClientIP,sizeof(mySock->lastClientIP));
+ n += mySock->SendDataOnly(mySock->lastClientIP,sizeof(mySock->lastClientIP));
// filepath
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
path = receiverBase->getFilePath();
#endif
if (path == NULL)
- mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH);
+ n += mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH);
else {
- mySock->SendDataOnly(path,MAX_STR_LENGTH);
+ n += mySock->SendDataOnly(path,MAX_STR_LENGTH);
delete[] path;
}
@@ -650,9 +651,9 @@ int slsReceiverTCPIPInterface::send_update() {
path = receiverBase->getFileName();
#endif
if(path == NULL)
- mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH);
+ n += mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH);
else {
- mySock->SendDataOnly(path,MAX_STR_LENGTH);
+ n += mySock->SendDataOnly(path,MAX_STR_LENGTH);
delete[] path;
}
@@ -660,43 +661,43 @@ int slsReceiverTCPIPInterface::send_update() {
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
ind=receiverBase->getFileIndex();
#endif
- mySock->SendDataOnly(&ind,sizeof(ind));
+ n += mySock->SendDataOnly(&ind,sizeof(ind));
//file format
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
ind=(int)receiverBase->getFileFormat();
#endif
- mySock->SendDataOnly(&ind,sizeof(ind));
+ n += mySock->SendDataOnly(&ind,sizeof(ind));
// file write enable
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
ind=(int)receiverBase->getFileWriteEnable();
#endif
- mySock->SendDataOnly(&ind,sizeof(ind));
+ n += mySock->SendDataOnly(&ind,sizeof(ind));
// file overwrite enable
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
ind=(int)receiverBase->getOverwriteEnable();
#endif
- mySock->SendDataOnly(&ind,sizeof(ind));
+ n += mySock->SendDataOnly(&ind,sizeof(ind));
// receiver read frequency
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
ind=(int)receiverBase->getFrameToGuiFrequency();
#endif
- mySock->SendDataOnly(&ind,sizeof(ind));
+ n += mySock->SendDataOnly(&ind,sizeof(ind));
// streaming port
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
ind=(int)receiverBase->getStreamingPort();
#endif
- mySock->SendDataOnly(&ind,sizeof(ind));
+ n += mySock->SendDataOnly(&ind,sizeof(ind));
// data streaming enable
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
ind=(int)receiverBase->getDataStreamEnable();
#endif
- mySock->SendDataOnly(&ind,sizeof(ind));
+ n += mySock->SendDataOnly(&ind,sizeof(ind));
// streaming source ip
#ifdef SLS_RECEIVER_UDP_FUNCTIONS