mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-12-28 07:01:19 +01:00
Compare commits
109 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 26c829d766 | |||
| 3fde5c5b55 | |||
| 3e5f546ebe | |||
| 9833a7d330 | |||
| 8f9155e578 | |||
|
|
56c504abbb | ||
|
|
4d6346e678 | ||
|
|
dc7e448759 | ||
|
|
e658cbacda | ||
|
|
1e6c6dea71 | ||
|
|
befdcf7f36 | ||
|
|
02f5c472a8 | ||
|
|
75ed2cd2e4 | ||
|
|
3be045f9b6 | ||
|
|
8fae982802 | ||
|
|
128ec88b5f | ||
|
|
d5fc158330 | ||
|
|
864e6e4c81 | ||
|
|
343d96ff16 | ||
|
|
4142328437 | ||
|
|
6c797988c7 | ||
|
|
215c262981 | ||
|
|
081b809078 | ||
|
|
9263567cd8 | ||
|
|
58e90a85be | ||
|
|
6a80bc5b54 | ||
|
|
b9275646ad | ||
|
|
9e2f2697c7 | ||
|
|
b6b0df62b6 | ||
|
|
0ba537e479 | ||
|
|
75ddf535dc | ||
|
|
b1de501bef | ||
|
|
0f3a63f101 | ||
|
|
3b4b2d707f | ||
|
|
f405aa1733 | ||
|
|
df0fdb7ecb | ||
|
|
91b7a87557 | ||
|
|
9468b9ca1e | ||
|
|
d7982e178e | ||
|
|
9cf5714a5b | ||
|
|
0c9ac8911a | ||
|
|
4730c8c0a9 | ||
|
|
43efb8acfd | ||
|
|
6ecca8fcb0 | ||
|
|
17cb63a57f | ||
|
|
4f83fcb001 | ||
|
|
ab94af6d29 | ||
|
|
7c725cc69b | ||
|
|
f0198d2d2e | ||
|
|
5ddccbdee4 | ||
|
|
8fb39b8c7e | ||
|
|
bd5293f4b1 | ||
|
|
b91180f5b2 | ||
|
|
7c3b5065a5 | ||
|
|
9aef802bea | ||
|
|
f7d85231f2 | ||
|
|
5b3a911e8d | ||
|
|
65f5e1c1ab | ||
|
|
1afb9e3e48 | ||
|
|
09d3372cc0 | ||
|
|
cacb4c9d93 | ||
|
|
86490226ed | ||
|
|
eb203c93b2 | ||
|
|
44be9829d4 | ||
|
|
e450f5ec6a | ||
|
|
70a7217353 | ||
|
|
7dfb1b7192 | ||
|
|
da8d535dae | ||
|
|
404be013a2 | ||
|
|
6d4c0d0d46 | ||
|
|
54371bc6be | ||
|
|
5c230e2ac5 | ||
|
|
0814f6369d | ||
|
|
9e658e7947 | ||
|
|
bf57be309f | ||
|
|
6f34dddb5a | ||
|
|
c47f2f3449 | ||
|
|
5dcacaae2a | ||
|
|
aae4e3f993 | ||
|
|
78958c7699 | ||
|
|
575c9617c7 | ||
|
|
1ab80b0517 | ||
|
|
4b388f56b2 | ||
|
|
fb91ba25f3 | ||
|
|
1413244617 | ||
|
|
dc77b07c92 | ||
|
|
9f68fc6f3b | ||
|
|
47a769e677 | ||
|
|
ecaa8e45a4 | ||
|
|
36e92c194d | ||
|
|
4a8f2b5a69 | ||
|
|
22e0332833 | ||
|
|
53be854efd | ||
|
|
0a1aaec708 | ||
|
|
1cbbf9409f | ||
|
|
b16757e8d1 | ||
|
|
6c3165b31a | ||
|
|
e86e9361b6 | ||
|
|
475f0692a0 | ||
|
|
62de278f24 | ||
|
|
9e9c109898 | ||
|
|
111f8beab3 | ||
|
|
4c351ba686 | ||
|
|
a1f00518b8 | ||
|
|
3d2264fa56 | ||
|
|
3e9476cca2 | ||
|
|
490e756622 | ||
|
|
87ce1ed736 | ||
|
|
0896704de7 |
@@ -5,17 +5,17 @@
|
||||
CC = g++
|
||||
CXX = $(CC)
|
||||
ASM=$(shell echo "/lib/modules/`uname -r`/build/include")
|
||||
LDFLAGDET = -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsDetector -L/usr/lib64/ -lpthread
|
||||
LDFLAGRXR = -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsReceiver -L/usr/lib64/ -lpthread
|
||||
FLAGS= -Wall #-DEIGER_DEBUG2 -DEIGER_DEBUG -DEIGER_DEBUG3 #-DFIFO_DEBUG
|
||||
LDFLAGDET = -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsDetector -L/usr/lib64/ -pthread
|
||||
LDFLAGRXR = -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsReceiver -L/usr/lib64/ -pthread
|
||||
FLAGS= -Wall -pthread #-DEIGER_DEBUG2 -DEIGER_DEBUG -DEIGER_DEBUG3 #-DFIFO_DEBUG
|
||||
# -DVERBOSE
|
||||
|
||||
# Setting up the verbose flags
|
||||
ifeq ($(DEBUG),1)
|
||||
FLAGS = -Wall -DVERBOSE
|
||||
FLAGS = -Wall -pthread -DVERBOSE
|
||||
endif
|
||||
ifeq ($(DEBUG),2)
|
||||
FLAGS = -Wall -DVERYVERBOSE
|
||||
FLAGS = -Wall -pthread -DVERYVERBOSE
|
||||
endif
|
||||
|
||||
##############################################################
|
||||
|
||||
135
RELEASE.txt
Normal file
135
RELEASE.txt
Normal file
@@ -0,0 +1,135 @@
|
||||
SLS Detector Package 2.3.0 released on 2017-03-23
|
||||
================================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
|
||||
This document describes the differences between previous versions and 2.3.0 releases.
|
||||
|
||||
Manuals can be found under the 'manual' folder.
|
||||
|
||||
User documentation and other help can be accessed directly at this location:
|
||||
|
||||
https://www.psi.ch/detectors/users-support
|
||||
|
||||
If you have any software related questions or comments, please send them to:
|
||||
|
||||
dhanya.thattil@psi.ch
|
||||
|
||||
|
||||
|
||||
|
||||
CONTENTS
|
||||
|
||||
- Changes in User Interface
|
||||
- New Features
|
||||
- Resolved Issues
|
||||
- Known Issues
|
||||
|
||||
|
||||
|
||||
|
||||
Changes in User Interface
|
||||
=========================
|
||||
|
||||
This release supports the following features:
|
||||
|
||||
|
||||
Receiver
|
||||
--------
|
||||
- The files will be written in this format in the default mode:
|
||||
* ASCII file header of 1024 bytes (only for EIGER detectors)
|
||||
* series of images, each preceded by a Standard Header image
|
||||
(header described below)
|
||||
|
||||
|
||||
- Stanard Header image header in file and call back
|
||||
arguments defined. It is in the following format defined as
|
||||
sls_detector_header defined in
|
||||
slsReceiverSoftware/include/sls_receiver_defs.h
|
||||
Mostly 0 if not applicatble or implemented, but updated in next release
|
||||
from firmware.
|
||||
|
||||
* Frame Number : 8 bytes # Image Number
|
||||
* Exposure Length : 4 bytes # sub frame number in 32 bit mode
|
||||
Eiger.
|
||||
* Packet Number : 4 bytes # Number of packets in an image
|
||||
* Bunch ID : 8 bytes # Bunch Id in beamline for jungfrau.
|
||||
* Timestamp : 8 bytes # Not implemened
|
||||
* Module Id : 2 bytes # Not implemented
|
||||
* X Coordinate : 2 bytes # Id of part of detector in 1D
|
||||
* Y Coordinate : 2 bytes # Not implemented
|
||||
* Z Coordinate : 2 bytes # Not implemented
|
||||
* Debug : 4 bytes # Not implemented
|
||||
* Round Robin Number : 2 bytes # Not implemented
|
||||
* Detector Type : 1 byte # Detector type defined by enum
|
||||
detectorType in slsReceiverSoftware
|
||||
/include/sls_receiver_defs.h
|
||||
* Header Version : 1 byte # 1
|
||||
|
||||
|
||||
|
||||
- The call back value for Start Acquisition Call back is insignificant at the
|
||||
moment and left for future use. Instead, the following rules apply:
|
||||
* If file write is enabled from the client, we will write the files.
|
||||
* If callbacks are registered, they will be called.
|
||||
For example, the user prefers to write the data himself, one must disable
|
||||
file write (so we dont write) and register the callbacks (so the user gets
|
||||
the data).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
New Features
|
||||
============
|
||||
Eiger
|
||||
-----
|
||||
- Tau is moved to settings file, Gain and offset are removed from calibration
|
||||
file. Put settings only sets client variable, whereas putting threshold loads
|
||||
settings files to the server.
|
||||
|
||||
- Mode argument in starting up receiver is removed. FlippedData command is used
|
||||
in config file to specify bottom.
|
||||
|
||||
|
||||
Receiver
|
||||
--------
|
||||
- Image Reconstruction from the files are different as packet headers are not
|
||||
stored and a standard image header is used.
|
||||
|
||||
|
||||
General
|
||||
-------
|
||||
|
||||
- Users folder that gives an example on how to user the slsDetectorUsers and
|
||||
slsReceiverUsers class.
|
||||
|
||||
- Data is streamed from Receiver to Gui via ZMQ if gui call back defined.
|
||||
|
||||
|
||||
|
||||
|
||||
Resolved Issues
|
||||
===============
|
||||
|
||||
Eiger
|
||||
-----
|
||||
- Frame and packet counters in server to check delays were buggy.
|
||||
|
||||
|
||||
Known Issues
|
||||
============
|
||||
- X, Y and Z Coordinates do not exactly define the position of the
|
||||
detector in 3d. This will be defined in the next release. Other header
|
||||
parameters will be complete in the next release.
|
||||
|
||||
- Too many split files per detector especially for Eiger. Next Release will
|
||||
have a HDF5 version, with virtual file mapping all the split files in an
|
||||
acquisition.
|
||||
|
||||
- This version is tested only for Eiger and Jungfrau.
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ INCLUDES = -I .
|
||||
SRC_DET = mainClient.cpp
|
||||
SRC_REC = mainReceiver.cpp
|
||||
LIBDIR = ../../bin
|
||||
LDFLAG_DET = -L$(LIBDIR) -lSlsDetector -L/usr/lib64/ -lpthread
|
||||
LDFLAG_REC = -L$(LIBDIR) -lSlsReceiver -L/usr/lib64/ -lpthread
|
||||
LDFLAG_DET = -L$(LIBDIR) -lSlsDetector -L/usr/lib64/ -pthread
|
||||
LDFLAG_REC = -L$(LIBDIR) -lSlsReceiver -L/usr/lib64/ -pthread
|
||||
DESTDIR ?= ../docs
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
This file is an example of how to implement the slsDetectorUsers class
|
||||
You can compile it linking it to the slsDetector library
|
||||
|
||||
gcc mainClient.cpp -L lib -l SlsDetector -lm -lpthread
|
||||
gcc mainClient.cpp -L lib -l SlsDetector -lm -pthread
|
||||
|
||||
where lib is the location of libSlsDetector.so
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
This file is an example of how to implement the slsDetectorUsers class
|
||||
You can compile it linking it to the slsDetector library
|
||||
|
||||
gcc mainReceiver.cpp -L lib -l SlsDetector -lm -lpthread
|
||||
gcc mainReceiver.cpp -L lib -l SlsDetector -lm -pthread
|
||||
|
||||
where lib is the location of libSlsDetector.so
|
||||
|
||||
|
||||
@@ -16,21 +16,21 @@
|
||||
\section{Usage}
|
||||
|
||||
\subsection{Mandatory setup - Hardware}
|
||||
A EIGER single module (500~kpixels) needs:
|
||||
An EIGER single module (500~kpixels) needs:
|
||||
\begin{itemize}
|
||||
\item A chilled (water+alcohol) at approximately 21~$^{\circ}$C, which needs to dissipate 85~W.
|
||||
\item A power supply (12~V, 8~A).
|
||||
\item 2$\times$1~Gb/s Ethernet connectors to control the detector and, optionally, receive data at low rate. A DHCP server that gives IPs to the 1~Gb/s connectors of the detector is needed. Note that flow control has to be enabled on the switch you are using.
|
||||
\item 2$\times$10~Gb/s transceivers to optionally, receive data at high rate.
|
||||
\end{itemize}
|
||||
|
||||
Figure~\ref{fig:1} shows the relationship between the \textbf{Client} (which sits on a beamline control PC), the \textbf{Receiver} (which can run in multiple instances on one or more PCs which receive data from the detector. The receiver(s) does not necessary have to be running on the same PC as the client.) It is important that the receiver is closely connected to the detector.
|
||||
\end{itemize}
|
||||
The equipment scales linearly with the number of modules.
|
||||
Figure~\ref{fig:1} shows the relationship between the \textbf{Client} (which sits on a beamline control PC), the \textbf{Receiver} (which can run in multiple instances on one or more PCs which receive data from the detector. The receiver(s) does not necessary have to be running on the same PC as the client.) It is important that the receiver is closely connected to the detector (they have to be on the same network). Note that if you implement the 1Gb/s readout only: client, receiver and detector have to be all three in the same network. If you implement the 10Gb/s readout, then client, the 1~GbE of the detector and the receiver have to stay on the 1GbE. But the receiver data receiving device and the 10GbE detector can be on their private network, minimizing the missing packets.
|
||||
|
||||
\begin{figure}[t]
|
||||
\begin{center}
|
||||
\includegraphics[width=.8\textwidth]{Client2}
|
||||
\end{center}
|
||||
\caption{Communications protocol between the Client PC, the receiver pc and the detector.}
|
||||
\caption{Communications protocol between the Client PC, the receiver PC and the detector.}
|
||||
\label{fig:1}
|
||||
\end{figure}
|
||||
|
||||
@@ -43,10 +43,10 @@ The receiver is a process run on a PC closely connected to the detector. Open on
|
||||
|
||||
\begin{itemize}
|
||||
\item {\tt{./slsReceiver --rx\_tcpport xxxx}}
|
||||
\item {\tt{./slsReceiver --rx\_tcpport yyyy --mode 1}}
|
||||
\item {\tt{./slsReceiver --rx\_tcpport yyyy}}
|
||||
\end{itemize}
|
||||
|
||||
where xxxx, yyyy are the tcp port numbers. Use 1955 and 1956 for example. Note that {\tt{--mode 1}} is used only for the ``bottom'' half module. \\ Open as many receiver as half module boards. A single module has two half module boards.
|
||||
where xxxx, yyyy are the tcp port numbers. Use 1955 and 1956 for example. Note that in older version of the software {\tt{--mode 1}} was used only for the ``bottom'' half module. Now, the receiver for the bottom is open without arguments anymore, but still in the configuration file one needs to write {\tt{n:flippeddatax 1}}, where {\tt{n}} indicated the half module number, 1 if it is a module.
|
||||
\\ Open as many receiver as half module boards. A single module has two half module boards.
|
||||
|
||||
\subsection{Mandatory setup - Client}
|
||||
|
||||
@@ -60,7 +60,6 @@ The command line interface consists in these main functions:
|
||||
\item[sls\_detector\_get] to retrieve detector parameters
|
||||
\end{description}
|
||||
|
||||
|
||||
First, your detector should always be configured for each PC that you might want to use for controlling the detector. All the examples given here show the command {\tt{0-}}, which could be omitted for the EIGER system $0$. In the case more EIGER systems are controlled at once, the call of {\tt{1-}},.. becomes compulsory.
|
||||
|
||||
To make sure the shared memory is cleaned, before starting, one should do:
|
||||
@@ -71,9 +70,39 @@ To do that:
|
||||
\begin{verbatim}
|
||||
sls_detector_put 0-config mydetector.config
|
||||
\end{verbatim}
|
||||
Refer to sample configuration files to produce the appropriate one for your detector.
|
||||
\underline{In the case of cSAXS the {\tt{mydetector.config}} *at present* is:}\\
|
||||
\underline{/sls/X12SA/data/x12saop/EigerPackage/beb\_1.5M\_1Gb\_fiber.config}
|
||||
|
||||
In the config file, if client, receiver and detector are using \textbf{1GbE} the following lines are mandatory:
|
||||
\begin{verbatim}
|
||||
detsizechan 1024 512 #detetctor geometry, long side of the module first
|
||||
hostname beb059+beb058+ #1Gb detector hostname for controls
|
||||
0:rx_tcpport 1991 #tcpport for the first halfmodule
|
||||
0:rx_udpport 50011 #udp port first quadrant, first halfmodule
|
||||
0:rx_udpport2 50012 #udp port second quadrant, first halfmodule
|
||||
1:rx_tcpport 1992 #tcpport for the second halfmodule
|
||||
1:rx_udpport 50013 #udp port first quadrant, second halfmodule
|
||||
1:rx_udpport2 50014 #udp port second quadrant, second halfmodule
|
||||
rx_hostname x12sa-vcons #1Gb receiver pc hostname
|
||||
outdir /sls/X12SA/data/x12saop/Data10/Eiger0.5M
|
||||
\end{verbatim}
|
||||
|
||||
In the config file, if client, receiver and detector commands are on 1Gb, but detector data to receiver are sent using \textbf{10GbE} the following lines are mandatory:
|
||||
\begin{verbatim}
|
||||
detsizechan 1024 512 #detetctor geometry, long side of the module first
|
||||
hostname beb059+beb058+ #1Gb detector hostname for controls
|
||||
0:rx_tcpport 1991 #tcpport for the first halfmodule
|
||||
0:rx_udpport 50011 #udp port first quadrant, first halfmodule
|
||||
0:rx_udpport2 50012 #udp port second quadrant, first halfmodule
|
||||
0:rx_udpip 10.0.30.210 #udp IP of the receiver over 10Gb
|
||||
0:detectorip 10.0.30.100 #first half module 10 Gb IP
|
||||
1:rx_tcpport 1992 #tcpport for the second halfmodule
|
||||
1:rx_udpport 50013 #udp port first quadrant, second halfmodule
|
||||
1:rx_udpport2 50014 #udp port second quadrant, second halfmodule
|
||||
1:rx_udpip 10.0.40.210 #udp IP of the receiver over 10Gb,
|
||||
can be the same or different from 0:rx_udpip
|
||||
1:detectorip 10.0.40.101 #second half module 10 Gb IP
|
||||
rx_hostname x12sa-vcons #1Gb receiver pc hostname
|
||||
outdir /sls/X12SA/data/x12saop/Data10/Eiger0.5M
|
||||
\end{verbatim}
|
||||
|
||||
One can configure all the detector settings in a parameter file {\tt{setup.det}}, which is loaded by doing:
|
||||
\begin{verbatim}
|
||||
@@ -93,19 +122,44 @@ Other important settings that are configured in the {\tt{setup.det}} file are:
|
||||
One should notice that, by default, by choosing the option {\tt{dr 32}}, then the software automatically sets the detector to {\tt{clkdivider 2}}. By choosing the option {\tt{dr 16}}, the software automatically sets the detector to {\tt{clkdivider 1}}. One needs to choose {\tt{clkdivider 0}} after setting the {\tt{dr 16}} option to have the fastest frame rate.
|
||||
We would recommend expert users (beamline people) to write their parameters file for the users.
|
||||
|
||||
|
||||
\section{API versioning}
|
||||
The eigerDetectorServer running on the boards has a versioning API scheme that will make it crash if used with a wrong firmware.
|
||||
You can also check your versioning by hand with the code:
|
||||
\begin{verbatim}
|
||||
sls_detector_get softwareversion
|
||||
\end{verbatim}
|
||||
gets the server (slsDetectorSoftware) version (answer is something like: {\tt{softwareversion 111920160722}}.
|
||||
\begin{verbatim}
|
||||
sls_detector_get thisversion
|
||||
\end{verbatim}
|
||||
returns the client version. The answer can be {\tt{thisversion 111220160718}}.
|
||||
\begin{verbatim}
|
||||
/sls_detector_get detectorversion
|
||||
\end{verbatim}
|
||||
returns the firmware version . The answer can be {\tt{detectorversion 11}}.
|
||||
|
||||
\section{Setting up the threshold}
|
||||
\begin{verbatim}
|
||||
sls_detector_put 0-trimen N xxxx yyyy zzzz
|
||||
sls_detector_put 0-settings standard #[veryhighgain/highgain/lowgain/verylowgain] also possible
|
||||
sls_detector_put 0-threshold energy_in_eV
|
||||
\end{verbatim}
|
||||
The first line requires to specify how many ({\tt{N}}) and at which energies in eV {\{tt{xxxx}}, {\tt{yyyy}}, {\tt{zzzz}} and so on) trimmed files were generated (to allow for an interpolation). This line should normally be included into the {\tt{mydetector.config}} file and should be set for you by one of the detector group.
|
||||
NORMALLY, in this new calibration scheme, only {\tt{settings standard}} will be provided to you, unless specific cases to be discussed.
|
||||
The threshold at 6000 eV , for example would be set as:{\tt{sls\_detector\_put 0-threshold 6000}}.
|
||||
|
||||
\section{Standard acquisition}
|
||||
|
||||
You will then need to setup the detector threshold and settings, the exposure time, the number of real time frames and eventually how many real time frames should be acquired:
|
||||
After you setup the setting and the threshold, you need to specify the exposure time, the number of real time frames and eventually how many real time frames should be acquired:
|
||||
\begin{verbatim}
|
||||
sls_detector_put 0-settings [veryhighgain/highgain/standard/lowgain/verylowgain]
|
||||
sls_detector_put 0-threshold 6000
|
||||
sls_detector_put 0-exptime 1[time_is_s]
|
||||
sls_detector_put 0-frames 10
|
||||
sls_detector_put 0-period 0[time_is_s]
|
||||
\end{verbatim}
|
||||
In this case 10 consecutive 1~s frames will be acquired. Note that {\tt{period}} defines the sum of the acquisition time and the desired dead time before the next frame. If {\tt{period}} is set to 0, then the next frame will start as soon as the detector is ready to take another acquisition. \\
|
||||
In this acquisition 10 consecutive 1~s frames will be acquired. Note that {\tt{period}} defines the sum of the acquisition time and the desired dead time before the next frame. If {\tt{period}} is set to 0, then the next frame will start as soon as the detector is ready to take another acquisition. \\
|
||||
|
||||
For \E, at the moment 5 settings are possible: {\tt{standard}}, {\tt{lowgain}}, {\tt{verylowgain}}, {\tt{veryhighgain}} and {\tt{highgain}}. According to the setting chosen, one can reach different energies. Refer to the settings requirements for your detector.\\
|
||||
For \E, at the moment 5 settings are possible: {\tt{standard}}, {\tt{lowgain}}, {\tt{verylowgain}}, {\tt{veryhighgain}} and {\tt{highgain}}. According to the setting chosen, one can reach different requirements (low noise or high rate). Refer to the settings requirements for your detector.\\
|
||||
Notice that the option {\tt{settings standard/highgain/lowgain/veryhighgain/verylowgain}} actually loads the trimbit files so it is time consuming. Only setting the {\tt{threshold}} does not load trimbit files.
|
||||
|
||||
The threshold is expressed in (eV) as the proper threshold setting, i.e. normally is set to 50\% of the beam energy.
|
||||
@@ -124,16 +178,40 @@ To acquire simply type:
|
||||
\begin{verbatim}
|
||||
sls_detector_acquire 0-
|
||||
\end{verbatim}
|
||||
Note that acquiring is blocking.
|
||||
You can poll the status of the detector with:
|
||||
\begin{verbatim}
|
||||
sls_detector_get status
|
||||
\end{verbatim}
|
||||
If the detector is still acquiring, the answer will return {\tt{running}}. If the detector has finished and ready for the next acquisition, then it will return {\tt{idle}}.
|
||||
You can also ask for the status of the receiver, to know when it has returned and finished getting the data with:
|
||||
\begin{verbatim}
|
||||
sls_detector_get receiver
|
||||
\end{verbatim}
|
||||
|
||||
There is a more complex way of performing an acquisition, that is useful for debugging and in case one wants a non blocking behavior:
|
||||
\begin{itemize}
|
||||
\item {\tt{sls\_detector\_put 0-receiver start}}
|
||||
\item {\tt{sls\_detector\_put 0-status start}}
|
||||
\end{itemize}
|
||||
|
||||
You can poll the detector status using:
|
||||
\begin{verbatim}
|
||||
sls_detector_get 0-status
|
||||
\end{verbatim}
|
||||
If the receiver has not yet received the finished signal by the detector, the answer will return {\tt{running}}. If the detector has finished and ready for the next acquisition, then it will return {\tt{idle}}.
|
||||
When the detector is {\tt{idle}}, then you need to stop the receiver doing:
|
||||
\begin{itemize}
|
||||
\item {\tt{sls\_detector\_put 0-receiver stop}}
|
||||
\end{itemize}
|
||||
You can then reset to zero the number of frames caught, if you desire:
|
||||
\begin{itemize}
|
||||
\item {\tt{sls\_detector\_put 0-resetframescaught 0}}
|
||||
\end{itemize}
|
||||
|
||||
The detector will not accept other commands while acquiring. If an acquisition wishes to be properly aborted, then:
|
||||
\begin{verbatim}
|
||||
sls_detector_put 0-status stop
|
||||
\end{verbatim}
|
||||
\begin{itemize}
|
||||
\item {\tt{sls\_detector\_put 0-status stop}}
|
||||
\end{itemize}
|
||||
this same command can be used after a non proper abortion of the acquisition to reset to normal status the detector.
|
||||
|
||||
\section{Readout timing- maximum frame rate}\label{timing}
|
||||
@@ -151,7 +229,7 @@ In the case of REAL CONTINUOUS readout, i.e. continuous acquire and readout from
|
||||
\end{itemize}
|
||||
Note that in the {\tt{continuous}} mode, some buffering is still done on the memories, so a higher frame rate than the proper real continuos one can be achieved. Still, this extra buffering is possible till the memories are not saturated.
|
||||
The number of images that can be stored on memories are:
|
||||
\ \\
|
||||
\begin{table}
|
||||
\begin{tabular}{|c|c|}
|
||||
\hline
|
||||
dynamic range & images\\
|
||||
@@ -163,12 +241,14 @@ dynamic range & images\\
|
||||
16 & 7600\\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\caption{Amount of images that can be stored on board.}
|
||||
\end{table}
|
||||
|
||||
The maximum frame rate achievable with 10~GbE, {\tt{dr 16}}, {\tt{flags continuous}}, {\tt{flags parallel}},{\tt{clkdivider 0}}, \textbf{6.1~kHz}. This is currently limited by the connection between the Front End Board and the Backend board. We expect the 32 bit mode limit to be \textbf{2~kHz} ({\tt{clkdivider 2}}).
|
||||
In dynamic range {\tt{dr 8}} the frame rate is \textbf{11~kHz} and for{\tt{dr 4}} is \textbf{22~kHz}. For 4 and 8 bit mode the frame rate are directly limited by the speed of the detector chip and not by the readout boards.
|
||||
|
||||
Here is a list of all the readout times in the different configurations:
|
||||
\ \\
|
||||
\begin{table}
|
||||
\begin{tabular}{|c|c|c|c|c|}
|
||||
\hline
|
||||
dynamic range & clkdivider & mode & readout time ($\mu$s) & max frame rate (kHz)\\
|
||||
@@ -190,7 +270,8 @@ dynamic range & clkdivider & mode & readout time ($\mu$s) & max frame rate (kHz)
|
||||
32 & 2 & nonparallel & 504 & $<2$\\
|
||||
\hline
|
||||
\end{tabular}
|
||||
|
||||
\caption{Readout settings.}
|
||||
\end{table}
|
||||
\textbf{As if you run too fast, the detector could become noisier, it is important to match the detector settings to your frame rate. This can be done having more parameters files and load the one suitable with your experiment.} We experienced that {\tt{highgain}} settings could not be used at 6~kHz.
|
||||
|
||||
|
||||
@@ -216,67 +297,7 @@ Hardware-wise, the ENABLE OUT signal outputs when the chips are really acquiring
|
||||
|
||||
We are planning to change some functionality, i.e. unify the {\tt{trigger}} and {\tt{burst}} trigger modes and make both {\tt{frames}} and {\tt{cycles}} configurable at the same time.
|
||||
|
||||
\section{Offline processing and monitoring}
|
||||
\subsection{Offline image reconstruction}
|
||||
The offline image reconstruction is in {\tt{slsDetectorsPackage/slsImageReconstruction}}.
|
||||
|
||||
The detector writes a raw file per receiver. An offline image reconstruction executable has been written to collate the possible files together and produce cbf files. The executable uses the CBFlib-0.9.5 library (downloaded from the web as it download some architecture dependent packages at installation).\\
|
||||
\underline{At cSAXS, the CBFlib-0.9.5 has been compiled -such that the required packages are}\\\underline{ downloaded in /sls/X12SA/data/x12saop/EigerPackage/CBFlib-0.9.5.}\\
|
||||
|
||||
To use it for a single module:
|
||||
\begin{verbatim}
|
||||
cbfMaker [filename with dir]
|
||||
\end{verbatim}
|
||||
eg.
|
||||
{\tt{cbfMaker /scratch/run\_63\_d1\_f000000000000\_3.raw}}\\
|
||||
|
||||
To use it for a 1.5 multi modules:
|
||||
\begin{verbatim}
|
||||
cbfMaker [filename] [pixels x] [pixels y] ([singlemodulelongside_x] [start det])
|
||||
\end{verbatim}
|
||||
eg.
|
||||
{\tt cbfMaker /scratch/run\_63\_d0\_f000000000000\_3.raw 3072 512 1 0}.\\
|
||||
The {\tt{[singlemodulelongside\_x]}} and {\tt{[start det]}} param are optional. Defaults are ``1'', the detector long side is on the x coordinate and start to reconstruct from module 0.
|
||||
The executables:
|
||||
\begin{verbatim}
|
||||
bcfMaker1.5M [file_name_with_dir]
|
||||
bcfMaker9M [file_name_with_dir]
|
||||
\end{verbatim}
|
||||
contain the hardcoded geometry for the 1.5M (3 modules horizontal on the long side) and for the 9M at cSAXS: 6(short side)$\times$3 (long side) modules.\\
|
||||
Missing packets in a frame and border pixels ($\times 2$ and $\times 4$ are given with value $-1$ at the present time.
|
||||
|
||||
It is important to know, that the pixels at the edge between 2 chips count more as double size. We can virtually introduced 1 virtual pixel per double larger pixel, so to have an even number of counts everywhere. Virtual pixels (not filled ) between module gaps are also inserted.
|
||||
|
||||
\begin{verbatim}
|
||||
GapPixelsBetweenChips_x = 2;
|
||||
GapPixelsBetweenChips_y = 2;
|
||||
GapPixelsBetweenModules_x = 8;
|
||||
GapPixelsBetweenModules_y = 36;
|
||||
\end{verbatim}
|
||||
|
||||
\subsection{Read temperatures from boards}
|
||||
|
||||
With an updated kernel on the linux boards (ask to the SLS detector group for specifications), it is possible to monitor the temperature on the Back End Boards:
|
||||
\begin{verbatim}
|
||||
temp_fpga #gets the temperature of the fpga
|
||||
temp_fpgaext #gets the temperature close to the fpga
|
||||
temp_10ge #gets the temperature close to the 10GE
|
||||
temp_dcdc #gets the temperature close to the dc dc converter
|
||||
temp_sodl #gets the temperature close to the left so-dimm memory
|
||||
temp_sodr #gets the temperature close to the right so-dimm memory
|
||||
temp_fpgafl #gets the temperature of the left front end board fpga
|
||||
temp_fpgafr #gets the temperature of the left front end board fpga
|
||||
|
||||
\end{verbatim}
|
||||
|
||||
You need to use the command specifying from which board you desire the temperature readings, for example:
|
||||
\begin{verbatim}
|
||||
./sls_detector_get 0:temp_fpga
|
||||
./sls_detector_get 1:temp_fpga
|
||||
\end{verbatim}
|
||||
|
||||
\section{Advanced functionalities}
|
||||
\subsection{Autosumming and rate corrections}
|
||||
\section{Autosumming and rate corrections}
|
||||
|
||||
In the case of autosumming mode, i.e, {\tt{dr 32}}, the acquisition time ({\tt{exptime}} is broken in as many subframes as they fit into the acquisition time minus all the subframes readout times. By default the {\tt{subexptime}} is set to 2.621440~ms. This implies that 12 bit counter of \E will saturate when the rate is above or equal to 1.57~MHz/pixel. The minimum value is of order of 10~ns (although as explained values smaller than 500~$\mu$s do not make sense). The maximum value is 5.2~s.
|
||||
|
||||
@@ -287,7 +308,7 @@ sls_detector_put 0-subexptime [time_in_s]
|
||||
|
||||
One needs to realize that the readout time, for each subframe is 10.5~$\mu$s if the detector is in parallel mode. 500~$\mu$s if the detector is in non parallel mode. Note that in {\tt{dr 32}}, as the single frame readout from the chip is 500~$\mu$s, no {\tt{subexptime}}$<$500~$\mu$s can be set in {\tt{parallel}} mode. To have smaller {\tt{subexptime}}, you need the {\tt{nonparallel}} mode, although this will have a larger deadtime than the acquisition time.\\
|
||||
|
||||
Online rate corrections can be activated. They are particularly useful and implemented \textbf{only} in the autosumming mode, i.e. when {\tt{dr 32}} is activated as every single subframe is corrected before summing it. To correct for rate, the subframe duration has to be known to the correction algorithm.
|
||||
Online rate corrections can be activated for {\tt{dr=32}}. They are particularly useful in the autosumming mode as every single subframe is corrected before summing it. To correct for rate, the subframe duration has to be known to the correction algorithm. Rate corrections for {\tt{dr=16}} will be activated as well in the next firmware release.
|
||||
To activate the rate corrections, one should do:\\
|
||||
\begin{verbatim}
|
||||
sls_detector_put 0-ratecorr [tauval_in_ns]
|
||||
@@ -296,12 +317,19 @@ To deactivate:
|
||||
\begin{verbatim}
|
||||
sls_detector_put 0-ratecorr 0
|
||||
\end{verbatim}
|
||||
Default values for tau can be loaded from the calibration files. In this case, one needs to make sure the appropriate tau value is written in the calibration file, then need to load the appropriate {\tt{settings}} or {\tt{calibrations}} at least once before. Now to activate the rate corrections with the value written in the calibrations, once would do:
|
||||
Default values for tau can be loaded from the trimbit files. In this case, one needs to make sure the appropriate tau value is written in the trimbit files, then need to load the appropriate {\tt{settings}} and {\tt{vthreshold}} before. Now to activate the rate corrections with the value written in the trimbit file or interpolated from there, once would do:
|
||||
\begin{verbatim}
|
||||
sls_detector_put 0-ratecorr -1
|
||||
\end{verbatim}
|
||||
|
||||
Every time either the rate corrections are activated, $\tau$ is changed or the subframe length is changed, then a new correction table is evaluated. Note that computing the correction table is time consuming.
|
||||
\section{1Gb/s, 10Gb/s links}
|
||||
\subsection{Checking the 1Gb/s, 10Gb/s physical links}
|
||||
LEDs on the backpanel board at the back of each half module signal:
|
||||
\begin{itemize}
|
||||
\item the 1Gb/s physical link is signaled by the most external LED (should be green)
|
||||
\item the 10Gb/s physical link is signaled by the second most external LED next to the 1Gb/s one (should be green)
|
||||
\end{itemize}
|
||||
|
||||
\subsection{Delays in sending for 1Gb/s, 10Gb/s, 10Gb flow control, receiver fifo}
|
||||
|
||||
@@ -350,6 +378,91 @@ To activate back a module, do:
|
||||
\end{verbatim}
|
||||
|
||||
\end{itemize}
|
||||
\subsection{Setting up 10Gb correctly: experience so far}
|
||||
|
||||
For configuring well the 10Gb card not to loose packets, as root, do:
|
||||
\begin{verbatim}
|
||||
ethtool -G xth1 rx 4096, ethtool -C xth1 rx-usecs 100
|
||||
\end{verbatim}
|
||||
where {\tt{xth1}} can be replaced with the correct 10Gb device. To minimise loosing packets, priorities are set better as root user, so have the receiver as root.
|
||||
To try to bypass being root, we trued something like this:
|
||||
\begin{verbatim}
|
||||
/etc/security/limits.conf username – rtprio 99
|
||||
\end{verbatim}
|
||||
but somehow it did not fully worked so we kept the trick of being root.
|
||||
|
||||
Very important is to activate the flow control in 10Gb (in 1Gb it is on by default and not configurable)
|
||||
\begin{verbatim}
|
||||
./sls_detector_put flowcontrol_10g 1
|
||||
\end{verbatim}
|
||||
Set the transmission delays as explained in the manual.
|
||||
|
||||
\section{Offline processing and monitoring}
|
||||
\subsection{Offline image reconstruction}
|
||||
The offline image reconstruction is in {\tt{slsDetectorsPackage/slsImageReconstruction}}.
|
||||
|
||||
The detector writes a raw file per receiver. An offline image reconstruction executable has been written to collate the possible files together and produce cbf files. The executable uses the CBFlib-0.9.5 library (downloaded from the web as it download some architecture dependent packages at installation).\\
|
||||
\underline{At cSAXS, the CBFlib-0.9.5 has been compiled -such that the required packages are}\\\underline{ downloaded in /sls/X12SA/data/x12saop/EigerPackage/CBFlib-0.9.5.}\\
|
||||
|
||||
To use it for a single module:
|
||||
\begin{verbatim}
|
||||
cbfMaker [filename with dir]
|
||||
\end{verbatim}
|
||||
eg.
|
||||
{\tt{cbfMaker /scratch/run\_63\_d1\_f000000000000\_3.raw}}\\
|
||||
|
||||
To use it for a 1.5 multi modules:
|
||||
\begin{verbatim}
|
||||
cbfMaker [filename] [pixels x] [pixels y] ([singlemodulelongside_x] [start det])
|
||||
\end{verbatim}
|
||||
eg.
|
||||
{\tt cbfMaker /scratch/run\_63\_d0\_f000000000000\_3.raw 3072 512 1 0}.\\
|
||||
The {\tt{[singlemodulelongside\_x]}} and {\tt{[start det]}} param are optional. Defaults are ``1'', the detector long side is on the x coordinate and start to reconstruct from module 0.
|
||||
The executables:
|
||||
\begin{verbatim}
|
||||
bcfMaker1.5M [file_name_with_dir]
|
||||
bcfMaker9M [file_name_with_dir]
|
||||
\end{verbatim}
|
||||
contain the hardcoded geometry for the 1.5M (3 modules horizontal on the long side) and for the 9M at cSAXS: 6(short side)$\times$3 (long side) modules.\\
|
||||
Missing packets in a frame and border pixels ($\times 2$ and $\times 4$ are given with value $-1$ at the present time.
|
||||
|
||||
It is important to know, that the pixels at the edge between 2 chips count more as double size. We can virtually introduced 1 virtual pixel per double larger pixel, so to have an even number of counts everywhere. Virtual pixels (not filled ) between module gaps are also inserted.
|
||||
|
||||
\begin{verbatim}
|
||||
GapPixelsBetweenChips_x = 2;
|
||||
GapPixelsBetweenChips_y = 2;
|
||||
GapPixelsBetweenModules_x = 8;
|
||||
GapPixelsBetweenModules_y = 36;
|
||||
\end{verbatim}
|
||||
|
||||
\subsection{Read temperatures/HV from boards}
|
||||
|
||||
With an updated kernel on the linux boards (ask to the SLS detector group for specifications), it is possible to monitor the temperature on the Back End Boards:
|
||||
\begin{verbatim}
|
||||
temp_fpga #gets the temperature of the fpga
|
||||
temp_fpgaext #gets the temperature close to the fpga
|
||||
temp_10ge #gets the temperature close to the 10GE
|
||||
temp_dcdc #gets the temperature close to the dc dc converter
|
||||
temp_sodl #gets the temperature close to the left so-dimm memory
|
||||
temp_sodr #gets the temperature close to the right so-dimm memory
|
||||
temp_fpgafl #gets the temperature of the left front end board fpga
|
||||
temp_fpgafr #gets the temperature of the right front end board fpga
|
||||
|
||||
\end{verbatim}
|
||||
|
||||
You need to use the command specifying from which board you desire the temperature readings, for example:
|
||||
\begin{verbatim}
|
||||
./sls_detector_get 0:temp_fpga
|
||||
./sls_detector_get 1:temp_fpga
|
||||
\end{verbatim}
|
||||
In 500k--2M pixel systems there is a hardware temperature safety switch, which will cut power to the BEBs when reaching a too high temperature. For the 9M system, there is a temperature sensor read by the bchip100 PCU which will shutdown the detector when above a certain temperature.
|
||||
|
||||
The HV can also be set and read through the software:
|
||||
\begin{verbatim}
|
||||
./sls_detector_put vhighvoltage 150
|
||||
./sls_detector_get vhighvoltage
|
||||
\end{verbatim}
|
||||
Note that the get {\tt{vhighvoltage}} would return the measured HV from the master module only.
|
||||
|
||||
\appendix
|
||||
|
||||
@@ -376,47 +489,74 @@ Start the server again:
|
||||
|
||||
\section{Loading firmware bitfiles}
|
||||
|
||||
A \textbf{bcp} executable (which needs \textbf{tftp} installed on the PC, is needed. First of all, you need to press something on the detector: to programm bitfiles (firmware files), do a hard reset with a pin/thin stuff in the holes at the very back of the module. They are between the top 7 LED and the bottom 1 and opposite for the otehr side. Push hard till all LEDs are alternating green and red. After booting only the central one should be on green and red alternating. From a terminal, do:
|
||||
A \textbf{bcp} executable (which needs \textbf{tftp} installed on the PC, is needed. First of all, you need to press something on the detector: to programm bitfiles (firmware files), do a hard reset with a pin/thin stuff in the holes at the very back of the module. They are between the top 7 LED and the bottom 1 and opposite for the other side. Push hard till all LEDs are alternating green and red. After booting only the central one should be on green and red alternating. From a terminal, do:
|
||||
\begin{verbatim}
|
||||
nc -p 3000 -u bebxxx 3000
|
||||
\end{verbatim}
|
||||
where {\tt{xxx}} is the board number. It is enough top monitor with {\tt{nc}} only one board. Pres enter twice (till you see a prompt with the baord hostname printed) and keep this terminal to monitor. It takes a bit of time to load the bitfiles, but the terminal tells you.\\
|
||||
where {\tt{xxx}} is the board number. It is enough top monitor with {\tt{nc}} only one board. Pres enter twice (till you see a prompt with the board hostname printed) and keep this terminal to monitor. It takes a bit of time to load the bitfiles, but the terminal tells you.\\
|
||||
From another terminal you do:
|
||||
\begin{verbatim}
|
||||
./bcp feb_left.bit bebxxx:/febl
|
||||
sleep 300; #or till the screen over netcat has told you Successuful
|
||||
sleep 300; #or till the screen over netcat has told you Successful
|
||||
./bcp feb_right.bit bebxxx:/febr
|
||||
sleep 300; #or till the screen over netcat has told you Successuful
|
||||
sleep 300; #or till the screen over netcat has told you Successful
|
||||
./bcp download.bit bebxxx:/fw0
|
||||
sleep 300; #or till the screen over netcat has told you Successuful
|
||||
sleep 300; #or till the screen over netcat has told you Successful
|
||||
\end{verbatim}
|
||||
If you need to program a new kernel (only needed when told to do so):
|
||||
\begin{verbatim}
|
||||
./bcp kernel_local bebxxx:/kernel
|
||||
sleep 300; #or till the screen over netcat has told you Successuful
|
||||
sleep 300; #or till the screen over netcat has told you Successful
|
||||
\end{verbatim}
|
||||
do the same for the other boards. You can program in parallel many boards, but you cannot load two bitfiles on the same board till loading and copying one process has finished. So load all left febs together, then proceed to the right febs, then the bebs. Power off completely everything. Power it on.
|
||||
|
||||
do the same for the other boards. You can program in parallel many boards, but you cannot load two bitfiles on the same board till loading and copying one process has finished. So load all left febs together, then proceed to the left febs, then the bebs. Power off completely everything. Power it on.
|
||||
\section{Pulsing the detector}
|
||||
There are two ways to pulse the detector:
|
||||
\begin{itemize}
|
||||
\item \textbf{Pulse digitally:} when you are interested to the output readout and do not care about the analog response from the pixels:
|
||||
\begin{verbatim}
|
||||
sls_detector_put vthreshold 4000
|
||||
sls_detector_put vtr 4000
|
||||
sls_detector_put pulsechip N #to pulse N
|
||||
sls_detector_put pulsechip -1 #to get out of testing mode
|
||||
\end{verbatim}
|
||||
Note that the answer will be $2 \cdot \textrm{{\tt{N}}} +2$ in this case.
|
||||
|
||||
\section{Setting up 10Gb correctly: experience so far}
|
||||
\item \textbf{Pulse analogically:} You want to really check the analogical part of the detcetor, not just the readout.
|
||||
|
||||
For configuring well the 10Gb card not to loose packets, as root, do:
|
||||
\begin{verbatim}
|
||||
sls_detector_put vcall 3600
|
||||
sls_detector_put vthreshold 1700
|
||||
sls_detector_put vrf 3100
|
||||
for i in $(seq 0 7) ;
|
||||
do px=$((-255+i));
|
||||
sls_detector_put pulse 0 $px 0;
|
||||
for j in $(seq 0 255) ; do
|
||||
sls_detector_put pulsenmove N 0 1;
|
||||
done;
|
||||
done;
|
||||
sls_detector_p resmat 0
|
||||
sls_detector_acquire
|
||||
\end{verbatim}
|
||||
You read {\tt{N}} in every pixel if you are setup correctly.
|
||||
\end{itemize}
|
||||
|
||||
\section{Load a noise pattern with shape}
|
||||
For debug purposes, we have created a noise pattern with a shape. If you reconstruct correctly your image, you should be able to read ".EIGER'' in the same direction for both the top and bottom in normal human readable orientation.
|
||||
To load the special noise file look at {\tt{settingsdir/eiger/standard/eigernoise.sn0xx}} in the package.
|
||||
\begin{verbatim}
|
||||
ethtool -G xth1 rx 4096, ethtool -C xth1 rx-usecs 100
|
||||
sls_detector_put trimbits ../settingsdir/eiger/standard/eigernoise
|
||||
sls_detector_put vthreshold 4000
|
||||
sls_detector_put vtr 4000
|
||||
\end{verbatim}
|
||||
where {\tt{xth1}} can be replaced with the correct 10Gb device. To minimise loosing packets, priorities are set better as root user, so have the receiver as root.
|
||||
To try to bypass being root, we trued something like this:
|
||||
\begin{verbatim}
|
||||
/etc/security/limits.conf username – rtprio 99
|
||||
\end{verbatim}
|
||||
but somehow it did not fully worked so we kept the trick of being root.
|
||||
|
||||
Very important is to activate the flow control in 10Gb (in 1Gb it is on by default and not configurable)
|
||||
\begin{verbatim}
|
||||
./sls_detector_put flowcontrol_10g 1
|
||||
\end{verbatim}
|
||||
Set the transmission delays as explained in the manual.
|
||||
|
||||
\section{Running the (9M at cSAXS. For now)}
|
||||
\begin{itemize}
|
||||
\item login as {\tt{x12saop@xbl-daq-27}}
|
||||
\item {\tt{setup\_eiger}} \#loads environmental variables and brings you to the right directory to execute commands
|
||||
\item slsReceiverScript3 1991 36 \# from one shell.. opens 36 receivers
|
||||
\item p config ../../eiger\_9m\_10gb\_xbl-daq-27\_withbottom.config
|
||||
\end{itemize}
|
||||
|
||||
\end{document}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv2.2.0.16.4
|
||||
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv2.3.0.16.2
|
||||
BIN
settingsdir/eiger/standard/4500eV/noise.sn031
Normal file
BIN
settingsdir/eiger/standard/4500eV/noise.sn031
Normal file
Binary file not shown.
BIN
settingsdir/eiger/standard/4500eV/noise.sn032
Normal file
BIN
settingsdir/eiger/standard/4500eV/noise.sn032
Normal file
Binary file not shown.
BIN
settingsdir/eiger/standard/5400eV/noise.sn031
Normal file
BIN
settingsdir/eiger/standard/5400eV/noise.sn031
Normal file
Binary file not shown.
BIN
settingsdir/eiger/standard/5400eV/noise.sn032
Normal file
BIN
settingsdir/eiger/standard/5400eV/noise.sn032
Normal file
Binary file not shown.
BIN
settingsdir/eiger/standard/6400eV/noise.sn031
Normal file
BIN
settingsdir/eiger/standard/6400eV/noise.sn031
Normal file
Binary file not shown.
BIN
settingsdir/eiger/standard/6400eV/noise.sn032
Normal file
BIN
settingsdir/eiger/standard/6400eV/noise.sn032
Normal file
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
CC = g++
|
||||
CLAGS += -DVERBOSE #VERYBOSE
|
||||
LDLIBS += -lm -lstdc++ -lpthread
|
||||
LDLIBS += -lm -lstdc++ -pthread
|
||||
|
||||
LDIR = ../../slsDetectorSoftware
|
||||
RDIR = ../../slsReceiverSoftware
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorGui
|
||||
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_gui.git
|
||||
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_gui.git
|
||||
Repsitory UUID: 14ee36afeb077c918d34aaea39431a6e05f9436d
|
||||
Revision: 377
|
||||
Branch: developer
|
||||
Repsitory UUID: bddd126e382c1b2e8082419ff393f6e1fb17526a
|
||||
Revision: 381
|
||||
Branch: 2.3.1
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 377
|
||||
Last Changed Date: 2016-11-22 14:11:11 +0100
|
||||
Last Changed Rev: 381
|
||||
Last Changed Date: 2017-04-07 14:25:09 +0200
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//#define SVNPATH ""
|
||||
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_gui.git"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID "14ee36afeb077c918d34aaea39431a6e05f9436d"
|
||||
//#define SVNREV 0x377
|
||||
#define SVNREPUUID "bddd126e382c1b2e8082419ff393f6e1fb17526a"
|
||||
//#define SVNREV 0x381
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "Dhanya_Maliakal"
|
||||
#define SVNREV 0x377
|
||||
#define SVNDATE 0x20161122
|
||||
#define SVNREV 0x381
|
||||
#define SVNDATE 0x20170407
|
||||
//
|
||||
|
||||
@@ -69,14 +69,14 @@ gotthardVirtualServer: $(SRC_MYTHEN_SVC)
|
||||
|
||||
|
||||
%.o : %.cpp %.h Makefile
|
||||
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -lpthread -lrt $(LIBZMQ) #$(FLAGS)
|
||||
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -pthread -lrt $(LIBZMQ) $(FLAGS)
|
||||
|
||||
|
||||
package: $(OBJS) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a
|
||||
|
||||
|
||||
$(DESTDIR)/libSlsDetector.so: $(OBJS)
|
||||
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64 -lpthread -lrt $(LIBZMQ)
|
||||
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64 -pthread -lrt $(LIBZMQ)
|
||||
$(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR))
|
||||
mv libSlsDetector.so $(DESTDIR)
|
||||
|
||||
|
||||
@@ -561,6 +561,15 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA
|
||||
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) {
|
||||
@@ -571,6 +580,7 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA
|
||||
printf("received %d chips\n",nChips);
|
||||
#endif
|
||||
|
||||
|
||||
nChans=myMod->nchan;
|
||||
nchandiff=nChans-nchanold;
|
||||
if (nchanold!=nChans) {
|
||||
|
||||
@@ -19,11 +19,12 @@ using namespace std;
|
||||
|
||||
/** Error flags */
|
||||
/*Assumption: Only upto 63 detectors */
|
||||
#define CRITICAL_ERROR_MASK 0xFFFFFFFF
|
||||
|
||||
#define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL
|
||||
|
||||
#define CRITICAL_ERROR_MASK 0xFFFFFFFF
|
||||
|
||||
// 0xFFFFFFFF00000000ULL
|
||||
#define CANNOT_CONNECT_TO_DETECTOR 0x4000000000000000ULL
|
||||
#define CANNOT_CONNECT_TO_RECEIVER 0x2000000000000000ULL
|
||||
#define COULDNOT_SET_CONTROL_PORT 0x1000000000000000ULL
|
||||
@@ -40,10 +41,9 @@ using namespace std;
|
||||
#define COULD_NOT_CONFIGURE_MAC 0x0002000000000000ULL
|
||||
#define COULDNOT_START_RECEIVER 0x0001000000000000ULL // default error like starting threads
|
||||
#define COULDNOT_STOP_RECEIVER 0x0000800000000000ULL
|
||||
|
||||
// 0xFFFFFFFF00000000ULL
|
||||
|
||||
|
||||
// 0x00000000FFFFFFFFULL
|
||||
#define COULDNOT_SET_NETWORK_PARAMETER 0x0000000000000001ULL
|
||||
#define COULDNOT_SET_ROI 0x0000000000000002ULL
|
||||
#define RECEIVER_READ_FREQUENCY 0x0000000000000004ULL
|
||||
@@ -74,8 +74,9 @@ using namespace std;
|
||||
#define RECEIVER_READ_TIMER 0x0000000008000000ULL
|
||||
#define RECEIVER_ACQ_TIME_NOT_SET 0x0000000010000000ULL
|
||||
#define RECEIVER_FLIPPED_DATA_NOT_SET 0x0000000020000000ULL
|
||||
|
||||
#define THRESHOLD_NOT_SET 0x0000000040000000ULL
|
||||
// 0x00000000FFFFFFFFULL
|
||||
|
||||
/** @short class returning all error messages for error mask */
|
||||
class errorDefs {
|
||||
|
||||
@@ -234,6 +235,9 @@ public:
|
||||
if(slsErrorMask&RECEIVER_FLIPPED_DATA_NOT_SET)
|
||||
retval.append("Could not set receiver flipped data/bottom\n");
|
||||
|
||||
if(slsErrorMask&THRESHOLD_NOT_SET)
|
||||
retval.append("Could not set threshold\n");
|
||||
|
||||
//------------------------------------------------------ length of message
|
||||
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ class slsDetectorDefs: public virtual slsReceiverDefs{
|
||||
typedef struct {
|
||||
int module; /**< is the module number */
|
||||
int serialnumber; /**< is the module serial number */
|
||||
int nchan; /**< is the number of channels per chip */
|
||||
int nchan; /**< is the number of channels on the module*/
|
||||
int nchip; /**< is the number of chips on the module */
|
||||
int ndac; /**< is the number of dacs on the module */
|
||||
int nadc; /**< is the number of adcs on the module */
|
||||
|
||||
@@ -180,24 +180,31 @@ void Beb_GetModuleConfiguration(int* master, int* top, int* normal){
|
||||
void Beb_EndofDataSend(int tengiga){
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
int l_framepktcounter2, l_txndelaycounter, l_framedelaycounter, r_framepktcounter2, r_txndelaycounter, r_framedelaycounter;
|
||||
int l_framepktcounter2_new, l_txndelaycounter_new, l_framedelaycounter_new, r_framepktcounter2_new, r_txndelaycounter_new, r_framedelaycounter_new;
|
||||
int addr_l_framepktcounter2, addr_l_txndelaycounter, addr_l_framedelaycounter, addr_r_framepktcounter2, addr_r_txndelaycounter, addr_r_framedelaycounter;
|
||||
int l_framepktLsbcounter, l_framepktMsbcounter, l_txndelaycounter, l_framedelaycounter;
|
||||
int r_framepktLsbcounter, r_framepktMsbcounter, r_txndelaycounter, r_framedelaycounter;
|
||||
int l_framepktLsbcounter_new, l_framepktMsbcounter_new, l_txndelaycounter_new, l_framedelaycounter_new;
|
||||
int r_framepktLsbcounter_new, r_framepktMsbcounter_new, r_txndelaycounter_new, r_framedelaycounter_new;
|
||||
int addr_l_framepktLsbcounter, addr_l_framepktMsbcounter, addr_l_txndelaycounter, addr_l_framedelaycounter;
|
||||
int addr_r_framepktLsbcounter, addr_r_framepktMsbcounter, addr_r_txndelaycounter, addr_r_framedelaycounter;
|
||||
|
||||
switch(tengiga){
|
||||
case 0:
|
||||
addr_l_framepktcounter2 = ONE_GIGA_LEFT_PKT_SEND_COUNTER;
|
||||
addr_l_framepktLsbcounter = ONE_GIGA_LEFT_INDEX_LSB_COUNTER;
|
||||
addr_l_framepktMsbcounter = ONE_GIGA_LEFT_INDEX_MSB_COUNTER;
|
||||
addr_l_txndelaycounter = ONE_GIGA_LEFT_TXN_DELAY_COUNTER;
|
||||
addr_l_framedelaycounter = ONE_GIGA_LEFT_FRAME_DELAY_COUNTER;
|
||||
addr_r_framepktcounter2 = ONE_GIGA_RIGHT_PKT_SEND_COUNTER;
|
||||
addr_r_framepktLsbcounter = ONE_GIGA_RIGHT_INDEX_LSB_COUNTER;
|
||||
addr_r_framepktMsbcounter = ONE_GIGA_RIGHT_INDEX_MSB_COUNTER;
|
||||
addr_r_txndelaycounter = ONE_GIGA_RIGHT_TXN_DELAY_COUNTER;
|
||||
addr_r_framedelaycounter = ONE_GIGA_RIGHT_FRAME_DELAY_COUNTER;
|
||||
break;
|
||||
case 1:
|
||||
addr_l_framepktcounter2 = TEN_GIGA_LEFT_PKT_SEND_COUNTER;
|
||||
addr_l_framepktLsbcounter = TEN_GIGA_LEFT_INDEX_LSB_COUNTER;
|
||||
addr_l_framepktMsbcounter = TEN_GIGA_LEFT_INDEX_MSB_COUNTER;
|
||||
addr_l_txndelaycounter = TEN_GIGA_LEFT_TXN_DELAY_COUNTER;
|
||||
addr_l_framedelaycounter = TEN_GIGA_LEFT_FRAME_DELAY_COUNTER;
|
||||
addr_r_framepktcounter2 = TEN_GIGA_RIGHT_PKT_SEND_COUNTER;
|
||||
addr_r_framepktLsbcounter = TEN_GIGA_RIGHT_INDEX_LSB_COUNTER;
|
||||
addr_r_framepktMsbcounter = TEN_GIGA_RIGHT_INDEX_MSB_COUNTER;
|
||||
addr_r_txndelaycounter = TEN_GIGA_RIGHT_TXN_DELAY_COUNTER;
|
||||
addr_r_framedelaycounter = TEN_GIGA_RIGHT_FRAME_DELAY_COUNTER;
|
||||
break;
|
||||
@@ -211,23 +218,27 @@ void Beb_EndofDataSend(int tengiga){
|
||||
return;
|
||||
}else{
|
||||
//read data first time
|
||||
l_framepktcounter2 = Beb_Read32(csp0base, addr_l_framepktcounter2);
|
||||
l_framepktLsbcounter = Beb_Read32(csp0base, addr_l_framepktLsbcounter);
|
||||
l_framepktMsbcounter = Beb_Read32(csp0base, addr_l_framepktMsbcounter);
|
||||
l_txndelaycounter = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
l_framedelaycounter = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
r_framepktcounter2 = Beb_Read32(csp0base, addr_r_framepktcounter2);
|
||||
r_framepktLsbcounter = Beb_Read32(csp0base, addr_r_framepktLsbcounter);
|
||||
r_framepktMsbcounter = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
//#ifdef VERBOSE
|
||||
printf("\nLeft\n"
|
||||
"Framepacketcounter: %d\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n"
|
||||
"\nRight\n"
|
||||
"Framepacketcounter: %d\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n\n",
|
||||
l_framepktcounter2,l_txndelaycounter,l_framedelaycounter,
|
||||
r_framepktcounter2,r_txndelaycounter,r_framedelaycounter);
|
||||
l_framepktLsbcounter,l_framepktMsbcounter,l_txndelaycounter,l_framedelaycounter,
|
||||
r_framepktLsbcounter,r_framepktMsbcounter,r_txndelaycounter,r_framedelaycounter);
|
||||
//#endif
|
||||
|
||||
//keep comparing with previous values
|
||||
@@ -239,33 +250,42 @@ void Beb_EndofDataSend(int tengiga){
|
||||
usleep(maxtimer);
|
||||
|
||||
//read new values
|
||||
l_framepktcounter2_new = Beb_Read32(csp0base, addr_l_framepktcounter2);
|
||||
l_framepktLsbcounter_new = Beb_Read32(csp0base, addr_l_framepktLsbcounter);
|
||||
l_framepktMsbcounter_new = Beb_Read32(csp0base, addr_l_framepktMsbcounter);
|
||||
l_txndelaycounter_new = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
l_framedelaycounter_new = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
r_framepktcounter2_new = Beb_Read32(csp0base, addr_r_framepktcounter2);
|
||||
r_framepktLsbcounter_new = Beb_Read32(csp0base, addr_r_framepktLsbcounter);
|
||||
r_framepktMsbcounter_new = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter_new = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter_new = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
//#ifdef VERBOSE
|
||||
printf("\nLeft\n"
|
||||
"Framepacketcounter: %d\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n"
|
||||
"\nRight\n"
|
||||
"Framepacketcounter: %d\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n\n",
|
||||
l_framepktcounter2_new,l_txndelaycounter_new,l_framedelaycounter_new,
|
||||
r_framepktcounter2_new,r_txndelaycounter_new,r_framedelaycounter_new);
|
||||
l_framepktLsbcounter_new,l_framepktMsbcounter_new,l_txndelaycounter_new,l_framedelaycounter_new,
|
||||
r_framepktLsbcounter_new,r_framepktMsbcounter_new,r_txndelaycounter_new,r_framedelaycounter_new);
|
||||
//#endif
|
||||
|
||||
if ((l_framepktcounter2 == l_framepktcounter2_new) && (r_framepktcounter2 == r_framepktcounter2_new))
|
||||
if ((l_framepktLsbcounter == l_framepktLsbcounter_new) &&
|
||||
(l_framepktMsbcounter == l_framepktMsbcounter_new) &&
|
||||
(r_framepktLsbcounter == r_framepktLsbcounter_new) &&
|
||||
(r_framepktMsbcounter == r_framepktMsbcounter_new))
|
||||
break;
|
||||
|
||||
//update old values
|
||||
l_framepktcounter2 = l_framepktcounter2_new;
|
||||
l_framepktLsbcounter = l_framepktLsbcounter_new;
|
||||
l_framepktMsbcounter = l_framepktMsbcounter_new;
|
||||
l_txndelaycounter = l_txndelaycounter_new;
|
||||
l_framedelaycounter = l_framedelaycounter_new;
|
||||
r_framepktcounter2 = r_framepktcounter2_new;
|
||||
r_framepktLsbcounter = r_framepktLsbcounter_new;
|
||||
r_framepktMsbcounter = r_framepktMsbcounter_new;
|
||||
r_txndelaycounter = r_txndelaycounter_new;
|
||||
r_framedelaycounter = r_framedelaycounter_new;
|
||||
|
||||
|
||||
@@ -1,470 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
//return reversed 1 means good, 0 means failed
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
#include "xfs_types.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
#include "Beb.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
BebInfo::BebInfo(unsigned int beb_num){beb_number=beb_num;serial_address=0;src_mac_1GbE="";src_mac_10GbE="";src_ip_1GbE="";src_ip_10GbE=""; src_port_1GbE=src_port_10GbE=0;}
|
||||
bool BebInfo::SetHeaderInfo(bool ten_gig, string src_mac, string src_ip, unsigned int src_port){
|
||||
if(ten_gig){ src_mac_10GbE = src_mac; src_ip_10GbE = src_ip; src_port_10GbE = src_port;}
|
||||
else { src_mac_1GbE = src_mac; src_ip_1GbE = src_ip; src_port_1GbE = src_port;}
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool BebInfo::SetSerialAddress(unsigned int a){
|
||||
//address pre shifted
|
||||
if(a>0xff) return 0;
|
||||
serial_address = 0x04000000 | ((a&0xff)<<16);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void BebInfo::Print(){
|
||||
cout<<"\t"<<beb_number<<") Beb Info.:"<<endl;
|
||||
cout<<"\t\tSerial Add: 0x"<<hex<<serial_address<<dec<<endl;
|
||||
cout<<"\t\tMAC 1GbE: "<<src_mac_1GbE.c_str()<<endl;
|
||||
cout<<"\t\tIP 1GbE: "<<src_ip_1GbE.c_str()<<endl;
|
||||
cout<<"\t\tport 1GbE: "<<src_port_1GbE<<endl;
|
||||
cout<<"\t\tMAC 10GbE: "<<src_mac_10GbE.c_str()<<endl;
|
||||
cout<<"\t\tIP 10GbE: "<<src_ip_10GbE.c_str()<<endl;
|
||||
cout<<"\t\tport 10GbE: "<<src_port_10GbE<<endl;
|
||||
}
|
||||
|
||||
|
||||
Beb::Beb(int arg1){
|
||||
|
||||
send_ndata = 0;
|
||||
send_buffer_size = 1026;
|
||||
send_data_raw = new unsigned int [send_buffer_size+1];
|
||||
send_data = &send_data_raw[1];
|
||||
|
||||
recv_ndata = 0;
|
||||
recv_buffer_size = 1026;
|
||||
recv_data_raw = new unsigned int [recv_buffer_size+1];
|
||||
recv_data = &recv_data_raw[1];
|
||||
|
||||
if(!InitBebInfos()) exit(1);
|
||||
|
||||
cout<<"Printing Beb infos:"<<endl;
|
||||
for(unsigned int i=1;i<beb_infos.size();i++) beb_infos[i]->Print();
|
||||
cout<<endl<<endl;
|
||||
|
||||
bit_mode = 4;
|
||||
|
||||
ll = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR);
|
||||
|
||||
SetByteOrder();
|
||||
|
||||
|
||||
new_memory = new LocalLinkInterface();
|
||||
if(!new_memory->InitNewMemory(XPAR_PLB_LL_NEW_MEMORY, arg1))
|
||||
printf("New Memory FAIL\n");
|
||||
else
|
||||
printf("New Memory OK\n");
|
||||
|
||||
}
|
||||
|
||||
Beb::~Beb(){
|
||||
delete ll;
|
||||
delete [] send_data_raw;
|
||||
delete [] recv_data_raw;
|
||||
}
|
||||
|
||||
void Beb::ClearBebInfos(){
|
||||
for(unsigned int i=0;i<beb_infos.size();i++) delete beb_infos[i];
|
||||
beb_infos.clear();
|
||||
}
|
||||
|
||||
bool Beb::InitBebInfos(){//file name at some point
|
||||
ClearBebInfos();
|
||||
|
||||
BebInfo* b0 = new BebInfo(0);
|
||||
if(b0->SetSerialAddress(0xff)) beb_infos.push_back(b0); //all bebs for reset and possibly get request data?
|
||||
|
||||
if(!ReadSetUpFromFile("/home/root/executables/setup_beb.txt")) return 0;
|
||||
/*
|
||||
//loop through file to fill vector.
|
||||
BebInfo* b = new BebInfo(26);
|
||||
b->SetSerialAddress(0); //0xc4000000
|
||||
b->SetHeaderInfo(0,"00:50:c2:46:d9:34","129.129.205.78",42000 + 26); // 1 GbE, ip address can be acquire from the network "arp"
|
||||
b->SetHeaderInfo(1,"00:50:c2:46:d9:35","10.0.26.1",52000 + 26); //10 GbE, everything calculable/setable
|
||||
beb_infos.push_back(b);
|
||||
*/
|
||||
|
||||
return CheckSourceStuffBebInfo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Beb::SetBebSrcHeaderInfos(unsigned int beb_number, bool ten_gig, string src_mac, string src_ip,unsigned int src_port){
|
||||
//so that the values can be reset externally for now....
|
||||
|
||||
unsigned int i = GetBebInfoIndex(beb_number);
|
||||
if(!i) return 0; //i must be greater than 0, zero is the global send
|
||||
beb_infos[i]->SetHeaderInfo(ten_gig,src_mac,src_ip,src_port);
|
||||
|
||||
cout<<"Printing Beb info number ("<<i<<") :"<<endl;
|
||||
beb_infos[i]->Print();
|
||||
cout<<endl<<endl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Beb::ReadSetUpFromFile(string file_name){
|
||||
|
||||
static ifstream infile;
|
||||
static string line;
|
||||
static char cmd_st[2000],str_mac1[200],str_ip1[200],str_mac10[200],str_ip10[200];
|
||||
static int value_i[2];
|
||||
|
||||
infile.open(file_name.c_str(),ios::in);
|
||||
if(!infile.is_open()){
|
||||
cout<<"Error could not open setup file: "<<file_name<<"."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
cout<<endl;
|
||||
cout<<"Setting up detector:"<<endl;
|
||||
while(std::getline(infile,line)){
|
||||
if(line.length()<1) continue;
|
||||
istringstream iss(line);
|
||||
iss>>cmd_st;
|
||||
if(!strcmp("add_beb",cmd_st)){
|
||||
if(!(iss>>value_i[0]>>value_i[1]>>str_mac1>>str_ip1>>str_mac10>>str_ip10)){
|
||||
cout<<"Error adding beb from "<<file_name<<"."<<endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(GetBebInfoIndex(value_i[0])){
|
||||
cout<<"Error adding beb from "<<file_name<<", beb number "<<value_i[0]<<" already added."<<endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
BebInfo* b = new BebInfo(value_i[0]);
|
||||
b->SetSerialAddress(value_i[1]);
|
||||
b->SetHeaderInfo(0,str_mac1,str_ip1,42000+value_i[0]);
|
||||
b->SetHeaderInfo(1,str_mac10,str_ip10,52000+value_i[0]);
|
||||
beb_infos.push_back(b);
|
||||
}
|
||||
}
|
||||
|
||||
infile.close();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Beb::CheckSourceStuffBebInfo(){
|
||||
for(unsigned int i=1;i<beb_infos.size();i++){ //header stuff always starts from 1
|
||||
if(!SetHeaderData(beb_infos[i]->GetBebNumber(),0,"00:00:00:00:00:00","10.0.0.1",20000)||!SetHeaderData(beb_infos[i]->GetBebNumber(),1,"00:00:00:00:00:00","10.0.0.1",20000)){
|
||||
cout<<"Error in BebInfo for module number "<<beb_infos[i]->GetBebNumber()<<"."<<endl;
|
||||
beb_infos[i]->Print();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int Beb::GetBebInfoIndex(unsigned int beb_numb){
|
||||
if(!beb_numb) return 0;
|
||||
|
||||
for(unsigned int i=1;i<beb_infos.size();i++) if(beb_numb==beb_infos[i]->GetBebNumber()) return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Beb::WriteTo(unsigned int index){
|
||||
if(index>=beb_infos.size()){
|
||||
cout<<"WriteTo index error."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
send_data_raw[0] = 0x90000000 | beb_infos[index]->GetSerialAddress();
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
send_data_raw[0] = 0xc0000000;
|
||||
if((send_ndata+1)*4!=ll->Write((send_ndata+1)*4,send_data_raw)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void Beb::SwapDataFun(bool little_endian, unsigned int n, unsigned int *d){
|
||||
if(little_endian) for(unsigned int i=0;i<n;i++) d[i] = (((d[i]&0xff)<<24) | ((d[i]&0xff00)<<8) | ((d[i]&0xff0000)>>8) | ((d[i]&0xff000000)>>24)); //little_endian
|
||||
else for(unsigned int i=0;i<n;i++) d[i] = (((d[i]&0xffff)<<16) | ((d[i]&0xffff0000)>>16));
|
||||
}
|
||||
|
||||
|
||||
bool Beb::SetByteOrder(){
|
||||
send_data_raw[0] = 0x8fff0000;
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
while((ll->Read(recv_buffer_size*4,recv_data_raw)/4)>0) cout<<"\t) Cleanning buffer ..."<<endl;
|
||||
|
||||
if(beb_infos.size()<2) return 0;
|
||||
|
||||
send_ndata = 3;
|
||||
send_data[0] = 0x000c0000;
|
||||
send_data[1] = 0;
|
||||
send_data[2] = 0;
|
||||
WriteTo(0);
|
||||
|
||||
//using little endian for data, big endian not fully tested, swap on 16 bit boundary.
|
||||
send_ndata = 3;
|
||||
send_data[0] = 0x000c0000;
|
||||
send_data[1] = 1;
|
||||
send_data[2] = 0;
|
||||
SwapDataFun(0,2,&(send_data[1]));
|
||||
WriteTo(0);
|
||||
|
||||
cout<<"\tSetting Byte Order .............. ok"<<endl<<endl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Beb::SetUpUDPHeader(unsigned int beb_number, bool ten_gig, unsigned int header_number, string dst_mac, string dst_ip, unsigned int dst_port){
|
||||
unsigned int i = GetBebInfoIndex(beb_number);
|
||||
if(!i) return 0; //i must be greater than 0, zero is the global send
|
||||
|
||||
send_ndata = 14;
|
||||
send_data[0] = ten_gig ? 0x00020000 : 0x00010000; //write to fanout numbers 1 or 2
|
||||
send_data[1] = ((header_number*8)<<16);
|
||||
if(!SetHeaderData(beb_number,ten_gig,dst_mac,dst_ip,dst_port)) return 0;
|
||||
|
||||
SwapDataFun(1,12,&(send_data[2]));
|
||||
|
||||
if(!WriteTo(i)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Beb::SetHeaderData(unsigned int beb_number, bool ten_gig, string dst_mac, string dst_ip, unsigned int dst_port){
|
||||
unsigned int i = GetBebInfoIndex(beb_number);
|
||||
if(!i) return 0; //i must be greater than 0, zero is the global send
|
||||
return SetHeaderData(beb_infos[i]->GetSrcMAC(ten_gig),beb_infos[i]->GetSrcIP(ten_gig),beb_infos[i]->GetSrcPort(ten_gig),dst_mac,dst_ip,dst_port);
|
||||
}
|
||||
|
||||
bool Beb::SetHeaderData(string src_mac, string src_ip, unsigned int src_port, string dst_mac, string dst_ip, unsigned int dst_port){
|
||||
/* example header*/
|
||||
//static unsigned int* word_ptr = new unsigned int [16];
|
||||
static udp_header_type udp_header = {
|
||||
{0x00, 0x50, 0xc5, 0xb2, 0xcb, 0x46}, // DST MAC
|
||||
{0x00, 0x50, 0xc2, 0x46, 0xd9, 0x02}, // SRC MAC
|
||||
{0x08, 0x00},
|
||||
{0x45},
|
||||
{0x00},
|
||||
{0x00, 0x00},
|
||||
{0x00, 0x00},
|
||||
{0x40},
|
||||
{0x00},
|
||||
{0xff},
|
||||
{0x11},
|
||||
{0x00, 0x00},
|
||||
{129, 205, 205, 128}, // Src IP
|
||||
{129, 205, 205, 122}, // Dst IP
|
||||
{0x0f, 0xa1},
|
||||
{0x13, 0x89},
|
||||
{0x00, 0x00}, //{0x00, 0x11},
|
||||
{0x00, 0x00}
|
||||
};
|
||||
|
||||
if(!SetMAC(src_mac,&(udp_header.src_mac[0]))) return 0;
|
||||
if(!SetIP(src_ip,&(udp_header.src_ip[0]))) return 0;
|
||||
if(!SetPortNumber(src_port,&(udp_header.src_port[0]))) return 0;
|
||||
|
||||
if(!SetMAC(dst_mac,&(udp_header.dst_mac[0]))) return 0;
|
||||
if(!SetIP(dst_ip,&(udp_header.dst_ip[0]))) return 0;
|
||||
if(!SetPortNumber(dst_port,&(udp_header.dst_port[0]))) return 0;
|
||||
|
||||
|
||||
AdjustIPChecksum(&udp_header);
|
||||
|
||||
unsigned int* base_ptr = (unsigned int *) &udp_header;
|
||||
unsigned int num_words = ( sizeof(udp_header_type) + 3 ) / 4;
|
||||
// for(unsigned int i=0; i<num_words; i++) word_ptr[i] = base_ptr[i];
|
||||
// for(unsigned int i=num_words; i<16; i++) word_ptr[i] = 0;
|
||||
// return word_ptr;
|
||||
|
||||
for(unsigned int i=0; i<num_words; i++) send_data[i+2] = base_ptr[i];
|
||||
for(unsigned int i=num_words; i<16; i++) send_data[i+2] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Beb::SetMAC(string mac, unsigned char* dst_ptr){
|
||||
for(int i=0;i<6;i++){
|
||||
size_t p0=mac.find(':');
|
||||
if((i!=5&&p0!=2)||(i==5&&mac.length()!=2)){
|
||||
cout<<"Error: in mac address -> "<<mac<<endl;
|
||||
return 0;
|
||||
}
|
||||
dst_ptr[i] = (unsigned char) strtoul(mac.substr(0,p0).c_str(),NULL,16);
|
||||
mac=mac.substr(p0+1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool Beb::SetIP(string ip, unsigned char* dst_ptr){
|
||||
for(int i=0;i<4;i++){
|
||||
size_t p0=ip.find('.');
|
||||
if((i!=3&&(p0<1||p0>3))||(i==3&&(ip.length()<1||ip.length()>3))){
|
||||
cout<<"Error: in ip address -> "<<ip<<endl;
|
||||
return 0;
|
||||
}
|
||||
dst_ptr[i] = atoi(ip.substr(0,p0).c_str());
|
||||
ip=ip.substr(p0+1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool Beb::SetPortNumber(unsigned int port_number, unsigned char* dst_ptr){
|
||||
dst_ptr[0] = (port_number >> 8) & 0xff ;
|
||||
dst_ptr[1] = port_number & 0xff;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void Beb::AdjustIPChecksum(udp_header_type *ip){
|
||||
unsigned char *cptr = (unsigned char *) ip->ver_headerlen;
|
||||
|
||||
ip->ip_header_checksum[0] = 0;
|
||||
ip->ip_header_checksum[1] = 0;
|
||||
ip->total_length[0] = 0;
|
||||
ip->total_length[1] = 28; // IP + UDP Header Length
|
||||
|
||||
// calc ip checksum
|
||||
unsigned int ip_checksum = 0;
|
||||
for(unsigned int i=0; i<10; i++){
|
||||
ip_checksum += ( (cptr[2*i] << 8) + (cptr[2*i + 1]) );
|
||||
if (ip_checksum & 0x00010000) ip_checksum = (ip_checksum + 1) & 0x0000ffff;
|
||||
}
|
||||
|
||||
ip->ip_header_checksum[0] = (ip_checksum >> 8) & 0xff ;
|
||||
ip->ip_header_checksum[1] = ip_checksum & 0xff ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Beb::SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, bool ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, bool stop_read_when_fifo_empty){
|
||||
|
||||
unsigned int i = GetBebInfoIndex(beb_number); //zero is the global send
|
||||
|
||||
send_ndata = 3;
|
||||
if(left_right == 1) send_data[0] = 0x00040000;
|
||||
else if(left_right == 2) send_data[0] = 0x00080000;
|
||||
else if(left_right == 3) send_data[0] = 0x000c0000;
|
||||
else return 0;
|
||||
|
||||
//packet_size/=2;
|
||||
if(dst_number>0x3f) return 0;
|
||||
if(packet_size>0x3ff) return 0;
|
||||
if(npackets==0||npackets>0x100) return 0;
|
||||
npackets--;
|
||||
|
||||
|
||||
send_data[1] = 0x62000000 | (!stop_read_when_fifo_empty) << 27 | (ten_gig==1) << 24 | packet_size << 14 | dst_number << 8 | npackets;
|
||||
send_data[2] = 0;
|
||||
|
||||
SwapDataFun(0,2,&(send_data[1]));
|
||||
|
||||
if(!WriteTo(i)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Beb::SetUpTransferParameters(short the_bit_mode){
|
||||
if(the_bit_mode!=4&&the_bit_mode!=8&&the_bit_mode!=16&&the_bit_mode!=32) return 0;
|
||||
bit_mode = the_bit_mode;
|
||||
|
||||
//nimages = the_number_of_images;
|
||||
// on_dst = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool Beb::RequestNImages(unsigned int beb_number, unsigned int left_right, bool ten_gig, unsigned int dst_number, unsigned int nimages, bool test_just_send_out_packets_no_wait){
|
||||
if(dst_number>64) return 0;
|
||||
|
||||
unsigned int header_size = 4; //4*64 bits
|
||||
unsigned int packet_size = ten_gig ? 0x200 : 0x80; // 4k or 1k packets
|
||||
unsigned int npackets = ten_gig ? bit_mode*4 : bit_mode*16;
|
||||
bool in_two_requests = (!ten_gig&&bit_mode==32);
|
||||
if(in_two_requests) npackets/=2;
|
||||
|
||||
//cout<<"here: "<<beb_number<<","<<left_right<<","<<ten_gig<<","<<dst_number<<","<<1<<","<<header_size<<","<<test_just_send_out_packets_no_wait<<endl;
|
||||
|
||||
for(unsigned int i=0;i<nimages;i++){
|
||||
//header then data request
|
||||
if(!SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,1,header_size,test_just_send_out_packets_no_wait) ||
|
||||
!SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,npackets,packet_size,test_just_send_out_packets_no_wait) ||
|
||||
(in_two_requests&&!SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,npackets,packet_size,test_just_send_out_packets_no_wait))) return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Beb::Test(unsigned int beb_number){
|
||||
cout<<"Testing module number: "<<beb_number<<endl;
|
||||
|
||||
|
||||
//bool Beb::SetUpUDPHeader(unsigned int beb_number, bool ten_gig, unsigned int header_number, string dst_mac, string dst_ip, unsigned int dst_port){
|
||||
//SetUpUDPHeader(26,0,0,"60:fb:42:f4:e3:d2","129.129.205.186",22000);
|
||||
|
||||
unsigned int index = GetBebInfoIndex(beb_number);
|
||||
if(!index){
|
||||
cout<<"Error beb number ("<<beb_number<<")not in list????"<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
for(unsigned int i=0;i<64;i++){
|
||||
if(!SetUpUDPHeader(beb_number,0,i,"60:fb:42:f4:e3:d2","129.129.205.186",22000+i)){
|
||||
cout<<"Error setting up header table...."<<endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, bool ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, bool stop_read_when_fifo_empty=1);
|
||||
for(unsigned int i=0;i<64;i++){
|
||||
if(!SendMultiReadRequest(beb_number,i%3+1,0,i,1,0)){
|
||||
cout<<"Error requesting data...."<<endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,388 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <algorithm> // std::remove_if
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Beb.h"
|
||||
#include "slsDetectorServer_defs.h" //include port number
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum cmd_string {evNotFound,
|
||||
evRequestImages,evTestRequest,
|
||||
evSetBitMode,
|
||||
evSetupTableEntry,evSetDstParameters,
|
||||
evTest,evTestSend,
|
||||
evExitServer};
|
||||
|
||||
map<string, cmd_string> enum_map;
|
||||
|
||||
void init(){
|
||||
|
||||
enum_map["requestimages"] = evRequestImages; //<dst>
|
||||
enum_map["testrequest"] = evTestRequest; //<dst>
|
||||
|
||||
enum_map["setbitmode"] = evSetBitMode; // (resets on_dst and dst_requested)
|
||||
|
||||
enum_map["setuptableentry"] = evSetupTableEntry;
|
||||
enum_map["setdstparameters"] = evSetDstParameters; //<one_ten> <ndsts> <nimages_per_request> (resets on_dst and dst_requested)
|
||||
|
||||
enum_map["test"] = evTest;
|
||||
enum_map["testsend"] = evTestSend;
|
||||
enum_map["exitserver"] = evExitServer;
|
||||
|
||||
}
|
||||
|
||||
int server_list_s;
|
||||
int server_conn_s;
|
||||
int AccpetConnectionAndWaitForData(char* buffer, int maxlength);
|
||||
bool WriteNClose(const char* buffer, int length);
|
||||
bool SetupListenSocket(unsigned short int port);
|
||||
|
||||
|
||||
string LowerCase(string str);
|
||||
string GetNextString(string str,bool start_from_beginning=0);
|
||||
void AddNumber(string& str, int n, int location=-1);//-1 means append
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
cout<<endl<<endl;
|
||||
|
||||
/*
|
||||
if(argc<2){
|
||||
cout<<"Usage: eiger_beb_server port_number"<<endl<<endl;
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
init();
|
||||
|
||||
int arg1;
|
||||
Beb *bebs;
|
||||
|
||||
if(argc>1)
|
||||
bebs = new Beb(atoi(argv[1]));
|
||||
else
|
||||
bebs = new Beb(-1);
|
||||
|
||||
// unsigned short int port_number = atoi(argv[1]);
|
||||
|
||||
unsigned short int port_number = BEB_PORT;
|
||||
if(!SetupListenSocket(port_number)) return 1;
|
||||
|
||||
|
||||
int length=1000;
|
||||
char data[1000];
|
||||
|
||||
int stop = 0;
|
||||
time_t rawtime;
|
||||
struct tm *timeinfo;
|
||||
|
||||
bool send_to_ten_gig = 0;
|
||||
int ndsts_in_use=32;
|
||||
unsigned int nimages_per_request=1;
|
||||
|
||||
int on_dst=0;
|
||||
bool dst_requested[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
|
||||
while(!stop){
|
||||
|
||||
cout<<endl<<"\n\n\n\nWaiting for command -> "<<flush;
|
||||
int nread = AccpetConnectionAndWaitForData(data,length);
|
||||
if(nread<=0) return 0;
|
||||
|
||||
time(&rawtime); timeinfo=localtime(&rawtime);
|
||||
cout<<asctime(timeinfo);
|
||||
cout<<" Command received: "<<data<<endl<<endl;
|
||||
|
||||
|
||||
|
||||
string tmp_str[5];
|
||||
//float v1,v2,v3,v4,v5;
|
||||
int n[5];
|
||||
|
||||
string cmd = GetNextString(data,1);
|
||||
//static char retval_st[100];
|
||||
int ret_val = 1;
|
||||
string return_message = " Command recieved: ";
|
||||
return_message.append(data);
|
||||
return_message.append("\n");
|
||||
|
||||
int return_start_pos;
|
||||
while(cmd.length()>0){
|
||||
return_start_pos = return_message.length();
|
||||
|
||||
switch(enum_map.find(LowerCase(cmd))->second){
|
||||
|
||||
case evRequestImages :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data()); //dst number
|
||||
if(tmp_str[0].length()<1||n[0]<0||n[0]>=ndsts_in_use){
|
||||
return_message.append("\tError executing: RequestImages <dst_number> (note dst_number must be less than ndsts_in_use that is set with SetDstParameters\n");
|
||||
ret_val = 1;
|
||||
}else{
|
||||
dst_requested[n[0]] = 1;
|
||||
ret_val=0;
|
||||
tmp_str[1] = " ( ";
|
||||
while(dst_requested[on_dst]){
|
||||
//waits on data
|
||||
if((ret_val = (!bebs->RequestNImages(0,1,send_to_ten_gig,on_dst,nimages_per_request)||!bebs->RequestNImages(0,2,send_to_ten_gig,0x20|on_dst,nimages_per_request)))) break;
|
||||
AddNumber(tmp_str[1],on_dst);tmp_str[1].append(" ");
|
||||
dst_requested[on_dst++]=0;
|
||||
on_dst%=ndsts_in_use;
|
||||
}
|
||||
if(ret_val) return_message.append("\tError executing: RequestImages <dst_number>");
|
||||
else{ return_message.append("\tExecuted: RequestImages "); AddNumber(return_message,n[0]);}
|
||||
return_message.append(tmp_str[1]);
|
||||
return_message.append(" )\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case evTestRequest :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data()); //dst number
|
||||
if(tmp_str[0].length()<1||n[0]<0||n[0]>=ndsts_in_use){
|
||||
return_message.append("\tError executing: TestRequest <dst_number> (note dst_number must be less than 2xndsts_in_use that is set with SetDstParameters\n");
|
||||
ret_val = 1;
|
||||
}else{
|
||||
ret_val = (!bebs->RequestNImages(0,1,send_to_ten_gig,n[0],nimages_per_request,1)||!bebs->RequestNImages(0,2,send_to_ten_gig,0x20|n[0],nimages_per_request,1));
|
||||
if(ret_val) return_message.append("\tError executing: TestRequest <dst_number>\n");
|
||||
else{ return_message.append("\tExecuted: TestRequest "); AddNumber(return_message,n[0]); return_message.append("\n");}
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetBitMode :
|
||||
on_dst = 0;
|
||||
for(n[0]=0;n[0]<32;n[0]++) dst_requested[n[0]] = 0; //clear dst requested
|
||||
n[0] = atoi(GetNextString(data).data());
|
||||
if((ret_val = !bebs->SetUpTransferParameters(n[0]))) return_message.append("\tError executing: SetBitMode <bit_mode 4,8,16,32>\n");
|
||||
else{ return_message.append("\tExecuted: SetBitMode ");AddNumber(return_message,n[0]);return_message.append("\n");}
|
||||
break;
|
||||
|
||||
case evSetDstParameters : //move below //<one_ten_gigabit> <ndsts> <nimages_per_request>
|
||||
on_dst = 0;
|
||||
for(n[0]=0;n[0]<32;n[0]++) dst_requested[n[0]] = 0; //clear dst requested
|
||||
n[0] = atoi(GetNextString(data).data()); //<1GbE(0) or 10GbE(1)>
|
||||
n[1] = atoi(GetNextString(data).data()); //<ndsts (1 to 32)>
|
||||
n[2] = atoi(GetNextString(data).data()); // <nimages_per_request (>0)>
|
||||
|
||||
if((n[0]!=0&&n[0]!=1)||(n[1]<1||n[1]>32)||n[2]<1){
|
||||
return_message.append("\tError executing: SetDstParameters <1GbE(0) or 10GbE(1)> <ndsts> <nimages_per_request>\n");
|
||||
ret_val=1;
|
||||
}
|
||||
else{
|
||||
send_to_ten_gig = n[0];
|
||||
ndsts_in_use=n[1];
|
||||
nimages_per_request=n[2];
|
||||
return_message.append("\tExecuted: SetDstParameters ");
|
||||
AddNumber(return_message,n[0]);return_message.append(" ");
|
||||
AddNumber(return_message,n[1]);return_message.append(" ");
|
||||
AddNumber(return_message,n[2]);return_message.append(" ");
|
||||
ret_val=0;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetupTableEntry :
|
||||
n[0] = atoi(GetNextString(data).data()); //beb_number;
|
||||
n[1] = atoi(GetNextString(data).data()); //<1GbE(0) or 10GbE(1)>
|
||||
n[2] = atoi(GetNextString(data).data()); //header_number
|
||||
tmp_str[0] = GetNextString(data); //src_mac
|
||||
tmp_str[1] = GetNextString(data); //src_ip
|
||||
n[3] = atoi(GetNextString(data).data()); //src_port
|
||||
tmp_str[2] = GetNextString(data); //dst_mac
|
||||
tmp_str[3] = GetNextString(data); //dst_ip
|
||||
n[4] = atoi((tmp_str[4]=GetNextString(data)).data()); //dst_port
|
||||
|
||||
if(n[0]<1||(n[1]!=0&&n[1]!=1)||(n[2]<0||n[2]>63)||tmp_str[0].length()<1||tmp_str[1].length()<1||n[3]<0||tmp_str[2].length()<1||tmp_str[3].length()<1||n[4]<0||tmp_str[4].length()<1){
|
||||
return_message.append("\tError executing: SetupTableEntry <beb_number> <1GbE(0) or 10GbE(1)> <dst_number> <src_mac> <src_ip> <src_port> <dst_mac> <dst_ip> <dst_port>\n");
|
||||
ret_val = 1;
|
||||
}else{
|
||||
for(int i=0;i<32;i++)/** modified for Aldo*/
|
||||
ret_val = !bebs->SetBebSrcHeaderInfos(n[0],n[1],tmp_str[0],tmp_str[1],n[3])||!bebs->SetUpUDPHeader(n[0],n[1],n[2]+i,tmp_str[2],tmp_str[3],n[4]);
|
||||
|
||||
if(ret_val) return_message.append("\tError Executing: SetupTableEntry ");
|
||||
else return_message.append("\tExecuted: SetupTableEntry ");
|
||||
AddNumber(return_message,n[0]);return_message.append(" ");
|
||||
AddNumber(return_message,n[1]);return_message.append(" ");
|
||||
AddNumber(return_message,n[2]);return_message.append(" ");
|
||||
return_message.append(tmp_str[0]);return_message.append(" ");
|
||||
return_message.append(tmp_str[1]);return_message.append(" ");
|
||||
AddNumber(return_message,n[3]);return_message.append(" ");
|
||||
return_message.append(tmp_str[2]);return_message.append(" ");
|
||||
return_message.append(tmp_str[3]);return_message.append(" ");
|
||||
AddNumber(return_message,n[4]);
|
||||
}
|
||||
break;
|
||||
|
||||
case evTest :
|
||||
n[0] = atoi(GetNextString(data).data());
|
||||
if(n[0]<1){
|
||||
return_message.append("\tError executing: Test <beb_number>\n");
|
||||
ret_val = 1;
|
||||
}else{
|
||||
ret_val = !bebs->Test(n[0]);
|
||||
if(ret_val) return_message.append("\tError Executing: Test ");
|
||||
else return_message.append("\tExecuted: Test ");
|
||||
AddNumber(return_message,n[0]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case evTestSend :
|
||||
n[0] = atoi(GetNextString(data).data()); //beb_number;
|
||||
n[1] = atoi(GetNextString(data).data()); //giga bit, ten giga bit
|
||||
n[2] = atoi((tmp_str[0]=GetNextString(data)).data()); //header_number
|
||||
|
||||
if(n[0]<1||(n[1]!=0&&n[1]!=1)||(n[2]<0||n[2]>63)||tmp_str[0].length()<1){
|
||||
return_message.append("\tError executing: TestSend <beb_number> <1GbE(0) or 10GbE(1)> <dst_number>\n");
|
||||
ret_val = 1;
|
||||
}else{
|
||||
ret_val = !bebs->SendMultiReadRequest(n[0],1,n[1],n[2],1,0);
|
||||
|
||||
if(ret_val) return_message.append("\tError Executing: TestSend ");
|
||||
else return_message.append("\tExecuted: TestSend ");
|
||||
AddNumber(return_message,n[0]);return_message.append(" ");
|
||||
AddNumber(return_message,n[1]);return_message.append(" ");
|
||||
AddNumber(return_message,n[2]);return_message.append(" ");
|
||||
}
|
||||
break;
|
||||
|
||||
case evExitServer :
|
||||
return_message.append("\tExiting Server ....\n");
|
||||
stop = 1;
|
||||
ret_val = -200;
|
||||
break;
|
||||
|
||||
default :
|
||||
return_message.append("\tWarning command \"");
|
||||
return_message.append(cmd);
|
||||
return_message.append("\" not found.\n");
|
||||
return_message.append("\t\tValid commands: ");
|
||||
map<string, cmd_string>::iterator it = enum_map.begin();
|
||||
while(it!=enum_map.end()){
|
||||
return_message.append((it++)->first);
|
||||
return_message.append(" ");
|
||||
}
|
||||
|
||||
ret_val=-100;
|
||||
break;
|
||||
}
|
||||
|
||||
return_message.append("\n");
|
||||
AddNumber(return_message,ret_val,return_start_pos);
|
||||
if(ret_val!=0) break;
|
||||
|
||||
cmd = GetNextString(data);
|
||||
}
|
||||
return_message.append("\n\n\n");
|
||||
|
||||
AddNumber(return_message,ret_val,0);
|
||||
cout<<return_message.c_str()<<endl;
|
||||
cout<<"\treturn: "<<ret_val<<endl;
|
||||
|
||||
if(!WriteNClose(return_message.c_str(),return_message.length())) return 0;
|
||||
}
|
||||
|
||||
|
||||
delete bebs;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
string LowerCase(string str){
|
||||
string s = str;
|
||||
string::iterator i = s.begin();
|
||||
while(i!=s.end()) *i=tolower(*(i++));
|
||||
return s;
|
||||
}
|
||||
|
||||
string GetNextString(string str,bool start_from_beginning){
|
||||
static string::size_type start_pos = 0;
|
||||
if(start_from_beginning) start_pos = 0;
|
||||
|
||||
while(start_pos != string::npos){
|
||||
string::size_type found = str.find_first_of(" ",start_pos);
|
||||
string sub = str.substr(start_pos,found-start_pos);
|
||||
|
||||
start_pos = found;
|
||||
if(start_pos != string::npos) start_pos+=1;
|
||||
|
||||
sub.erase(remove_if(sub.begin(),sub.end(), ::isspace ),sub.end());
|
||||
|
||||
if(sub.length()>0) return sub;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AddNumber(string& str, int n, int location){
|
||||
static char retval_st[100];
|
||||
sprintf(retval_st,"%d",n);
|
||||
|
||||
if(location<0) str.append(retval_st);
|
||||
else str.insert(location,retval_st);
|
||||
}
|
||||
|
||||
|
||||
bool SetupListenSocket(unsigned short int port){
|
||||
server_list_s=0;
|
||||
server_conn_s=0;
|
||||
|
||||
if((server_list_s = socket(AF_INET, SOCK_STREAM, 0))<0) return 0;
|
||||
|
||||
struct sockaddr_in servaddr; /* socket address structure */
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
servaddr.sin_port = htons(port);
|
||||
|
||||
if(bind(server_list_s,(struct sockaddr *) &servaddr,sizeof(servaddr))<0) return 0;
|
||||
|
||||
if(listen(server_list_s,32) < 0){ // 1024 /* Backlog for listen() */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int AccpetConnectionAndWaitForData(char* buffer, int maxlength){
|
||||
if(server_list_s==0||maxlength<=0) return 0;
|
||||
|
||||
if((server_conn_s = accept(server_list_s,NULL,NULL))< 0) return 0;
|
||||
|
||||
int nread = read(server_conn_s,buffer,maxlength-1);
|
||||
|
||||
if(nread<0) return 0;
|
||||
|
||||
buffer[nread]='\0';
|
||||
return nread;
|
||||
}
|
||||
|
||||
bool WriteNClose(const char* buffer, int length){
|
||||
if(server_conn_s==0||length<=0) return 0;
|
||||
|
||||
int nsent = write(server_conn_s,buffer,length);
|
||||
if(close(server_conn_s)<0) return 0;
|
||||
|
||||
server_conn_s=0;
|
||||
return (nsent==length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
Internal setup:
|
||||
setdac
|
||||
trimbits
|
||||
rate correction tau
|
||||
high voltage
|
||||
|
||||
|
||||
Setup:
|
||||
photon energy
|
||||
dynamic range (4,8,16,32)
|
||||
number of images
|
||||
exposure time
|
||||
exposure period
|
||||
readout speed(full speed, 1/2 speed, 1/4 or super slow)
|
||||
readout mode (parallel, non-parallel or super safe)
|
||||
trigger mode (internal,external start of series, external start of acquisitions, external window)
|
||||
trigger polarity (pos/neg)
|
||||
external gating (on, pos/neg)
|
||||
|
||||
|
||||
Acquisition:
|
||||
start acquisition
|
||||
stop acquisition
|
||||
acquisition in progress
|
||||
wait until daq is finished
|
||||
status (needs to be implemented)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,179 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#ifndef EIGER_H
|
||||
#define EIGER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Feb.h"
|
||||
|
||||
|
||||
class Module{
|
||||
|
||||
private:
|
||||
unsigned int module_number;
|
||||
bool top_address_valid;
|
||||
unsigned int top_left_address;
|
||||
unsigned int top_right_address;
|
||||
bool bottom_address_valid;
|
||||
unsigned int bottom_left_address;
|
||||
unsigned int bottom_right_address;
|
||||
|
||||
unsigned int idelay_top[4]; //ll,lr,rl,ll
|
||||
unsigned int idelay_bottom[4]; //ll,lr,rl,ll
|
||||
float high_voltage;
|
||||
float* top_dac;
|
||||
float* bottom_dac;
|
||||
|
||||
public:
|
||||
Module(unsigned int number, unsigned int address_top); //for half module()
|
||||
Module(unsigned int number, unsigned int address_top, unsigned int address_bottom);
|
||||
~Module();
|
||||
|
||||
static const unsigned int ndacs;
|
||||
static const std::string dac_names[16];
|
||||
|
||||
unsigned int GetModuleNumber() {return module_number;}
|
||||
bool TopAddressIsValid() {return top_address_valid;}
|
||||
unsigned int GetTopBaseAddress() {return (top_left_address&0xff);}
|
||||
unsigned int GetTopLeftAddress() {return top_left_address;}
|
||||
unsigned int GetTopRightAddress() {return top_right_address;}
|
||||
unsigned int GetBottomBaseAddress() {return (bottom_left_address&0xff);}
|
||||
bool BottomAddressIsValid() {return bottom_address_valid;}
|
||||
unsigned int GetBottomLeftAddress() {return bottom_left_address;}
|
||||
unsigned int GetBottomRightAddress() {return bottom_right_address;}
|
||||
|
||||
unsigned int SetTopIDelay(unsigned int chip,unsigned int value) { return TopAddressIsValid() &&chip<4 ? (idelay_top[chip]=value) : 0;} //chip 0=ll,1=lr,0=rl,1=rr
|
||||
unsigned int GetTopIDelay(unsigned int chip) { return chip<4 ? idelay_top[chip] : 0;} //chip 0=ll,1=lr,0=rl,1=rr
|
||||
unsigned int SetBottomIDelay(unsigned int chip,unsigned int value) { return BottomAddressIsValid() &&chip<4 ? (idelay_bottom[chip]=value) : 0;} //chip 0=ll,1=lr,0=rl,1=rr
|
||||
unsigned int GetBottomIDelay(unsigned int chip) { return chip<4 ? idelay_bottom[chip] : 0;} //chip 0=ll,1=lr,0=rl,1=rr
|
||||
|
||||
float SetHighVoltage(float value) { return TopAddressIsValid() ? (high_voltage=value) : -1;}
|
||||
float GetHighVoltage() { return high_voltage;}
|
||||
|
||||
float SetTopDACVoltage(unsigned int i, float value) { return (i<ndacs && TopAddressIsValid()) ? (top_dac[i]=value) : -1;}
|
||||
float GetTopDACVoltage(unsigned int i) { return (i<ndacs) ? top_dac[i]:-1;}
|
||||
float SetBottomDACVoltage(unsigned int i, float value) { return (i<ndacs && BottomAddressIsValid()) ? (bottom_dac[i]=value) : -1;}
|
||||
float GetBottomDACVoltage(unsigned int i) { return (i<ndacs) ? bottom_dac[i]:-1;}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Eiger:private Feb{
|
||||
|
||||
private:
|
||||
|
||||
std::vector<Module*> modules;
|
||||
void ClearModules();
|
||||
|
||||
unsigned int staticBits; //program=1,m4=2,m8=4,test=8,rotest=16,cs_bar_left=32,cs_bar_right=64
|
||||
unsigned int acquireNReadoutMode; //safe or parallel, half or full speed
|
||||
unsigned int triggerMode; //internal timer, external start, external window, signal polarity (external trigger and enable)
|
||||
unsigned int externalEnableMode; //external enabling engaged and it's polarity
|
||||
unsigned int subFrameMode;
|
||||
|
||||
unsigned int photon_energy_eV;
|
||||
|
||||
unsigned int nimages;
|
||||
float exposure_time_in_sec;
|
||||
float exposure_period_in_sec;
|
||||
|
||||
unsigned int trimbit_size;
|
||||
unsigned char* last_downloaded_trimbits;
|
||||
|
||||
void PrintModuleList();
|
||||
bool GetModuleIndex(unsigned int module_number, unsigned int& module_index);
|
||||
bool CheckModuleAddresses(unsigned int top_address, unsigned int bottom_address);
|
||||
bool AddModule(unsigned int module_number, unsigned int top_address);
|
||||
bool AddModule(unsigned int module_number, unsigned int top_address, unsigned int bottom_address, bool half_module=0);
|
||||
|
||||
bool GetDACNumber(std::string s, unsigned int& n);
|
||||
bool SendDACValue(unsigned int dst_num, unsigned int ch, float& value);
|
||||
bool VoltageToDAC(float value, unsigned int& digital, unsigned int nsteps, float vmin, float vmax);
|
||||
float DACToVoltage(unsigned int digital,unsigned int nsteps,float vmin,float vmax);
|
||||
|
||||
bool SendHighVoltage(unsigned int module_index, float& value);
|
||||
|
||||
bool SendIDelays(unsigned int dst_num, bool chip_lr, unsigned int channels, unsigned int ndelay_units);
|
||||
|
||||
bool SetStaticBits();
|
||||
bool SetStaticBits(unsigned int the_static_bits);
|
||||
|
||||
unsigned int ConvertTimeToRegister(float time_in_sec);
|
||||
|
||||
bool SetCommandRegister(unsigned int cmd);
|
||||
bool GetDAQStatusRegister(int socket_num, unsigned int &ret_status);
|
||||
bool StartDAQOnlyNWaitForFinish(int sleep_time_us=5000);
|
||||
bool ResetDataStream();
|
||||
|
||||
bool ResetChipCompletely();
|
||||
|
||||
public:
|
||||
Eiger();
|
||||
virtual ~Eiger();
|
||||
|
||||
bool Init();
|
||||
bool ReadSetUpFileToAddModules(std::string file_name);
|
||||
bool ReadSetUpFile(unsigned int module_num, std::string file_name);
|
||||
bool CheckSetup();
|
||||
|
||||
unsigned int GetNModules();
|
||||
unsigned int GetNHalfModules();
|
||||
|
||||
//bool SetHighVoltage(float value);
|
||||
bool SetHighVoltage(unsigned int module_num,float value);
|
||||
|
||||
bool SetPhotonEnergy(unsigned int full_energy_eV);
|
||||
unsigned int GetPhotonEnergy(){return photon_energy_eV;}
|
||||
|
||||
bool SetIDelays(unsigned int module_num, unsigned int ndelay_units);
|
||||
bool SetIDelays(unsigned int module_num, unsigned int chip_pos, unsigned int ndelay_units);
|
||||
|
||||
bool SetDAC(std::string s, float value);
|
||||
bool GetDAC(std::string s, float& ret_value);
|
||||
bool GetDACName(unsigned int dac_num, std::string &s);
|
||||
|
||||
bool SetTrimbits(unsigned char* trimbits);
|
||||
unsigned char* GetTrimbits();
|
||||
|
||||
|
||||
|
||||
bool Reset();
|
||||
bool StartAcquisition();
|
||||
bool StopAcquisition();
|
||||
bool AcquisitionInProgress();
|
||||
bool WaitForFinishedFlag(int sleep_time_us=5000);
|
||||
|
||||
//functions for setting up exposure
|
||||
void PrintAcquisitionSetup();
|
||||
bool SetNImages(unsigned int n_images);
|
||||
unsigned int GetNImages();
|
||||
bool SetExposureTime(float the_exposure_time_in_sec);
|
||||
float GetExposureTime();
|
||||
bool SetExposurePeriod(float the_exposure_period_in_sec);
|
||||
float GetExposurePeriod();
|
||||
bool SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo);
|
||||
unsigned int GetDynamicRange();
|
||||
bool SetReadoutSpeed(unsigned int readout_speed=0); //0->full,1->half,2->quarter or 3->super_slow
|
||||
bool SetReadoutMode(unsigned int readout_mode=0); //0->parallel,1->non-parallel,2-> safe_mode
|
||||
bool SetTriggerMode(unsigned int trigger_mode=0, bool polarity=1);
|
||||
bool SetExternalEnableMode(bool use_external_enable=0, bool polarity=1);
|
||||
|
||||
|
||||
//functions for testing
|
||||
bool SetTestModeVariable(bool on=1);
|
||||
bool GetTestModeVariable();
|
||||
|
||||
bool FebTest(){return Feb::Test();}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,200 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
||||
#include "slsDetectorServer_defs.h" //include port number
|
||||
|
||||
struct sockaddr_in eiger_back_socket_addr;
|
||||
int eiger_back_max_message_length = 1024;
|
||||
char eiger_back_message[1024];
|
||||
int eiger_back_message_length = 0;
|
||||
int eiger_back_ret_val=0;
|
||||
|
||||
|
||||
int bit_mode=0;
|
||||
int ten_giga=0;
|
||||
|
||||
int EigerBackInit(){
|
||||
static int passed = 0;
|
||||
|
||||
if(!passed){
|
||||
struct hostent *dst_host;
|
||||
if((dst_host = gethostbyname("localhost")) == NULL){ //or look into getaddrinfo(3)
|
||||
fprintf(stderr,"ERROR, no such host\n");
|
||||
return 0;
|
||||
}else{
|
||||
//struct sockaddr_in eiger_back_socket_addr;
|
||||
int port = BEB_PORT;
|
||||
bzero((char *) &eiger_back_socket_addr, sizeof(eiger_back_socket_addr));
|
||||
eiger_back_socket_addr.sin_family = AF_INET;
|
||||
bcopy((char *)dst_host->h_addr,(char *)&eiger_back_socket_addr.sin_addr.s_addr,dst_host->h_length);
|
||||
eiger_back_socket_addr.sin_port = htons(port);
|
||||
passed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
|
||||
int EigerBackSendCMD(){
|
||||
if(!EigerBackInit()||eiger_back_message_length<=0) return 0;
|
||||
|
||||
int sockfd = socket(AF_INET,SOCK_STREAM,0);
|
||||
if(sockfd<0){
|
||||
fprintf(stderr,"ERROR opening socket\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(connect(sockfd,(struct sockaddr *) &eiger_back_socket_addr,sizeof(eiger_back_socket_addr))<0){
|
||||
fprintf(stderr,"ERROR connecting\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n = write(sockfd,eiger_back_message,eiger_back_message_length);
|
||||
int ret_length = read(sockfd,eiger_back_message,eiger_back_max_message_length);
|
||||
|
||||
close(sockfd);
|
||||
|
||||
if(n<0||ret_length<0) return 0;
|
||||
|
||||
|
||||
//fprintf(stdout,"%s\n",eiger_back_message);
|
||||
if(eiger_back_ret_val>0){
|
||||
int i=0;
|
||||
eiger_back_message[1]='\0';
|
||||
if(atoi(eiger_back_message)!=0) return 0;
|
||||
|
||||
for(i=2;i<ret_length;i++){
|
||||
if(eiger_back_message[i] == ' '){
|
||||
//fprintf(stdout," in : %d \n",i);
|
||||
eiger_back_message[i]='\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
eiger_back_ret_val = atoi(&eiger_back_message[2]);
|
||||
//fprintf(stdout," the \"%s\" %d\n",&eiger_back_message[2],eiger_back_ret_val);
|
||||
}
|
||||
|
||||
eiger_back_message_length = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EigerSetBitMode(int i){
|
||||
eiger_back_ret_val=0;
|
||||
eiger_back_message_length = sprintf(eiger_back_message,"setbitmode %d",i);
|
||||
bit_mode = i;
|
||||
return EigerBackSendCMD();
|
||||
}
|
||||
|
||||
int EigerGetBitMode(){
|
||||
return bit_mode;
|
||||
}
|
||||
|
||||
//SetupTableEntry <beb_number> <1GbE(0) or 10GbE(1)> <dst_number> <src_mac> <src_ip> <src_port> <dst_mac> <dst_ip> <dst_port>
|
||||
int EigerSetupTableEntryLeft(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport){
|
||||
char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50];
|
||||
|
||||
int src_port = 0xE185;
|
||||
int dst_port = udpport;
|
||||
sprintf(src_ip,"%d.%d.%d.%d",(detipad>>24)&0xff,(detipad>>16)&0xff,(detipad>>8)&0xff,(detipad)&0xff);
|
||||
sprintf(dst_ip,"%d.%d.%d.%d",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff);
|
||||
sprintf(src_mac,"%02x:%02x:%02x:%02x:%02x:%02x",(unsigned int)((detectormacadd>>40)&0xFF),
|
||||
(unsigned int)((detectormacadd>>32)&0xFF),
|
||||
(unsigned int)((detectormacadd>>24)&0xFF),
|
||||
(unsigned int)((detectormacadd>>16)&0xFF),
|
||||
(unsigned int)((detectormacadd>>8)&0xFF),
|
||||
(unsigned int)((detectormacadd>>0)&0xFF));
|
||||
sprintf(dst_mac,"%02x:%02x:%02x:%02x:%02x:%02x",(unsigned int)((macad>>40)&0xFF),
|
||||
(unsigned int)((macad>>32)&0xFF),
|
||||
(unsigned int)((macad>>24)&0xFF),
|
||||
(unsigned int)((macad>>16)&0xFF),
|
||||
(unsigned int)((macad>>8)&0xFF),
|
||||
(unsigned int)((macad>>0)&0xFF));
|
||||
|
||||
printf("Seting up Table Entry Left:\n");
|
||||
printf("src_port:%d\n",src_port);
|
||||
printf("dst_port:%d\n",dst_port);
|
||||
printf("src_ip:%s\n",src_ip);
|
||||
printf("dst_ip:%s\n",dst_ip);
|
||||
printf("src_mac:%s\n",src_mac);
|
||||
printf("dst_mac:%s\n\n",dst_mac);
|
||||
|
||||
|
||||
|
||||
eiger_back_ret_val=0;
|
||||
eiger_back_message_length = sprintf(eiger_back_message,"setuptableentry %d %d %d %s %s %d %s %s %d",34,ten_giga,0,src_mac,src_ip,src_port,dst_mac,dst_ip,dst_port);
|
||||
return EigerBackSendCMD();
|
||||
}
|
||||
|
||||
|
||||
int EigerSetupTableEntryRight(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport){
|
||||
char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50];
|
||||
|
||||
int src_port = 0xE185;
|
||||
int dst_port = udpport+1;
|
||||
sprintf(src_ip,"%d.%d.%d.%d",(detipad>>24)&0xff,(detipad>>16)&0xff,(detipad>>8)&0xff,(detipad)&0xff);
|
||||
sprintf(dst_ip,"%d.%d.%d.%d",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff);
|
||||
sprintf(src_mac,"%02x:%02x:%02x:%02x:%02x:%02x",(unsigned int)((detectormacadd>>40)&0xFF),
|
||||
(unsigned int)((detectormacadd>>32)&0xFF),
|
||||
(unsigned int)((detectormacadd>>24)&0xFF),
|
||||
(unsigned int)((detectormacadd>>16)&0xFF),
|
||||
(unsigned int)((detectormacadd>>8)&0xFF),
|
||||
(unsigned int)((detectormacadd>>0)&0xFF));
|
||||
sprintf(dst_mac,"%02x:%02x:%02x:%02x:%02x:%02x",(unsigned int)((macad>>40)&0xFF),
|
||||
(unsigned int)((macad>>32)&0xFF),
|
||||
(unsigned int)((macad>>24)&0xFF),
|
||||
(unsigned int)((macad>>16)&0xFF),
|
||||
(unsigned int)((macad>>8)&0xFF),
|
||||
(unsigned int)((macad>>0)&0xFF));
|
||||
|
||||
printf("Seting up Table Entry Right:\n");
|
||||
printf("src_port:%d\n",src_port);
|
||||
printf("dst_port:%d\n",dst_port);
|
||||
printf("src_ip:%s\n",src_ip);
|
||||
printf("dst_ip:%s\n",dst_ip);
|
||||
printf("src_mac:%s\n",src_mac);
|
||||
printf("dst_mac:%s\n\n",dst_mac);
|
||||
|
||||
eiger_back_ret_val=0;
|
||||
eiger_back_message_length = sprintf(eiger_back_message,"setuptableentry %d %d %d %s %s %d %s %s %d",34,ten_giga,32,src_mac,src_ip,src_port,dst_mac,dst_ip,dst_port);
|
||||
return EigerBackSendCMD();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int RequestImages(){
|
||||
printf("Going to request images\n");
|
||||
eiger_back_ret_val=0;
|
||||
eiger_back_message_length = sprintf(eiger_back_message,"requestimages %d",0); // dst_number
|
||||
return EigerBackSendCMD();
|
||||
}
|
||||
|
||||
int SetDestinationParameters(int i){
|
||||
eiger_back_ret_val=0;
|
||||
eiger_back_message_length = sprintf(eiger_back_message,"setdstparameters %d %d %d",ten_giga,1,i);// number of dsts
|
||||
return EigerBackSendCMD();
|
||||
}
|
||||
|
||||
|
||||
void SetTenGigbaBitEthernet(int val){
|
||||
ten_giga = val;
|
||||
}
|
||||
|
||||
|
||||
int GetTenGigbaBitEthernet(){
|
||||
return ten_giga;
|
||||
}
|
||||
@@ -1,363 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "slsDetectorServer_defs.h" //include port number
|
||||
|
||||
|
||||
|
||||
int eiger_nexposures = 1;
|
||||
float eiger_exposuretime = 0;
|
||||
float eiger_exposureperiod = 0;
|
||||
int eiger_ncycles = 1;
|
||||
int eiger_ngates = 0;
|
||||
int eiger_getphotonenergy = 0;
|
||||
int eiger_dynamicrange = 0;
|
||||
int eiger_readoutspeed = 0;
|
||||
int eiger_readoutmode = 0;
|
||||
int eiger_highvoltage = 0;
|
||||
int eiger_iodelay = 0;
|
||||
int eiger_triggermode = 0;
|
||||
int eiger_extgating = 0;
|
||||
int eiger_extgatingpolarity = 0;
|
||||
|
||||
const unsigned int ndacs = 16;
|
||||
const char* dac_names[16] = {"SvP","Vtr","Vrf","Vrs","SvN","Vtgstv","Vcmp_ll","Vcmp_lr","cal","Vcmp_rl","rxb_rb","rxb_lb","Vcmp_rr","Vcp","Vcn","Vis"};
|
||||
|
||||
int saved_trimbits[256*256*4];
|
||||
|
||||
|
||||
int EigerGetNumberOfExposures(){return eiger_nexposures;}
|
||||
float EigerGetExposureTime(){return eiger_exposuretime;}
|
||||
float EigerGetExposurePeriod(){return eiger_exposureperiod;}
|
||||
int EigerGetNumberOfCycles(){return eiger_ncycles;}
|
||||
/*int EigerGetNumberOfGates(){return eiger_ngates;}*/
|
||||
unsigned int EigerGetDynamicRange(){return eiger_dynamicrange;}
|
||||
int EigerGetPhotonEnergy(){return eiger_getphotonenergy;}
|
||||
int EigerGetReadoutSpeed(){return eiger_readoutspeed;}
|
||||
int EigerGetReadoutMode(){return eiger_readoutmode;}
|
||||
int EigerGetHighVoltage(){return eiger_highvoltage;}
|
||||
int EigerGetIODelay(){return eiger_iodelay;}
|
||||
int EigerGetTriggerMode(){return eiger_triggermode;}
|
||||
int EigerGetExternalGating(){return eiger_extgating;}
|
||||
int EigerGetExternalGatingPolarity(){return eiger_extgatingpolarity;}
|
||||
|
||||
int EigerInit(){
|
||||
saved_trimbits[0] = -1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int EigerSendCMD(){
|
||||
if(!EigerInit()||eiger_message_length<=0) return 0;
|
||||
|
||||
int sockfd = socket(AF_INET,SOCK_STREAM,0);
|
||||
if(sockfd<0){
|
||||
fprintf(stderr,"ERROR opening socket\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(connect(sockfd,(struct sockaddr *) &eiger_socket_addr,sizeof(eiger_socket_addr))<0){
|
||||
fprintf(stderr,"ERROR connecting\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n = write(sockfd,eiger_message,eiger_message_length);
|
||||
|
||||
int ret_length = read(sockfd,eiger_message,eiger_max_message_length);
|
||||
|
||||
close(sockfd);
|
||||
|
||||
if(n<0||ret_length<0) return 0;
|
||||
|
||||
|
||||
//fprintf(stdout,"%s\n",eiger_message);
|
||||
if(eiger_ret_val>0){
|
||||
int i=0;
|
||||
eiger_message[1]='\0';
|
||||
if(atoi(eiger_message)!=0) return 0;
|
||||
|
||||
for(i=2;i<ret_length;i++){
|
||||
if(eiger_message[i] == ' '){
|
||||
//fprintf(stdout," in : %d \n",i);
|
||||
eiger_message[i]='\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
eiger_ret_val = atoi(&eiger_message[2]);
|
||||
//fprintf(stdout," the \"%s\" %d\n",&eiger_message[2],eiger_ret_val);
|
||||
}
|
||||
|
||||
eiger_message_length = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* EigerGetDACName(int i){
|
||||
if(i>0&&i<ndacs) return dac_names[i];
|
||||
return dac_names[0];
|
||||
}
|
||||
|
||||
|
||||
int EigerSetDAC(const char* iname,int v, int mV){
|
||||
eiger_ret_val=0;
|
||||
if(mV)
|
||||
eiger_message_length = sprintf(eiger_message,"setdacvoltage %s %d",iname,v);
|
||||
else
|
||||
eiger_message_length = sprintf(eiger_message,"setdacvalue %s %d",iname,v);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetTrimbits(const int *data){
|
||||
eiger_ret_val=0;
|
||||
/*char tt[263681];
|
||||
tt[263680]='\0';
|
||||
int ip=0, ich=0;
|
||||
int iy, ix;
|
||||
int ichip;
|
||||
|
||||
// convert the trimbits from int32 to chars and add border pixels.
|
||||
for(iy=0;iy<256;iy++) {
|
||||
for (ichip=0; ichip<4; ichip++) {
|
||||
for(ix=0;ix<256;ix++) {
|
||||
tt[ip++]=(char)((data[ich++]&(0x3f))+'0');
|
||||
}
|
||||
if (ichip<3) {
|
||||
tt[ip++]=(char)(0+'0');
|
||||
tt[ip++]=(char)(0+'0');
|
||||
}
|
||||
}
|
||||
}
|
||||
eiger_message_length = sprintf(eiger_message,"settrimbits %s", tt);
|
||||
memcpy(saved_trimbits,data,256*256*4*sizeof(int));*/
|
||||
|
||||
eiger_message_length = sprintf(eiger_message,"settrimbits %d", 0);
|
||||
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int EigerSetAllTrimbits(unsigned int value){
|
||||
eiger_ret_val=0;
|
||||
/*char tt[263681];
|
||||
tt[263680]='\0';
|
||||
int ip=0, ich=0;
|
||||
int iy, ix;
|
||||
int ichip;
|
||||
int sl=0;
|
||||
|
||||
|
||||
// convert the trimbits from int32 to chars and add border pixels.
|
||||
for(iy=0;iy<256;iy++) {
|
||||
for (ichip=0; ichip<4; ichip++) {
|
||||
for(ix=0;ix<256;ix++) {
|
||||
tt[ip++]=(char)((value&0x3f)+'0');
|
||||
}
|
||||
if (ichip<3) {
|
||||
tt[ip++]=(char)(0+'0');
|
||||
tt[ip++]=(char)(0+'0');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eiger_message_length = sprintf(eiger_message,"settrimbits %s", tt);
|
||||
for(iy=0;iy<256*256*4;++iy)
|
||||
saved_trimbits[iy] = value;*/
|
||||
eiger_message_length = sprintf(eiger_message,"setalltrimbits %d", value);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int EigerGetTrimbits(const int *data){
|
||||
eiger_ret_val=0;
|
||||
/*char tt[263681];
|
||||
tt[263680]='\0';
|
||||
int ip=0, ich=0;
|
||||
int iy, ix;
|
||||
int ichip;
|
||||
|
||||
eiger_message_length = sprintf(eiger_message,"gettrimbits ");
|
||||
memcpy(data,saved_trimbits,256*256*4*sizeof(int));*/
|
||||
|
||||
eiger_message_length = sprintf(eiger_message,"gettrimbits ");
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int EigerGetDAC(const char* iname){
|
||||
eiger_ret_val=1;
|
||||
eiger_message_length = sprintf(eiger_message,"getdacvalue %s",iname);
|
||||
if(!EigerSendCMD()) return -1;
|
||||
return eiger_ret_val;
|
||||
}
|
||||
|
||||
int EigerGetDACmV(const char* iname){
|
||||
eiger_ret_val=1;
|
||||
eiger_message_length = sprintf(eiger_message,"getdacvoltage %s",iname);
|
||||
if(!EigerSendCMD()) return -1;
|
||||
return eiger_ret_val;
|
||||
}
|
||||
|
||||
int EigerSetNumberOfExposures(unsigned int n){
|
||||
eiger_nexposures = n;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setnumberofexposures %u",eiger_nexposures*eiger_ncycles);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetExposureTime(float v){
|
||||
eiger_exposuretime = v;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setexposuretime %f",v);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
int EigerSetExposurePeriod(float v){
|
||||
eiger_exposureperiod = v;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setexposureperiod %f",v);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetNumberOfCycles(unsigned int n){
|
||||
eiger_ncycles = n;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setnumberofexposures %u",eiger_nexposures*eiger_ncycles);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
/*
|
||||
int EigerSetNumberOfGates(unsigned int n){
|
||||
eiger_ngates = n;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setnumberofexposures %u",n);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
*/
|
||||
int EigerSetDynamicRange(unsigned int i){
|
||||
eiger_dynamicrange = i;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setbitmode %u",i);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
int EigerSetPhotonEnergy(int in_eV){
|
||||
eiger_getphotonenergy = in_eV;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setphotonenergy %d",in_eV);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetReadoutSpeed(int speed){
|
||||
eiger_readoutspeed = speed;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setreadoutspeed %d",speed);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetReadoutMode(int mode){
|
||||
eiger_readoutmode = mode;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setreadoutmode %d",mode);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetHighVoltage(int hv){
|
||||
eiger_highvoltage = hv;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"sethighvoltage %d",hv);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetIODelay(int io){
|
||||
eiger_iodelay = io;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setinputdelays %d",io);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetTriggerMode(int m){
|
||||
eiger_triggermode = m;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"settriggermode %d",m);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetExternalGating(int e, int p){
|
||||
eiger_extgating = e;
|
||||
eiger_extgatingpolarity = p;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setexternalgating %d %d",e,p);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerStartAcquisition(){
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"startacquisition");
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
int EigerRunStatus(){
|
||||
eiger_ret_val=1;
|
||||
eiger_message_length = sprintf(eiger_message,"isdaqstillrunning");
|
||||
if(!EigerSendCMD()) return -1;
|
||||
return eiger_ret_val;
|
||||
}
|
||||
|
||||
int EigerStopAcquisition(){
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"stopacquisition");
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerWaitForAcquisitionFinish(){
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"waituntildaqfinished");
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
#ifdef TESTEIGERFUNCTIONS
|
||||
int main(){
|
||||
|
||||
int v=220;
|
||||
char n[2000] = "Vcmp_lr";
|
||||
|
||||
fprintf(stdout," ret : %d\n",EigerSetDAC(EigerGetDACName(7),2200));
|
||||
int t = EigerGetDAC(EigerGetDACName(7));
|
||||
fprintf(stdout," v : %d\n",t);
|
||||
|
||||
fprintf(stdout," ret : %d\n",EigerSetDAC(n,v));
|
||||
t = EigerGetDAC(n);
|
||||
fprintf(stdout," ret : %d\n",t);
|
||||
|
||||
float f=0.12;
|
||||
fprintf(stdout," ret : %d\n",EigerSetNumberOfExposures(120));
|
||||
fprintf(stdout," ret : %d\n",EigerSetExposureTime(0.12));
|
||||
fprintf(stdout," ret : %d\n",EigerSetExposurePeriod(0.22));
|
||||
fprintf(stdout," ret : %d\n",EigerSetPhotonEnergy(9200));
|
||||
fprintf(stdout," ret : %d\n",EigerSetDynamicRange(16));
|
||||
fprintf(stdout," ret : %d\n",EigerStartAcquisition());
|
||||
fprintf(stdout," aret : %d\n",EigerRunStatus());
|
||||
sleep(1);
|
||||
fprintf(stdout," ret : %d\n",EigerStopAcquisition());
|
||||
fprintf(stdout," bret : %d\n",EigerRunStatus());
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
//daq register definitions
|
||||
#define DAQ_REG_CTRL 1
|
||||
#define DAQ_REG_CHIP_CMDS 2
|
||||
#define DAQ_REG_STATIC_BITS 3
|
||||
#define DAQ_REG_CLK_ROW_CLK_NTIMES 3
|
||||
#define DAQ_REG_SHIFT_IN_32 3
|
||||
#define DAQ_REG_READOUT_NROWS 3
|
||||
#define DAQ_REG_SEND_N_TESTPULSES 3
|
||||
|
||||
#define DAQ_REG_NEXPOSURES 3
|
||||
#define DAQ_REG_EXPOSURE_TIMER 4 // == (31 downto 3) * 10^(2 downto 0)
|
||||
#define DAQ_REG_EXPOSURE_REPEAT_TIMER 5 // == (31 downto 3) * 10^(2 downto 0)
|
||||
#define DAQ_REG_STATUS 6 //also pg and fifo status register
|
||||
|
||||
#define DAQ_CTRL_RESET 0x80000000
|
||||
#define DAQ_CTRL_START 0x40000000
|
||||
#define ACQ_CTRL_START 0x50000000 //this is 0x10000000 (acq) | 0x40000000 (daq)
|
||||
#define DAQ_CTRL_STOP 0x00000000
|
||||
|
||||
//direct chip commands to the DAQ_REG_CHIP_CMDS register
|
||||
#define DAQ_SET_STATIC_BIT 0x00000001
|
||||
#define DAQ_RESET_COMPLETELY 0x0000000E
|
||||
#define DAQ_RESET_PERIPHERY 0x00000002
|
||||
#define DAQ_RESET_PIXEL_COUNTERS 0x00000004
|
||||
#define DAQ_RESET_COLUMN_SELECT 0x00000008
|
||||
|
||||
#define DAQ_STORE_IMAGE 0x00000010
|
||||
#define DAQ_RELEASE_IMAGE_STORE 0x00000020
|
||||
|
||||
#define DAQ_SEND_A_TOKEN_IN 0x00000040
|
||||
#define DAQ_CLK_ROW_CLK_NTIMES 0x00000080
|
||||
#define DAQ_SERIALIN_SHIFT_IN_32 0x00000100
|
||||
#define DAQ_LOAD_16ROWS_OF_TRIMBITS 0x00000200
|
||||
|
||||
#define DAQ_IGNORE_INITIAL_CRAP 0x00000400 //crap before readout
|
||||
#define DAQ_READOUT_NROWS 0x00000800
|
||||
#define DAQ_CLKOUT_LAST_4_BITS_AND_RETURN_TO_START 0x00001000 //last 4 bit of data in the last frame
|
||||
|
||||
#define DAQ_RELEASE_IMAGE_STORE_AFTER_READOUT 0x00002000
|
||||
#define DAQ_RESET_PIXEL_COUNTERS_AFTER_READOUT 0x00004000
|
||||
|
||||
#define DAQ_CLK_ROW_CLK_TO_SELECT_NEXT_ROW 0x00008000
|
||||
#define DAQ_CLK_MAIN_CLK_TO_SELECT_NEXT_PIXEL 0x00010000
|
||||
#define DAQ_SEND_N_TEST_PULSES 0x00020000
|
||||
|
||||
#define DAQ_CHIP_CONTROLLER_HALF_SPEED 0x00040000 //everything at 100 MHz (50MHz ddr readout)
|
||||
#define DAQ_CHIP_CONTROLLER_QUARTER_SPEED 0x00080000 //everything at 50 MHz (25MHz ddr readout)
|
||||
#define DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED 0x000c0000 //everything at ~200 kHz (200 kHz MHz ddr readout)
|
||||
|
||||
#define DAQ_FIFO_ENABLE 0x00100000
|
||||
|
||||
//direct chip commands to the DAQ_REG_CHIP_CMDS register
|
||||
#define DAQ_NEXPOSURERS_SAFEST_MODE_ROW_CLK_BEFORE_MODE 0x00200000 //row clk is before main clk readout sequence
|
||||
#define DAQ_NEXPOSURERS_NORMAL_NONPARALLEL_MODE 0x00400000 //expose ->readout ->expose -> ..., with store is always closed
|
||||
#define DAQ_NEXPOSURERS_PARALLEL_MODE 0x00600000 //parallel acquire/read mode
|
||||
|
||||
//DAQ_NEXPOSURERS_READOUT_COMPLETE_IMAGES is old now hard-wired in the firmware that every image comes with a header
|
||||
//#define DAQ_NEXPOSURERS_READOUT_COMPLETE_IMAGES 0x00800000 //DAQ_IGNORE_INITIAL_CRAP and DAQ_CLKOUT_LAST_4_BITS_AND_RETURN_TO_START
|
||||
|
||||
#define DAQ_NEXPOSURERS_EXTERNAL_ENABLING 0x01000000
|
||||
#define DAQ_NEXPOSURERS_EXTERNAL_ENABLING_POLARITY 0x02000000
|
||||
#define DAQ_NEXPOSURERS_EXTERNAL_TRIGGER_POLARITY 0x04000000
|
||||
|
||||
#define DAQ_NEXPOSURERS_INTERNAL_ACQUISITION 0x00000000 //internally controlled
|
||||
#define DAQ_NEXPOSURERS_EXTERNAL_ACQUISITION_START 0x08000000 //external acquisition start
|
||||
#define DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START 0x10000000 //external image start
|
||||
#define DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START_AND_STOP 0x18000000 //externally controlly, external image start and stop
|
||||
|
||||
#define DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING 0x20000000
|
||||
#define DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION 0x40000000
|
||||
|
||||
//#define DAQ_MASTER_HALF_MODULE 0x80000000 currently not used
|
||||
|
||||
|
||||
//chips static bits
|
||||
#define DAQ_STATIC_BIT_PROGRAM 0x00000001
|
||||
#define DAQ_STATIC_BIT_M4 0x00000002 //these are the status bits, not bit mode
|
||||
#define DAQ_STATIC_BIT_M8 0x00000004 //these are the status bits, not bit mode
|
||||
#define DAQ_STATIC_BIT_M12 0x00000000 //these are the status bits, not bit mode, ie. "00" is 12 bit mode
|
||||
#define DAQ_STATIC_BIT_CHIP_TEST 0x00000008
|
||||
#define DAQ_STATIC_BIT_ROTEST 0x00000010
|
||||
#define DAQ_CS_BAR_LEFT 0x00000020
|
||||
#define DAQ_CS_BAR_RIGHT 0x00000040
|
||||
|
||||
|
||||
//status flags
|
||||
#define DAQ_STATUS_DAQ_RUNNING 0x01
|
||||
#define DAQ_DATA_COLLISION_ERROR 0x02
|
||||
|
||||
#define DAQ_STATUS_CURRENT_M4 0x04
|
||||
#define DAQ_STATUS_CURRENT_M8 0x08
|
||||
#define DAQ_STATUS_CURRENT_M12 0x00 //in 12 bit mode both are cleared
|
||||
#define DAQ_STATUS_CURRENT_TESTMODE 0x10
|
||||
#define DAQ_STATUS_TOKEN_OUT 0x20
|
||||
#define DAQ_STATUS_SERIAL_OUT 0x40
|
||||
#define DAQ_STATUS_PIXELS_ARE_ENABLED 0x80
|
||||
#define DAQ_STATUS_DAQ_RUN_TOGGLE 0x200
|
||||
|
||||
//data delay registers
|
||||
#define CHIP_DATA_OUT_DELAY_REG_CTRL 1
|
||||
#define CHIP_DATA_OUT_DELAY_REG2 2
|
||||
#define CHIP_DATA_OUT_DELAY_REG3 3
|
||||
#define CHIP_DATA_OUT_DELAY_REG4 4
|
||||
#define CHIP_DATA_OUT_DELAY_SET 0x20000000
|
||||
|
||||
|
||||
//module configuration
|
||||
#define TOP_BIT_MASK 0x00f
|
||||
#define MASTER_BIT_MASK 0x200
|
||||
@@ -1,38 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Eiger.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
|
||||
cout<<"\n\n\n\n\n\n\n\n\n\n"<<endl;
|
||||
int n = (argc>1) ? atoi(argv[1]):5;
|
||||
|
||||
//Feb *f = new Feb();
|
||||
// f->Test();
|
||||
//delete f;
|
||||
//return 0;
|
||||
|
||||
Eiger* e = new Eiger();
|
||||
e->SetNImages(n);
|
||||
e->SetDynamicRange(32);
|
||||
e->SetExposureTime(0.02);
|
||||
e->SetExposurePeriod(0.050);
|
||||
e->StartAcquisition();
|
||||
|
||||
delete e;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,326 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
//return reversed 1 means good, 0 means failed
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
//#include <unistd.h>
|
||||
//#include <string.h>
|
||||
//#include <sys/mman.h>
|
||||
//#include <fcntl.h>
|
||||
|
||||
#include "xparameters.h"
|
||||
|
||||
#include "Feb.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Feb::Feb(){
|
||||
|
||||
nfebs = 0;
|
||||
feb_numb = 0;
|
||||
|
||||
send_ndata = 0;
|
||||
send_buffer_size = 1026;
|
||||
send_data_raw = new unsigned int [send_buffer_size+1];
|
||||
send_data = &send_data_raw[1];
|
||||
|
||||
recv_ndata = 0;
|
||||
recv_buffer_size = 1026;
|
||||
recv_data_raw = new unsigned int [recv_buffer_size+1];
|
||||
recv_data = &recv_data_raw[1];
|
||||
|
||||
ll = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR);
|
||||
|
||||
}
|
||||
|
||||
Feb::~Feb(){
|
||||
delete ll;
|
||||
if(feb_numb) delete [] feb_numb;
|
||||
delete [] send_data_raw;
|
||||
delete [] recv_data_raw;
|
||||
}
|
||||
|
||||
void Feb::SendCompleteFebList(unsigned int n,unsigned int* list){
|
||||
if(feb_numb) delete [] feb_numb;
|
||||
nfebs = n;
|
||||
feb_numb = new unsigned int [n];
|
||||
for(unsigned int i=0;i<n;i++) feb_numb[i] = list[i];
|
||||
}
|
||||
|
||||
bool Feb::WriteTo(unsigned int ch){
|
||||
if(ch>0xfff) return 0;
|
||||
|
||||
send_data_raw[0] = 0x90000000 | (ch<<16); //we
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
send_data_raw[0] = 0xc0000000; //data
|
||||
return ((send_ndata+1)*4==ll->Write((send_ndata+1)*4,send_data_raw));
|
||||
}
|
||||
|
||||
bool Feb::ReadFrom(unsigned int ch, unsigned int ntrys){
|
||||
if(ch>=0xfff) return 0;
|
||||
|
||||
recv_data_raw[0] = 0xa0000000 | (ch<<16); //read data
|
||||
ll->Write(4,recv_data_raw);
|
||||
usleep(20);
|
||||
|
||||
recv_ndata=-1;
|
||||
for(unsigned int t=0;t<ntrys;t++){
|
||||
if((recv_ndata=ll->Read(recv_buffer_size*4,recv_data_raw)/4)>0){
|
||||
recv_ndata--;
|
||||
break;
|
||||
}
|
||||
cout<<"\t Read try number: "<<t<<endl;
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
return (recv_ndata>=0);
|
||||
}
|
||||
|
||||
void Feb::PrintData(){
|
||||
cout<<"Sent data: "<<send_ndata<<endl;
|
||||
for(int i=0;i<send_ndata;i++) cout<<"\t"<<i<<")"<<setw(14)<<send_data[i]<<" ("<<hex<<send_data[i]<<")"<<dec<<endl;
|
||||
cout<<"Receive data: "<<recv_ndata<<endl;
|
||||
for(int i=0;i<recv_ndata;i++) cout<<"\t"<<i<<")"<<setw(14)<<recv_data[i]<<" ("<<hex<<recv_data[i]<<")"<<dec<<endl;
|
||||
cout<<endl<<endl;
|
||||
}
|
||||
|
||||
|
||||
bool Feb::CheckHeader(unsigned int valid_bit_mask, bool print_error_info){
|
||||
|
||||
bool header_returned_is_ok = (send_data[0] & valid_bit_mask)==(recv_data[0] & valid_bit_mask);
|
||||
|
||||
if(print_error_info && !header_returned_is_ok){
|
||||
cout<<"Error: Command received not the same as command recieved."<<endl;
|
||||
cout<<"\t\t Header sent: "<<dec<<send_data[0]<<" ("<<hex<<send_data[0]<<") recieved: "<<dec<<recv_data[0]<<" ("<<hex<<recv_data[0]<<")"<<dec<<endl;
|
||||
if(send_ndata>1&&recv_ndata>1){
|
||||
cout<<"\t\t Tail sent: "<<dec<<send_data[send_ndata-1]<<" ("<<hex<<send_data[send_ndata-1]<<") recieved: "<<dec<<recv_data[recv_ndata-1]<<" ("<<hex<<recv_data[recv_ndata-1]<<")"<<dec<<endl;
|
||||
}else{
|
||||
cout<<"Error printing tail, too little data nsent = "<<send_ndata<<", nrecv = "<<recv_ndata<<"."<<endl;
|
||||
}
|
||||
PrintData();
|
||||
}
|
||||
return header_returned_is_ok;
|
||||
}
|
||||
|
||||
|
||||
bool Feb::CheckTail(unsigned int valid_bit_mask){
|
||||
if(send_ndata<=1&&recv_ndata<=1){
|
||||
cout<<"Error checking tail, too little data nsent = "<<send_ndata<<", nrecv = "<<recv_ndata<<"."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int the_tail = recv_data[recv_ndata-1]&valid_bit_mask;
|
||||
if(the_tail!=0){
|
||||
cout<<"Error returned in tail: "<<hex<<the_tail<<" "<<dec<<"("<<the_tail<<")"<<endl;
|
||||
if(the_tail&0x10000000) cout<<"\t\tBusy flag address error."<<endl;
|
||||
if(the_tail&0x20000000) cout<<"\t\tRead register address error."<<endl;
|
||||
if(the_tail&0x40000000) cout<<"\t\tWrite register address error."<<endl;
|
||||
if(the_tail&0x80000000) cout<<"\t\tBram number error."<<endl;
|
||||
if(the_tail&0x08000000) cout<<"\t\tFifo to read from error."<<endl;
|
||||
if(the_tail&0x3ff) cout<<"\t\tNumber of data send error."<<endl;
|
||||
return 0; //error
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Feb::CheckCommunication(){
|
||||
send_data_raw[0] = 0x8fff0000; //rst-all serial coms and lls
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
cout<<"Feb::CheckingCommunication ...."<<endl;
|
||||
while((ll->Read(recv_buffer_size*4,recv_data_raw)/4)>0) cout<<"\t) Cleanning buffer ..."<<endl;
|
||||
|
||||
return SetByteOrder();
|
||||
}
|
||||
|
||||
|
||||
bool Feb::SetByteOrder(){
|
||||
|
||||
send_ndata = 2;
|
||||
send_data[0] = 0; //header
|
||||
send_data[1] = 0; //tail
|
||||
|
||||
unsigned int dst = 0xff;
|
||||
for(unsigned int i=0;i<nfebs;i++) dst = (dst | feb_numb[i]); //get sub dst bits (left right in this case)
|
||||
bool passed = WriteTo(dst);
|
||||
|
||||
for(unsigned int i=0;i<nfebs;i++){
|
||||
cout<<"\t"<<i<<") Set Byte Order .............. ";
|
||||
unsigned int current_passed = ReadFrom(feb_numb[i])&&(recv_ndata==2)&&CheckHeader();
|
||||
if(current_passed) cout<<"passed."<<endl;
|
||||
else cout<<"failed."<<endl;
|
||||
passed&=current_passed;
|
||||
}
|
||||
cout<<endl;
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
/*
|
||||
bool Feb::CheckSubNumber(unsigned int sub_num){
|
||||
if(sub_num>=nfebs){
|
||||
cout<<"Error invalid sub number "<<sub_num<<" must be less than "<<nfebs<<"."<<endl;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool Feb::SetStartOnEndOnFebs(int sub_num_s, unsigned int& start_on, unsigned int& end_on){
|
||||
// -1 means write to all
|
||||
|
||||
if(sub_num_s<=-2){
|
||||
cout<<"Error bad subnumber "<<sub_num_s<<"."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
start_on = sub_num_s!=-1 ? sub_num_s : 0;
|
||||
end_on = sub_num_s!=-1 ? sub_num_s : nfebs - 1;
|
||||
|
||||
return CheckSubNumber(start_on);
|
||||
}
|
||||
*/
|
||||
|
||||
bool Feb::ReadRegister(unsigned int sub_num, unsigned int reg_num,unsigned int& value_read){
|
||||
return ReadRegisters(sub_num,1,®_num,&value_read);
|
||||
}
|
||||
|
||||
|
||||
bool Feb::ReadRegisters(unsigned int sub_num, unsigned int nreads, unsigned int* reg_nums,unsigned int* values_read){
|
||||
//here cout<<"Reading Register ...."<<endl;
|
||||
|
||||
nreads &= 0x3ff; //10 bits
|
||||
if(!nreads||nreads>send_buffer_size-2) return 0;
|
||||
|
||||
send_ndata = nreads+2;
|
||||
send_data[0] = 0x20000000 | nreads << 14; //cmd -> read "00" , nreads
|
||||
|
||||
for(unsigned int i=0;i<nreads;i++) send_data[i+1]=reg_nums[i];
|
||||
send_data[nreads+1] = 0; //tail
|
||||
|
||||
if(!WriteTo(sub_num)||!ReadFrom(sub_num)||recv_ndata!=int(nreads+2)||!CheckHeader()||!CheckTail()){
|
||||
PrintData();
|
||||
cout<<"Error reading register."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(unsigned int i=0;i<nreads;i++) values_read[i] = recv_data[i+1];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool Feb::WriteRegister(unsigned int sub_num, unsigned int reg_num,unsigned int value, bool wait_on, unsigned int wait_on_address){
|
||||
return WriteRegisters(sub_num,1,®_num,&value,&wait_on,&wait_on_address);
|
||||
}
|
||||
|
||||
bool Feb::WriteRegisters(unsigned int sub_num, unsigned int nwrites, unsigned int* reg_nums, unsigned int* values, bool* wait_ons, unsigned int* wait_on_addresses){
|
||||
|
||||
// sub_num == 0xfff means write to all
|
||||
|
||||
nwrites &= 0x3ff; //10 bits
|
||||
if(!nwrites||nwrites>send_buffer_size-2) return 0;
|
||||
|
||||
//cout<<"Write register : "<<this<<" "<<s_num<<" "<<nwrites<<" "<<reg_nums<<" "<<values<<" "<<wait_ons<<" "<<wait_on_addresses<<endl;
|
||||
send_ndata = 2*nwrites+2;
|
||||
send_data[0] = 0x80000000 | nwrites << 14; //cmd -> write nwrites and how many
|
||||
send_data[2*nwrites+1] = 0; //tail
|
||||
|
||||
for(unsigned int i=0;i<nwrites;i++) send_data[2*i+1] = 0x3fff®_nums[i]; // register address data_in(13 downto 0)
|
||||
for(unsigned int i=0;i<nwrites;i++) send_data[2*i+2] = values[i]; // value is data_in(31 downto 0)
|
||||
// wait on busy data(28), address of busy flag data(27 downto 14)
|
||||
if(wait_ons&&wait_on_addresses) for(unsigned int i=0;i<nwrites;i++) send_data[2*i+1] |= (wait_ons[i]<<28 | (0x3fff&wait_on_addresses[i])<<14);
|
||||
|
||||
if(!WriteTo(sub_num)){
|
||||
cout<<sub_num<<") Error writing register(s)."<<endl;
|
||||
PrintData();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool passed = 1;
|
||||
unsigned int n = (sub_num&0xff)==0xff ? nfebs : 1;
|
||||
unsigned int* nums = (sub_num&0xff)==0xff ? feb_numb : &sub_num;
|
||||
for(unsigned int i=0;i<n;i++){
|
||||
if((sub_num&0xf00&(nums[i]))==0) continue;
|
||||
if(!ReadFrom(nums[i])||recv_ndata!=2||!CheckHeader()){
|
||||
cout<<nums[i]<<") Error writing register(s) response."<<endl;
|
||||
PrintData();
|
||||
passed = 0;
|
||||
}else{
|
||||
passed = passed && CheckTail();
|
||||
}
|
||||
}
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
|
||||
bool Feb::WriteMemory(unsigned int sub_num, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values){
|
||||
// -1 means write to all
|
||||
|
||||
mem_num &= 0x3f; //6 bits
|
||||
start_address &= 0x3fff; //14 bits
|
||||
nwrites &= 0x3ff; //10 bits
|
||||
if(!nwrites||nwrites>send_buffer_size-2) return 0;
|
||||
|
||||
send_ndata = nwrites+2;
|
||||
send_data[0] = 0xc0000000 | mem_num << 24 | nwrites << 14 | start_address; //cmd -> write to memory, nwrites, mem number, start address
|
||||
send_data[nwrites+1] = 0; //tail
|
||||
for(unsigned int i=0;i<nwrites;i++) send_data[i+1] = values[i];
|
||||
|
||||
|
||||
if(!WriteTo(sub_num)){
|
||||
cout<<sub_num<<") Error writing memory."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool passed = 1;
|
||||
unsigned int n = (sub_num&0xff)==0xff ? nfebs : 1;
|
||||
unsigned int* nums = (sub_num&0xff)==0xff ? feb_numb : &sub_num;
|
||||
for(unsigned int i=0;i<n;i++){
|
||||
if((sub_num&0xf00&(nums[i]))==0) continue;
|
||||
if(!ReadFrom(nums[i])||recv_ndata!=2||!CheckHeader()){
|
||||
cout<<nums[i]<<") Error writing memory response."<<endl;
|
||||
PrintData();
|
||||
passed = 0;
|
||||
}else{
|
||||
passed = passed && CheckTail();
|
||||
}
|
||||
}
|
||||
// unsigned int n = sub_num==0xfff ? nfebs : 1;
|
||||
// unsigned int* nums = sub_num==0xfff ? feb_numb : &sub_num;
|
||||
// for(unsigned int i=0;i<n;i++){
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Feb::Test(){//int sub_num_s, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values){
|
||||
// -1 means write to all
|
||||
|
||||
unsigned int reg_nums[10]={0,1,2,3,1,2,3,1,2,3};
|
||||
|
||||
cout<<"Test"<<endl<<endl<<endl<<endl;
|
||||
|
||||
unsigned int value = 0;
|
||||
for(unsigned int i=0;i<10;i++){
|
||||
WriteRegister(0xfff,reg_nums[i%10],i);
|
||||
ReadRegister(256,reg_nums[i%10],value);
|
||||
cout<<i<<" "<<value<<endl;
|
||||
ReadRegister(512,reg_nums[i%10],value);
|
||||
cout<<i<<" "<<value<<endl;
|
||||
WriteMemory(0xfff,0,0,10,reg_nums);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -607,14 +607,22 @@ int Feb_Control_SendHighVoltage(int dacvalue){
|
||||
char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE];
|
||||
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-2]='\0';
|
||||
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n';
|
||||
int n = 0;
|
||||
int n;
|
||||
sprintf(buffer,"p%d ",dacvalue);
|
||||
n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||
if (n < 0) {
|
||||
cprintf(RED,"\nWarning: Error writing to i2c bus\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef VERBOSEI
|
||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||
#endif
|
||||
//ok/fail
|
||||
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||
if (n < 0) {
|
||||
cprintf(RED,"\nWarning: Error reading from i2c bus\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef VERBOSEI
|
||||
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||
#endif
|
||||
@@ -686,12 +694,20 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){
|
||||
//request
|
||||
strcpy(buffer,"g ");
|
||||
n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||
if (n < 0) {
|
||||
cprintf(RED,"\nWarning: Error writing to i2c bus\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef VERBOSEI
|
||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||
#endif
|
||||
|
||||
//ok/fail
|
||||
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||
if (n < 0) {
|
||||
cprintf(RED,"\nWarning: Error reading from i2c bus\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef VERBOSEI
|
||||
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||
#endif
|
||||
@@ -701,6 +717,10 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){
|
||||
}
|
||||
|
||||
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||
if (n < 0) {
|
||||
cprintf(RED,"\nWarning: Error reading from i2c bus\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef VERBOSEI
|
||||
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,175 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
//#include <unistd.h>
|
||||
//#include <string.h>
|
||||
//#include <sys/mman.h>
|
||||
//#include <fcntl.h>
|
||||
|
||||
#include "xparameters.h"
|
||||
|
||||
#include "FebInterface.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FebInterface::FebInterface(){
|
||||
|
||||
nfebs = 0;
|
||||
feb_numb = 0;
|
||||
|
||||
send_ndata = 0;
|
||||
send_buffer_size = 1026;
|
||||
send_data_raw = new unsigned int [send_buffer_size+1];
|
||||
send_data = &send_data_raw[1];
|
||||
|
||||
recv_ndata = 0;
|
||||
recv_buffer_size = 1026;
|
||||
recv_data_raw = new unsigned int [recv_buffer_size+1];
|
||||
recv_data = &recv_data_raw[1];
|
||||
|
||||
ll = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR);
|
||||
|
||||
}
|
||||
|
||||
FebInterface::~FebInterface(){
|
||||
delete ll;
|
||||
if(feb_numb) delete [] feb_numb;
|
||||
delete [] send_data_raw;
|
||||
delete [] recv_data_raw;
|
||||
}
|
||||
|
||||
void FebInterface::SendCompleteList(unsigned int n,unsigned int* list){
|
||||
if(feb_numb) delete [] feb_numb;
|
||||
nfebs = n;
|
||||
feb_numb = new unsigned int [n];
|
||||
for(unsigned int i=0;i<n;i++) feb_numb[i] = list[i];
|
||||
}
|
||||
|
||||
bool FebInterface::WriteTo(unsigned int ch){
|
||||
if(ch>0xfff) return 0;
|
||||
|
||||
send_data_raw[0] = 0x8fff0000;
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
send_data_raw[0] = 0x90000000 | (ch<<16);
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
send_data_raw[0] = 0xc0000000;
|
||||
return ((send_ndata+1)*4==ll->Write((send_ndata+1)*4,send_data_raw));
|
||||
}
|
||||
|
||||
bool FebInterface::ReadFrom(unsigned int ch, unsigned int ntrys){
|
||||
if(ch>=0xfff) return 0;
|
||||
|
||||
recv_data_raw[0] = 0xa0000000 | (ch<<16);
|
||||
ll->Write(4,recv_data_raw);
|
||||
usleep(20);
|
||||
|
||||
recv_ndata=-1;
|
||||
for(unsigned int t=0;t<ntrys;t++){
|
||||
if((recv_ndata=ll->Read(recv_buffer_size*4,recv_data_raw)/4)>0){
|
||||
recv_ndata--;
|
||||
break;
|
||||
}
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
return (recv_ndata>=0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FebInterface::SetByteOrder(){
|
||||
|
||||
send_data_raw[0] = 0x8fff0000;
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
send_ndata = 2;
|
||||
send_data[0] = 0;
|
||||
send_data[1] = 0;
|
||||
|
||||
unsigned int dst = 0xff;
|
||||
for(unsigned int i=0;i<nfebs;i++) dst = (dst | feb_numb[i]);
|
||||
bool passed = WriteTo(dst);
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
|
||||
bool FebInterface::ReadRegister(unsigned int sub_num, unsigned int reg_num,unsigned int& value_read){
|
||||
return ReadRegisters(sub_num,1,®_num,&value_read);
|
||||
}
|
||||
|
||||
|
||||
bool FebInterface::ReadRegisters(unsigned int sub_num, unsigned int nreads, unsigned int* reg_nums,unsigned int* values_read){
|
||||
//here cout<<"Reading Register ...."<<endl;
|
||||
|
||||
nreads &= 0x3ff;
|
||||
if(!nreads||nreads>send_buffer_size-2) return 0;
|
||||
|
||||
send_ndata = nreads+2;
|
||||
send_data[0] = 0x20000000 | nreads << 14;
|
||||
|
||||
for(unsigned int i=0;i<nreads;i++) send_data[i+1]=reg_nums[i];
|
||||
send_data[nreads+1] = 0;
|
||||
|
||||
if(!WriteTo(sub_num)||!ReadFrom(sub_num)||recv_ndata!=int(nreads+2)) return 0;
|
||||
|
||||
for(unsigned int i=0;i<nreads;i++) values_read[i] = recv_data[i+1];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool FebInterface::WriteRegister(unsigned int sub_num, unsigned int reg_num,unsigned int value, bool wait_on, unsigned int wait_on_address){
|
||||
return WriteRegisters(sub_num,1,®_num,&value,&wait_on,&wait_on_address);
|
||||
}
|
||||
|
||||
bool FebInterface::WriteRegisters(unsigned int sub_num, unsigned int nwrites, unsigned int* reg_nums, unsigned int* values, bool* wait_ons, unsigned int* wait_on_addresses){
|
||||
|
||||
nwrites &= 0x3ff; //10 bits
|
||||
if(!nwrites||2*nwrites>send_buffer_size-2) return 0;
|
||||
|
||||
//cout<<"Write register : "<<this<<" "<<s_num<<" "<<nwrites<<" "<<reg_nums<<" "<<values<<" "<<wait_ons<<" "<<wait_on_addresses<<endl;
|
||||
send_ndata = 2*nwrites+2;
|
||||
send_data[0] = 0x80000000 | nwrites << 14;
|
||||
send_data[2*nwrites+1] = 0;
|
||||
|
||||
for(unsigned int i=0;i<nwrites;i++) send_data[2*i+1] = 0x3fff®_nums[i];
|
||||
for(unsigned int i=0;i<nwrites;i++) send_data[2*i+2] = values[i];
|
||||
// wait on busy data(28), address of busy flag data(27 downto 14)
|
||||
if(wait_ons&&wait_on_addresses) for(unsigned int i=0;i<nwrites;i++) send_data[2*i+1] |= (wait_ons[i]<<28 | (0x3fff&wait_on_addresses[i])<<14);
|
||||
|
||||
if(!WriteTo(sub_num)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool FebInterface::WriteMemory(unsigned int sub_num, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values){
|
||||
// -1 means write to all
|
||||
|
||||
mem_num &= 0x3f;
|
||||
start_address &= 0x3fff;
|
||||
nwrites &= 0x3ff;
|
||||
if(!nwrites||nwrites>send_buffer_size-2) {cout<<"error herer: nwrites:"<<nwrites<<endl;return 0;}//*d-1026
|
||||
|
||||
send_ndata = nwrites+2;//*d-1025
|
||||
send_data[0] = 0xc0000000 | mem_num << 24 | nwrites << 14 | start_address; //cmd -> write to memory, nwrites, mem number, start address
|
||||
send_data[nwrites+1] = 0;
|
||||
for(unsigned int i=0;i<nwrites;i++) send_data[i+1] = values[i];
|
||||
|
||||
|
||||
if(!WriteTo(sub_num)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -156,27 +156,27 @@
|
||||
#define FEB_REG_STATUS 0xa
|
||||
|
||||
//1g counters
|
||||
#define ONE_GIGA_LEFT_FRAME_SEND_COUNTER 0x04
|
||||
#define ONE_GIGA_LEFT_PKT_SEND_COUNTER 0x24
|
||||
#define ONE_GIGA_LEFT_INDEX_LSB_COUNTER 0x04
|
||||
#define ONE_GIGA_LEFT_INDEX_MSB_COUNTER 0x24
|
||||
|
||||
#define ONE_GIGA_LEFT_TXN_DELAY_COUNTER 0x104
|
||||
#define ONE_GIGA_LEFT_FRAME_DELAY_COUNTER 0x124
|
||||
|
||||
#define ONE_GIGA_RIGHT_FRAME_SEND_COUNTER 0x44
|
||||
#define ONE_GIGA_RIGHT_PKT_SEND_COUNTER 0x64
|
||||
#define ONE_GIGA_RIGHT_INDEX_LSB_COUNTER 0x44
|
||||
#define ONE_GIGA_RIGHT_INDEX_MSB_COUNTER 0x64
|
||||
|
||||
#define ONE_GIGA_RIGHT_TXN_DELAY_COUNTER 0x144
|
||||
#define ONE_GIGA_RIGHT_FRAME_DELAY_COUNTER 0x164
|
||||
|
||||
//10g counters
|
||||
#define TEN_GIGA_LEFT_FRAME_SEND_COUNTER 0x84
|
||||
#define TEN_GIGA_LEFT_PKT_SEND_COUNTER 0xa4
|
||||
#define TEN_GIGA_LEFT_INDEX_LSB_COUNTER 0x84
|
||||
#define TEN_GIGA_LEFT_INDEX_MSB_COUNTER 0xa4
|
||||
|
||||
#define TEN_GIGA_LEFT_TXN_DELAY_COUNTER 0x184
|
||||
#define TEN_GIGA_LEFT_FRAME_DELAY_COUNTER 0x1a4
|
||||
|
||||
#define TEN_GIGA_RIGHT_FRAME_SEND_COUNTER 0xc4
|
||||
#define TEN_GIGA_RIGHT_PKT_SEND_COUNTER 0xe4
|
||||
#define TEN_GIGA_RIGHT_INDEX_LSB_COUNTER 0xc4
|
||||
#define TEN_GIGA_RIGHT_INDEX_MSB_COUNTER 0xe4
|
||||
|
||||
#define TEN_GIGA_RIGHT_TXN_DELAY_COUNTER 0x1c4
|
||||
#define TEN_GIGA_RIGHT_FRAME_DELAY_COUNTER 0x1e4
|
||||
|
||||
@@ -1,604 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
* @developed for running Eiger at cSAXS
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <algorithm> // std::remove_if
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "FebControl.h"
|
||||
#include "slsDetectorServer_defs.h" //include port number
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum cmd_string {evNotFound,
|
||||
evReinitialize,evReset,
|
||||
|
||||
evSetInputDelays,
|
||||
evSetDACValue,evGetDACValue,evSetDACVoltage,evGetDACVoltage,evSetHighVoltage,//evGetHighVoltage,
|
||||
|
||||
evSetTrimBits,
|
||||
evSetAllTrimBits,
|
||||
evGetTrimBits,
|
||||
//evLoadTrimBitFile,
|
||||
|
||||
evSetBitMode,
|
||||
evSetPhotonEnergy,
|
||||
// evSetPhotonEnergyCalibrationParameters,evActivateRateCorrection,evDeactivateRateCorrection,evSetRateCorrectionTau,
|
||||
|
||||
evSetReadoutSpeed,evSetReadoutMode,
|
||||
|
||||
//temp solution
|
||||
// evNotFound1,evNotFound2,evNotFound3,
|
||||
|
||||
evSetNumberOfExposures,evSetExposureTime,evSetExposurePeriod,
|
||||
// evSetTriggerPolarityToPositive,evSetTriggerPolarityToNegative,
|
||||
evSetTriggerMode,
|
||||
evSetExternalGating,
|
||||
evStartAcquisition,evStopAcquisition,evIsDaqStillRunning,
|
||||
evWaitUntilDaqFinished,
|
||||
evExitServer
|
||||
};
|
||||
|
||||
map<string, cmd_string> enum_map;
|
||||
|
||||
void init(){
|
||||
|
||||
enum_map["reinitialize"] = evReinitialize;
|
||||
enum_map["reset"] = evReset;
|
||||
enum_map["setinputdelays"] = evSetInputDelays;
|
||||
enum_map["setdacvalue"] = evSetDACValue;
|
||||
enum_map["getdacvalue"] = evGetDACValue;
|
||||
enum_map["setdacvoltage"] = evSetDACVoltage;
|
||||
enum_map["getdacvoltage"] = evGetDACVoltage;
|
||||
enum_map["sethighvoltage"] = evSetHighVoltage;
|
||||
enum_map["settrimbits"] = evSetTrimBits;
|
||||
enum_map["setalltrimbits"] = evSetAllTrimBits;
|
||||
enum_map["gettrimbits"] = evGetTrimBits;
|
||||
// enum_map["loadtrimbitfile"] = evLoadTrimBitFile;
|
||||
enum_map["setbitmode"] = evSetBitMode;
|
||||
enum_map["setphotonenergy"] = evSetPhotonEnergy;
|
||||
// enum_map["setphotonenergycalibrationparameters"] = evSetPhotonEnergyCalibrationParameters;
|
||||
// enum_map["activateratecorrection"] = evActivateRateCorrection;
|
||||
// enum_map["deactivateratecorrection"] = evDeactivateRateCorrection;
|
||||
// enum_map["setratecorrectiontau"] = evSetRateCorrectionTau;
|
||||
enum_map["setreadoutspeed"] = evSetReadoutSpeed;
|
||||
enum_map["setreadoutmode"] = evSetReadoutMode;
|
||||
enum_map["setnumberofexposures"] = evSetNumberOfExposures;
|
||||
enum_map["setexposuretime"] = evSetExposureTime;
|
||||
enum_map["setexposureperiod"] = evSetExposurePeriod;
|
||||
// enum_map["settriggerpolaritytopositive"] = evSetTriggerPolarityToPositive;
|
||||
// enum_map["settriggerpolaritytonegative"] = evSetTriggerPolarityToNegative;
|
||||
enum_map["settriggermode"] = evSetTriggerMode;
|
||||
enum_map["setexternalgating"] = evSetExternalGating;
|
||||
enum_map["startacquisition"] = evStartAcquisition;
|
||||
enum_map["stopacquisition"] = evStopAcquisition;
|
||||
enum_map["isdaqstillrunning"] = evIsDaqStillRunning;
|
||||
enum_map["waituntildaqfinished"] = evWaitUntilDaqFinished;
|
||||
enum_map["exitserver"] = evExitServer;
|
||||
}
|
||||
|
||||
int server_list_s;
|
||||
int server_conn_s;
|
||||
int AccpetConnectionAndWaitForData(char* buffer, int maxlength);
|
||||
bool WriteNClose(const char* buffer, int length);
|
||||
bool SetupListenSocket(unsigned short int port);
|
||||
|
||||
|
||||
string LowerCase(string str);
|
||||
string GetNextString(string str,bool start_from_beginning=0);
|
||||
void AddNumber(string& str, int n, int location=-1, bool space_after=0);//-1 means append
|
||||
void AddNumber(string& str, float v, int location=-1, bool space_after=0);//-1 means append
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
cout<<endl<<endl;
|
||||
|
||||
/*
|
||||
if(argc<2){
|
||||
cout<<"Usage: feb_server port_number"<<endl<<endl;
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
init();
|
||||
|
||||
FebControl *feb_controler = new FebControl();
|
||||
|
||||
unsigned short int port_number = FEB_PORT;
|
||||
if(!SetupListenSocket(port_number)) return 1;
|
||||
|
||||
|
||||
int length=270000;
|
||||
char data[270000];
|
||||
|
||||
int stop = 0;
|
||||
time_t rawtime;
|
||||
struct tm *timeinfo;
|
||||
|
||||
|
||||
while(!stop){
|
||||
|
||||
/*cout<<"Waiting for command -> "<<flush;*/
|
||||
int nread = AccpetConnectionAndWaitForData(data,length);
|
||||
|
||||
if(nread<=0) return 0;
|
||||
|
||||
time(&rawtime); timeinfo=localtime(&rawtime);
|
||||
cout<<asctime(timeinfo);
|
||||
/*cout<<" Command received: "<<data<<endl;*/
|
||||
|
||||
|
||||
|
||||
string tmp_str[5];
|
||||
float v[4];//,v2,v3,v4,v5;
|
||||
int n[5];
|
||||
|
||||
|
||||
|
||||
string cmd = GetNextString(data,1);
|
||||
int ret_val = 1;
|
||||
|
||||
string return_message = "";/*\n\n\tCommand recieved: ";
|
||||
return_message.append(data);
|
||||
return_message.append("\n");
|
||||
*/
|
||||
int return_start_pos;
|
||||
while(cmd.length()>0){
|
||||
int ret_parameter = 0;
|
||||
return_start_pos = return_message.length();
|
||||
|
||||
switch(enum_map.find(LowerCase(cmd))->second){
|
||||
|
||||
case evReinitialize :
|
||||
if(feb_controler->Init()){
|
||||
return_message.append("\tExecuted: Reinitialize\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: Reinitialize\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evReset :
|
||||
if(feb_controler->Reset()){
|
||||
return_message.append("\tExecuted: Reset\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: Reset\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case evSetInputDelays :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetIDelays(0,n[0])){
|
||||
return_message.append("\tExecuted: SetInputDelays "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetInputDelays <delay>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case evSetDACValue :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
tmp_str[1] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[1].data());
|
||||
|
||||
if(tmp_str[0].length()>0&&tmp_str[1].length()>0&&feb_controler->SetDAC(tmp_str[0],n[0])){
|
||||
return_message.append("\tExecuted: SetDACValue "); return_message.append(tmp_str[0]+" "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetDACValue <dac_name> <value>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evGetDACValue :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
|
||||
if(tmp_str[0].length()>0&&feb_controler->GetDAC(tmp_str[0],ret_parameter)){
|
||||
return_message.append("\tExecuted: GetDACValue "); return_message.append(tmp_str[0]+" -> ");AddNumber(return_message,ret_parameter); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: GetDACValue <dac_name>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetDACVoltage :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
tmp_str[1] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[1].data());
|
||||
|
||||
if(tmp_str[0].length()>0&&tmp_str[1].length()>0&&feb_controler->SetDAC(tmp_str[0],n[0],1)){
|
||||
return_message.append("\tExecuted: SetDACVoltage "); return_message.append(tmp_str[0]+" "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetDACVoltage <dac_name> <voltage_mV>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evGetDACVoltage :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
|
||||
if(tmp_str[0].length()>0&&feb_controler->GetDAC(tmp_str[0],ret_parameter,1)){
|
||||
return_message.append("\tExecuted: GetDACVoltage "); return_message.append(tmp_str[0]+" -> ");AddNumber(return_message,ret_parameter); return_message.append(" mV\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: GetDACVoltage <dac_name>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetHighVoltage :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
v[0] = atof(tmp_str[0].data());
|
||||
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetHighVoltage(v[0])){
|
||||
return_message.append("\tExecuted: SetHighVoltage "); AddNumber(return_message,v[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetHighVoltage <voltage>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetTrimBits :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
if(feb_controler->LoadTrimbitFile()){
|
||||
/* if(1){*/
|
||||
/*tmp_str[0] = GetNextString(data);
|
||||
feb_controler->SetTrimbits(0,(unsigned char*)(tmp_str[0].c_str()));*/
|
||||
return_message.append("\tExecuted: SetTrimBits\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetTrimBits \n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetAllTrimBits :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
if(feb_controler->SaveAllTrimbitsTo(n[0])){
|
||||
/*feb_controler->SetTrimbits(0,(unsigned char*)(tmp_str[0].c_str()));*/
|
||||
/*if(1){*/
|
||||
return_message.append("\tExecuted: SetAllTrimBits\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetAllTrimBits \n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case evGetTrimBits :
|
||||
if(feb_controler->SaveTrimbitFile()){
|
||||
/*if(1){*/
|
||||
/*tmp_str[0] = GetNextString(data);
|
||||
feb_controler->GetTrimbits();*/
|
||||
return_message.append("\tExecuted: GetTrimBits\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: GetTrimBits \n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
// case evLoadTrimBitFile :
|
||||
|
||||
case evSetBitMode :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetDynamicRange(n[0])){
|
||||
return_message.append("\tExecuted: SetBitMode "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetBitMode <mode 4,8,16,32>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetPhotonEnergy :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetPhotonEnergy(n[0])){
|
||||
return_message.append("\tExecuted: SetPhotonEnergy "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetPhotonEnergy <energy eV>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
// case evSetPhotonEnergyCalibrationParameters :
|
||||
// case evActivateRateCorrection :
|
||||
// case evDeactivateRateCorrection :
|
||||
// case evSetRateCorrectionTau :
|
||||
|
||||
|
||||
case evSetReadoutSpeed :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetReadoutSpeed(n[0])){
|
||||
return_message.append("\tExecuted: SetReadoutSpeed "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetReadoutSpeed <speed 0-full 1-half 2-quarter 3-super_slow>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetReadoutMode :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetReadoutMode(n[0])){
|
||||
return_message.append("\tExecuted: SetReadoutMode "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetReadoutMode <mode 0->parallel,1->non-parallel,2-> safe_mode>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetNumberOfExposures :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetNExposures(n[0])){
|
||||
return_message.append("\tExecuted: SetNumberOfExposures "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetNumberOfExposures <n>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetExposureTime :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
v[0] = atof(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetExposureTime(v[0])){
|
||||
return_message.append("\tExecuted: SetExposureTime "); AddNumber(return_message,v[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetExposureTime <t_seconds>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetExposurePeriod :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
v[0] = atof(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetExposurePeriod(v[0])){
|
||||
return_message.append("\tExecuted: SetExposurePeriod "); AddNumber(return_message,v[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetExposurePeriod <t_seconds>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
// case evSetTriggerPolarityToPositive :
|
||||
// case evSetTriggerPolarityToNegative :
|
||||
case evSetTriggerMode :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetTriggerMode(n[0])){
|
||||
return_message.append("\tExecuted: SetTriggerMode "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetTriggerMode <n>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetExternalGating :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
tmp_str[1] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
n[1] = atoi(tmp_str[1].data());
|
||||
if(tmp_str[0].length()<1 || tmp_str[1].length()<1 || (n[0]!=0&&n[0]!=1) || (n[1]!=0&&n[1]!=1)){
|
||||
return_message.append("\tError executing: setexternalgating <enable> <polarity>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
feb_controler->SetExternalEnableMode(n[0],n[1]);
|
||||
ret_val = 0;
|
||||
break;
|
||||
|
||||
case evStartAcquisition :
|
||||
if(feb_controler->StartAcquisition()){
|
||||
return_message.append("\tExecuted: StartAcquisition\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: StartAcquisition\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evStopAcquisition :
|
||||
if(feb_controler->StopAcquisition()){
|
||||
return_message.append("\tExecuted: StopAcquisition\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: StopAcquisition\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case evIsDaqStillRunning :
|
||||
return_message.append("\tExecuted: evIsDaqStillRunning\n");
|
||||
ret_parameter = feb_controler->AcquisitionInProgress();
|
||||
ret_val = 0;
|
||||
break;
|
||||
|
||||
|
||||
case evWaitUntilDaqFinished :
|
||||
if(feb_controler->WaitForFinishedFlag()){
|
||||
return_message.append("\tExecuted: WaitUntilDaqFinished\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: WaitUntilDaqFinished\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case evExitServer :
|
||||
return_message.append("\tExiting Server ....\n");
|
||||
stop = 1;
|
||||
ret_val = -200;
|
||||
break;
|
||||
|
||||
|
||||
default :
|
||||
return_message.append("\tWarning command \"");
|
||||
return_message.append(cmd);
|
||||
return_message.append("\" not found.\n");
|
||||
return_message.append("\t\tValid commands: ");
|
||||
map<string, cmd_string>::iterator it = enum_map.begin();
|
||||
while(it!=enum_map.end()){
|
||||
return_message.append((it++)->first);
|
||||
return_message.append(" ");
|
||||
}
|
||||
|
||||
ret_val=-100;
|
||||
break;
|
||||
}
|
||||
|
||||
// return_message.append("\n");
|
||||
//AddNumber(return_message,ret_parameter,return_start_pos);
|
||||
AddNumber(return_message,ret_val,return_start_pos,1);
|
||||
AddNumber(return_message,ret_parameter,0,1);
|
||||
if(ret_val!=0) break;
|
||||
|
||||
cmd = GetNextString(data);
|
||||
}
|
||||
/*return_message.append("\n\n\n");*/
|
||||
|
||||
AddNumber(return_message,ret_val,0,1);
|
||||
cout<<return_message.c_str()<<"\t\t";
|
||||
cout<<"return: "<<ret_val<<endl;
|
||||
|
||||
if(!WriteNClose(return_message.c_str(),return_message.length())) return 0;
|
||||
}
|
||||
|
||||
|
||||
delete feb_controler;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
string LowerCase(string str){
|
||||
string s = str;
|
||||
string::iterator i = s.begin();
|
||||
while(i!=s.end()) *i=tolower(*(i++));
|
||||
return s;
|
||||
}
|
||||
|
||||
string GetNextString(string str,bool start_from_beginning){
|
||||
static string::size_type start_pos = 0;
|
||||
if(start_from_beginning) start_pos = 0;
|
||||
|
||||
while(start_pos != string::npos){
|
||||
string::size_type found = str.find_first_of(" ",start_pos);
|
||||
string sub = str.substr(start_pos,found-start_pos);
|
||||
|
||||
start_pos = found;
|
||||
if(start_pos != string::npos) start_pos+=1;
|
||||
|
||||
sub.erase(remove_if(sub.begin(),sub.end(), ::isspace ),sub.end());
|
||||
|
||||
if(sub.length()>0) return sub;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
void AddNumber(string& str, int n, int location, bool space_after){
|
||||
static char retval_st[100];
|
||||
if(space_after) sprintf(retval_st,"%d ",n);
|
||||
else sprintf(retval_st,"%d",n);
|
||||
|
||||
if(location<0) str.append(retval_st);
|
||||
else str.insert(location,retval_st);
|
||||
}
|
||||
|
||||
void AddNumber(string& str, float v, int location, bool space_after){
|
||||
static char retval_st[100];
|
||||
if(space_after) sprintf(retval_st,"%f ",v);
|
||||
else sprintf(retval_st,"%f",v);
|
||||
|
||||
if(location<0) str.append(retval_st);
|
||||
else str.insert(location,retval_st);
|
||||
}
|
||||
|
||||
|
||||
bool SetupListenSocket(unsigned short int port){
|
||||
server_list_s=0;
|
||||
server_conn_s=0;
|
||||
|
||||
if((server_list_s = socket(AF_INET, SOCK_STREAM, 0))<0) return 0;
|
||||
|
||||
struct sockaddr_in servaddr; /* socket address structure */
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
servaddr.sin_port = htons(port);
|
||||
|
||||
if(bind(server_list_s,(struct sockaddr *) &servaddr,sizeof(servaddr))<0) return 0;
|
||||
|
||||
if(listen(server_list_s,32) < 0){ // 1024 /* Backlog for listen() */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int AccpetConnectionAndWaitForData(char* buffer, int maxlength){
|
||||
if(server_list_s==0||maxlength<=0) return 0;
|
||||
|
||||
if((server_conn_s = accept(server_list_s,NULL,NULL))< 0) return 0;
|
||||
|
||||
int nread = read(server_conn_s,buffer,maxlength-1);
|
||||
|
||||
if(nread<0) return 0;
|
||||
|
||||
buffer[nread]='\0';
|
||||
return nread;
|
||||
}
|
||||
|
||||
bool WriteNClose(const char* buffer, int length){
|
||||
if(server_conn_s==0||length<=0) return 0;
|
||||
|
||||
int nsent = write(server_conn_s,buffer,length);
|
||||
if(close(server_conn_s)<0) return 0;
|
||||
|
||||
server_conn_s=0;
|
||||
return (nsent==length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
|
||||
//Class initially from Gerd and was called mmap_test.c
|
||||
//return reversed 1 means good, 0 means failed
|
||||
|
||||
|
||||
//#include <stdio.h>
|
||||
//#include <unistd.h>
|
||||
//#include <string.h>
|
||||
//#include <sys/mman.h>
|
||||
//#include <fcntl.h>
|
||||
|
||||
#include "HardwareIO.h"
|
||||
|
||||
xfs_u8 HardwareIO::xfs_in8(xfs_u32 InAddress)
|
||||
{
|
||||
/* read the contents of the I/O location and then synchronize the I/O
|
||||
* such that the I/O operation completes before proceeding on
|
||||
*/
|
||||
|
||||
xfs_u8 IoContents;
|
||||
__asm__ volatile ("eieio; lbz %0,0(%1)":"=r" (IoContents):"b"
|
||||
(InAddress));
|
||||
return IoContents;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
xfs_u16 HardwareIO::xfs_in16(xfs_u32 InAddress)
|
||||
{
|
||||
/* read the contents of the I/O location and then synchronize the I/O
|
||||
* such that the I/O operation completes before proceeding on
|
||||
*/
|
||||
|
||||
xfs_u16 IoContents;
|
||||
__asm__ volatile ("eieio; lhz %0,0(%1)":"=r" (IoContents):"b"
|
||||
(InAddress));
|
||||
return IoContents;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
xfs_u32 HardwareIO::xfs_in32(xfs_u32 InAddress)
|
||||
{
|
||||
/* read the contents of the I/O location and then synchronize the I/O
|
||||
* such that the I/O operation completes before proceeding on
|
||||
*/
|
||||
|
||||
xfs_u32 IoContents;
|
||||
__asm__ volatile ("eieio; lwz %0,0(%1)":"=r" (IoContents):"b"
|
||||
(InAddress));
|
||||
return IoContents;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void HardwareIO::xfs_out8(xfs_u32 OutAddress, xfs_u8 Value)
|
||||
{
|
||||
/* write the contents of the I/O location and then synchronize the I/O
|
||||
* such that the I/O operation completes before proceeding on
|
||||
*/
|
||||
|
||||
__asm__ volatile ("stb %0,0(%1); eieio"::"r" (Value), "b"(OutAddress));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void HardwareIO::xfs_out16(xfs_u32 OutAddress, xfs_u16 Value)
|
||||
{
|
||||
/* write the contents of the I/O location and then synchronize the I/O
|
||||
* such that the I/O operation completes before proceeding on
|
||||
*/
|
||||
|
||||
__asm__ volatile ("sth %0,0(%1); eieio"::"r" (Value), "b"(OutAddress));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void HardwareIO::xfs_out32(xfs_u32 OutAddress, xfs_u32 Value)
|
||||
{
|
||||
/* write the contents of the I/O location and then synchronize the I/O
|
||||
* such that the I/O operation completes before proceeding on
|
||||
*/
|
||||
|
||||
__asm__ volatile ("stw %0,0(%1); eieio"::"r" (Value), "b"(OutAddress));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,277 +0,0 @@
|
||||
|
||||
//Class initially from Gerd and was called mmap_test.c
|
||||
//return reversed 1 means good, 0 means failed
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
//#include <string.h>
|
||||
|
||||
|
||||
#include "HardwareMMappingDefs.h"
|
||||
|
||||
#include "LocalLinkInterface.h"
|
||||
|
||||
|
||||
|
||||
LocalLinkInterface::LocalLinkInterface(unsigned int ll_fifo_badr){
|
||||
// printf("\n v 1 \n");
|
||||
printf("Initialize PLB LL FIFOs\n");
|
||||
ll_fifo_base=0;
|
||||
ll_fifo_ctrl_reg=0;
|
||||
if(Init(ll_fifo_badr)){
|
||||
Reset();
|
||||
printf("\tFIFO Status : 0x%08x\n",StatusVector());
|
||||
}else printf("\tError LocalLink Mappping : 0x%08x\n",ll_fifo_badr);
|
||||
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
LocalLinkInterface::~LocalLinkInterface(){};
|
||||
|
||||
LocalLinkInterface::LocalLinkInterface(){
|
||||
printf("Initialize new memory\n");
|
||||
}
|
||||
|
||||
int LocalLinkInterface::InitNewMemory (unsigned int addr, int ifg){
|
||||
unsigned int CSP0BASE;
|
||||
int fd;
|
||||
|
||||
/*fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||
if (fd == -1) {
|
||||
printf("\nCan't find /dev/mem!\n");
|
||||
return 0;
|
||||
}
|
||||
printf("/dev/mem opened\n");
|
||||
|
||||
|
||||
CSP0BASE = (u_int32_t)mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, addr);
|
||||
if (CSP0BASE == (u_int32_t)MAP_FAILED) {
|
||||
printf("\nCan't map memmory area!!\n");
|
||||
return 0;
|
||||
}
|
||||
printf("CSP0 mapped\n");
|
||||
|
||||
|
||||
volatile u_int8_t *ptr1;
|
||||
|
||||
ptr1=(u_int8_t*)(CSP0BASE);
|
||||
|
||||
printf("pointer val=%x\n",(void*)ptr1);
|
||||
|
||||
printf("ifg_control=%02x\n",*ptr1);
|
||||
|
||||
*ptr1=ifg;
|
||||
|
||||
printf("ifg_control new=%02x\n",*ptr1);
|
||||
|
||||
close(fd);
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool LocalLinkInterface::Init(unsigned int ll_fifo_badr){
|
||||
int fd;
|
||||
void *plb_ll_fifo_ptr;
|
||||
|
||||
if ((fd=open("/dev/mem", O_RDWR)) < 0){
|
||||
fprintf(stderr, "Could not open /dev/mem\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
plb_ll_fifo_ptr = mmap(0, getpagesize(), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, ll_fifo_badr);
|
||||
close(fd);
|
||||
|
||||
if (plb_ll_fifo_ptr == MAP_FAILED){
|
||||
perror ("mmap");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ll_fifo_base = (xfs_u32) plb_ll_fifo_ptr;
|
||||
ll_fifo_ctrl_reg = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool LocalLinkInterface::Reset(){
|
||||
return Reset(PLB_LL_FIFO_CTRL_RESET_STD);
|
||||
}
|
||||
|
||||
bool LocalLinkInterface::Reset(unsigned int rst_mask){
|
||||
ll_fifo_ctrl_reg |= rst_mask;
|
||||
printf("\tCTRL Register bits: 0x%08x\n",ll_fifo_ctrl_reg);
|
||||
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll_fifo_ctrl_reg);
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll_fifo_ctrl_reg);
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll_fifo_ctrl_reg);
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll_fifo_ctrl_reg);
|
||||
|
||||
ll_fifo_ctrl_reg &= (~rst_mask);
|
||||
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll_fifo_ctrl_reg);
|
||||
// printf("FIFO CTRL Address: 0x%08x\n FIFO CTRL Register: 0x%08x\n",PLB_LL_FIFO_REG_CTRL,plb_ll_fifo[PLB_LL_FIFO_REG_CTRL]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int LocalLinkInterface::StatusVector(){
|
||||
return xfs_in32(ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
|
||||
}
|
||||
|
||||
int LocalLinkInterface::Write(unsigned int buffer_len, void *buffer){
|
||||
// note: buffer must be word (4 byte) aligned
|
||||
// frame_len in byte
|
||||
int vacancy=0;
|
||||
int i;
|
||||
int words_send = 0;
|
||||
int last_word;
|
||||
unsigned int *word_ptr;
|
||||
unsigned int fifo_ctrl;
|
||||
xfs_u32 status;
|
||||
|
||||
if (buffer_len < 1) return -1;
|
||||
|
||||
last_word = (buffer_len-1)/4;
|
||||
word_ptr = (unsigned int *)buffer;
|
||||
|
||||
while (words_send <= last_word)
|
||||
{
|
||||
while (!vacancy)//wait for Fifo to be empty again
|
||||
{
|
||||
status = xfs_in32(ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
|
||||
if((status & PLB_LL_FIFO_STATUS_ALMOSTFULL) == 0) vacancy = 1;
|
||||
}
|
||||
|
||||
//Just to know: #define PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS 100
|
||||
for (i=0; ((i<PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS) && (words_send <= last_word)); i++)
|
||||
{
|
||||
fifo_ctrl = 0;
|
||||
if (words_send == 0)
|
||||
{
|
||||
fifo_ctrl = PLB_LL_FIFO_CTRL_LL_SOF;//announce the start of file
|
||||
}
|
||||
|
||||
if (words_send == last_word)
|
||||
{
|
||||
fifo_ctrl |= (PLB_LL_FIFO_CTRL_LL_EOF | (( (buffer_len-1)<<PLB_LL_FIFO_CTRL_LL_REM_SHIFT) & PLB_LL_FIFO_CTRL_LL_REM) );
|
||||
}
|
||||
ctrl_reg_write_mask(PLB_LL_FIFO_CTRL_LL_MASK,fifo_ctrl);
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_FIFO,word_ptr[words_send++]);
|
||||
}
|
||||
}
|
||||
return buffer_len;
|
||||
}
|
||||
|
||||
|
||||
int LocalLinkInterface::Read(unsigned int buffer_len, void *buffer){
|
||||
static unsigned int buffer_ptr = 0;
|
||||
// note: buffer must be word (4 byte) aligned
|
||||
// frame_len in byte
|
||||
int len;
|
||||
unsigned int *word_ptr;
|
||||
unsigned int status;
|
||||
volatile unsigned int fifo_val;
|
||||
int sof = 0;
|
||||
|
||||
word_ptr = (unsigned int *)buffer;
|
||||
do
|
||||
{
|
||||
status = xfs_in32(ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
|
||||
|
||||
if (!(status & PLB_LL_FIFO_STATUS_EMPTY))
|
||||
{
|
||||
if (status & PLB_LL_FIFO_STATUS_LL_SOF)
|
||||
{
|
||||
if (buffer_ptr)
|
||||
{
|
||||
buffer_ptr = 0;
|
||||
return -1; // buffer overflow
|
||||
}
|
||||
// printf(">>>> SOF\n\r");
|
||||
buffer_ptr = 0;
|
||||
sof = 1;
|
||||
}
|
||||
|
||||
fifo_val = xfs_in32(ll_fifo_base+4*PLB_LL_FIFO_REG_FIFO); //read from fifo
|
||||
|
||||
if ((buffer_ptr > 0) || sof)
|
||||
{
|
||||
if ( (buffer_len >> 2) > buffer_ptr)
|
||||
{
|
||||
word_ptr[buffer_ptr++] = fifo_val; //write to buffer
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer_ptr = 0;
|
||||
return -2; // buffer overflow
|
||||
}
|
||||
|
||||
if (status & PLB_LL_FIFO_STATUS_LL_EOF)
|
||||
{
|
||||
len = (buffer_ptr << 2) -3 + ( (status & PLB_LL_FIFO_STATUS_LL_REM)>>PLB_LL_FIFO_STATUS_LL_REM_SHIFT );
|
||||
// printf(">>>>status=0x%08x EOF len = %d \n\r\n\r",status, len);
|
||||
buffer_ptr = 0;
|
||||
return len;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
while(!(status & PLB_LL_FIFO_STATUS_EMPTY));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool LocalLinkInterface::ctrl_reg_write_mask(unsigned int mask, unsigned int val){
|
||||
// printf("Fifo CTRL Reg(1): 0x%08x\n",plb_ll_fifo_ctrl_reg);
|
||||
ll_fifo_ctrl_reg &= (~mask);
|
||||
//printf("Fifo CTRL Reg(2): 0x%08x\n",plb_ll_fifo_ctrl_reg);
|
||||
ll_fifo_ctrl_reg |= ( mask & val);
|
||||
// printf("Fifo CTRL Reg: 0x%08x\n",plb_ll_fifo_ctrl_reg);
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll_fifo_ctrl_reg);
|
||||
// printf("Fifo STAT Reg: 0x%08x\n", plb_ll_fifo[PLB_LL_FIFO_REG_STATUS]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int LocalLinkInterface::Test(unsigned int buffer_len, void *buffer){
|
||||
|
||||
int len;
|
||||
unsigned int rec_buff_len = 4096;
|
||||
unsigned int rec_buffer[4097];
|
||||
|
||||
|
||||
Write(buffer_len,buffer);
|
||||
usleep(10000);
|
||||
|
||||
do{
|
||||
len = Read(rec_buff_len,rec_buffer);
|
||||
printf("receive length: %i\n",len);
|
||||
|
||||
if (len > 0){
|
||||
rec_buffer[len]=0;
|
||||
printf((char*) rec_buffer);
|
||||
printf("\n");
|
||||
}
|
||||
} while(len > 0);
|
||||
|
||||
printf("\n\n\n\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void LocalLinkInterface::llfifo_print_frame(unsigned char* fbuff, int len){
|
||||
printf("\n\r----Frame of len : %d Byte\n\r",len);
|
||||
for(int i=0;i<len;i++){
|
||||
printf("0x%02x ",fbuff[i] );
|
||||
if ((i&0xf) == 0x7) printf(" ");
|
||||
if ((i&0xf) == 0xf) printf("\n\r");
|
||||
}
|
||||
printf("\n\r");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xparameters.h"
|
||||
|
||||
#include "LocalLinkInterface.h"
|
||||
|
||||
int main(){
|
||||
|
||||
char s[2000];
|
||||
sprintf(s,"papamama");
|
||||
|
||||
LocalLinkInterface* l0 = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR);
|
||||
l0->Test(8,s);
|
||||
LocalLinkInterface* l1 = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_LEFT_BASEADDR);
|
||||
l1->Test(8,s);
|
||||
LocalLinkInterface* l2 = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR);
|
||||
l2->Test(8,s);
|
||||
LocalLinkInterface* l3 = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_RIGHT_BASEADDR);
|
||||
l3->Test(8,s);
|
||||
|
||||
delete l0;
|
||||
delete l1;
|
||||
delete l2;
|
||||
delete l3;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
CC = powerpc-4xx-softfloat-gcc
|
||||
CCX = powerpc-4xx-softfloat-g++
|
||||
BLACKFIN_CC = bfin-uclinux-gcc
|
||||
CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE #-DVIRTUAL -DPCCOMPILE -DMARTIN
|
||||
LDLIBS += -lm -lstdc++
|
||||
@@ -10,13 +9,10 @@ INSTMODE = 0777
|
||||
|
||||
|
||||
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c FebControl.c Beb.c HardwareIO.c LocalLinkInterface.c Feb.c FebInterface.c
|
||||
#SRC_CLNT2 = FebServer.cxx FebControl.cxx FebInterface.cxx LocalLinkInterface.cxx HardwareIO.cxx
|
||||
#SRC_CLNT3 = BebServer.cxx Beb.cxx LocalLinkInterface.cxx HardwareIO.cxx
|
||||
|
||||
OBJS = $(SRC_CLNT:.c=.o)
|
||||
|
||||
|
||||
all: clean $(PROGS) hv9m_blackfin_server #feb_debug beb_debug
|
||||
all: clean $(PROGS) #hv9m_blackfin_server
|
||||
|
||||
|
||||
boot: $(OBJS)
|
||||
@@ -27,14 +23,7 @@ $(PROGS):
|
||||
$(CC) -o $@ $(SRC_CLNT) $(CFLAGS) $(LDLIBS)
|
||||
mv $(PROGS) $(DESTDIR)
|
||||
|
||||
feb_debug:$(SRC_CLNT2)
|
||||
$(CCX) -o feb_debug $(SRC_CLNT2) -I.
|
||||
mv feb_debug $(DESTDIR)
|
||||
|
||||
beb_debug:$(SRC_CLNT3)
|
||||
$(CCX) -o beb_debug $(SRC_CLNT3) -I.
|
||||
mv beb_debug $(DESTDIR)
|
||||
|
||||
|
||||
hv9m_blackfin_server:9mhvserial_bf.c
|
||||
$(BLACKFIN_CC) -o hv9m_blackfin_server 9mhvserial_bf.c -Wall #-DVERBOSE
|
||||
mv hv9m_blackfin_server $(DESTDIR)
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xparameters.h"
|
||||
|
||||
#include "Feb.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
|
||||
cout<<"\n\n\n\n\n\n\n\n\n\n"<<endl;
|
||||
|
||||
|
||||
char s[2000];
|
||||
sprintf(s,"papamama");
|
||||
|
||||
Feb* feb = new Feb();
|
||||
|
||||
unsigned int v=22;
|
||||
feb->ReadRegister(0,0,v);
|
||||
feb->ReadRegister(0,0xffffffff,v);
|
||||
cout<<endl<<endl;
|
||||
feb->ReadRegister(1,0,v);
|
||||
feb->ReadRegister(1,0xffffffff,v);
|
||||
|
||||
delete feb;
|
||||
|
||||
return 1;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,19 +0,0 @@
|
||||
|
||||
echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
|
||||
|
||||
. /opt/eldk-5.1/powerpc-4xx-softfloat/environment-setup-ppc440-linux
|
||||
|
||||
#powerpc-4xx-softfloat-g++ -Wall -o test Test.cxx HardwareIO.cxx LocalLinkInterface.cxx Feb.cxx -I .
|
||||
#powerpc-4xx-softfloat-g++ -Wall -o hardware_interface_test HardwareInterfaceTest.cxx HardwareInterface.cxx HardwareMMapping.cxx -I .
|
||||
|
||||
|
||||
#powerpc-4xx-softfloat-g++ -Wall -o eiger_test EigerTest.cxx Eiger.cxx HardwareIO.cxx LocalLinkInterface.cxx Feb.cxx -I .
|
||||
|
||||
powerpc-4xx-softfloat-g++ -Wall -o feb_debug FebServer.cxx FebControl.cxx FebInterface.cxx LocalLinkInterface.cxx HardwareIO.cxx -I .
|
||||
|
||||
powerpc-4xx-softfloat-g++ -Wall -o beb_debug BebServer.cxx Beb.cxx LocalLinkInterface.cxx HardwareIO.cxx -I .
|
||||
|
||||
|
||||
cp eiger_test rootfs_executables/.
|
||||
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
|
||||
# documentation are documented, even if no documentation was available.
|
||||
# Private class members and static file members will be hidden unless
|
||||
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
|
||||
|
||||
EXTRACT_ALL = YES
|
||||
|
||||
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
|
||||
# will be included in the documentation.
|
||||
|
||||
EXTRACT_PRIVATE = NO
|
||||
|
||||
|
||||
|
||||
# If the EXTRACT_STATIC tag is set to YES all static members of a file
|
||||
# will be included in the documentation.
|
||||
|
||||
EXTRACT_STATIC = YES
|
||||
|
||||
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
|
||||
# defined locally in source files will be included in the documentation.
|
||||
# If set to NO only classes defined in header files are included.
|
||||
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
|
||||
# This flag is only useful for Objective-C code. When set to YES local
|
||||
# methods, which are defined in the implementation section but not in
|
||||
# the interface are included in the documentation.
|
||||
# If set to NO (the default) only methods in the interface are included.
|
||||
|
||||
EXTRACT_LOCAL_METHODS = YES
|
||||
|
||||
# If this flag is set to YES, the members of anonymous namespaces will be
|
||||
# extracted and appear in the documentation as a namespace called
|
||||
# 'anonymous_namespace{file}', where file will be replaced with the base
|
||||
# name of the file that contains the anonymous namespace. By default
|
||||
# anonymous namespace are hidden.
|
||||
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
|
||||
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
|
||||
# undocumented members of documented classes, files or namespaces.
|
||||
# If set to NO (the default) these members will be included in the
|
||||
# various overviews, but no documentation section is generated.
|
||||
# This option has no effect if EXTRACT_ALL is enabled.
|
||||
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
|
||||
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
|
||||
# undocumented classes that are normally visible in the class hierarchy.
|
||||
# If set to NO (the default) these classes will be included in the various
|
||||
# overviews. This option has no effect if EXTRACT_ALL is enabled.
|
||||
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
|
||||
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
|
||||
# friend (class|struct|union) declarations.
|
||||
# If set to NO (the default) these declarations will be included in the
|
||||
# documentation.
|
||||
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
|
||||
INTERNAL_DOCS = NO
|
||||
|
||||
SHOW_INCLUDE_FILES = NO
|
||||
|
||||
SHOW_FILES = NO
|
||||
|
||||
SHOW_NAMESPACES = NO
|
||||
|
||||
COMPACT_LATEX = YES
|
||||
|
||||
PAPER_TYPE = a4
|
||||
|
||||
PDF_HYPERLINKS = YES
|
||||
|
||||
USE_PDFLATEX = YES
|
||||
|
||||
LATEX_HIDE_INDICES = YES
|
||||
|
||||
PREDEFINED = __cplusplus
|
||||
|
||||
HAVE_DOT = YES
|
||||
CALL_GRAPH = YES
|
||||
CALLER_GRAPH = YES
|
||||
|
||||
|
||||
INPUT = Beb.h Eiger.h FebControl.h FebInterface.h gitInfoEiger.h HardwareIO.h LocalLinkInterface.h sls_detector_funcs.h slsDetectorServer_defs.h sls_receiver_defs.h xfs_types.h communication_funcs.h EigerRegisterDefs.h Feb.h FebRegisterDefs.h gitInfoEigerTmp.h HardwareMMappingDefs.h sls_detector_defs.h slsDetectorFunctionList.h slsDetectorServer_funcs.h sls_receiver_funcs.h xparameters.h Beb.cxx BebServer.cxx Eiger.cxx EigerTest.cxx FebControl.cxx Feb.cxx FebInterface.cxx FebServer.cxx HardwareIO.cxx LocalLinkInterface.cxx LocalLinkTest.cxx Test.cxx
|
||||
|
||||
|
||||
|
||||
|
||||
OUTPUT_DIRECTORY = docs
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
|
||||
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git/eigerDetectorServer
|
||||
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
|
||||
Repsitory UUID: 230d6b36e9852214f4ba5ae7c92647f35000b24d
|
||||
Revision: 263
|
||||
Branch: developer
|
||||
Repsitory UUID: 3618c87c5cd000fff7799ddd8cd07a4162d9fdec
|
||||
Revision: 276
|
||||
Branch: 2.3
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 1313
|
||||
Last Changed Date: 2016-11-30 10:36:34 +0100
|
||||
Last Changed Rev: 1340
|
||||
Last Changed Date: 2017-03-23 13:46:02 +0100
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//#define SVNPATH ""
|
||||
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git/eigerDetectorServer"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID "230d6b36e9852214f4ba5ae7c92647f35000b24d"
|
||||
//#define SVNREV 0x1313
|
||||
#define SVNREPUUID "3618c87c5cd000fff7799ddd8cd07a4162d9fdec"
|
||||
//#define SVNREV 0x1340
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "Dhanya_Maliakal"
|
||||
#define SVNREV 0x1313
|
||||
#define SVNDATE 0x20161130
|
||||
#define SVNREV 0x1340
|
||||
#define SVNDATE 0x20170323
|
||||
//
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
mv bin/eigerDetectorServer bin/$2
|
||||
cp bin/$2 /tftpboot
|
||||
git rm -f bin/$1
|
||||
git add bin/$2
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
|
||||
|
||||
#detector setup
|
||||
#add_module module_number base_address_top (for half module)
|
||||
#add_module module_number base_address_top base_address_bottom (for full module)
|
||||
add_half_module 17 0
|
||||
#add_half_module 17 1 for bottom
|
||||
#add_module 18 10 12
|
||||
#add_module 2 13 15
|
||||
#add_module 1 120 22
|
||||
|
||||
|
||||
#default setting
|
||||
photon_energy 8000
|
||||
dynamic_range 16
|
||||
readout_speed 1 #(0-full,1-half,2-quarter and 3-superslow)
|
||||
readout_mode 0 #(0-parallel,1-non_parallel,2-safe_mode)
|
||||
|
||||
|
||||
#default dacs
|
||||
SvP 0
|
||||
Vtr 1280
|
||||
Vrf 1550
|
||||
Vrs 700
|
||||
SvN 2000
|
||||
Vtgstv 1278
|
||||
Vcmp_ll 750
|
||||
Vcmp_lr 750
|
||||
cal 2000
|
||||
Vcmp_rl 750
|
||||
rxb_rb 600
|
||||
rxb_lb 600
|
||||
Vcmp_rr 750
|
||||
Vcp 100
|
||||
Vcn 1000
|
||||
Vis 775
|
||||
|
||||
#default high_voltage
|
||||
high_voltage 152
|
||||
|
||||
#default iodelays
|
||||
iodelay 675
|
||||
|
||||
#newgoodiodelay 643
|
||||
#halfspeed_add_about 32
|
||||
#goodiodelay 1467
|
||||
#goodiodelay 1550
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
|
||||
#detector setup
|
||||
#add_beb base_address mac_1GBE ip_1GBE mac_10GBE ip_10GBE
|
||||
|
||||
add_beb 26 0 00:50:c2:46:d9:34 129.129.205.78 00:50:c2:46:d9:35 10.0.26.1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ int *detectorChips=NULL;
|
||||
int *detectorChans=NULL;
|
||||
dacs_t *detectorDacs=NULL;
|
||||
dacs_t *detectorAdcs=NULL;
|
||||
int* detectorGain = NULL;
|
||||
int* detectorOffset = NULL;
|
||||
|
||||
int eiger_highvoltage = 0;
|
||||
int eiger_iodelay = 0;
|
||||
@@ -101,16 +99,12 @@ int initDetector(){
|
||||
detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int));
|
||||
detectorDacs=malloc(n*NDAC*sizeof(dacs_t));
|
||||
detectorAdcs=malloc(n*NADC*sizeof(dacs_t));
|
||||
detectorGain=malloc(n*NGAIN*sizeof(int));
|
||||
detectorOffset=malloc(n*NOFFSET*sizeof(int));
|
||||
#ifdef VERBOSE
|
||||
printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n);
|
||||
printf("chips from 0x%x to 0x%x\n",detectorChips, detectorChips+n*NCHIP);
|
||||
printf("chans from 0x%x to 0x%x\n",detectorChans, detectorChans+n*NCHIP*NCHAN);
|
||||
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);
|
||||
printf("gains from 0x%x to 0x%x\n",detectorGain, detectorGain+n*NGAIN);
|
||||
printf("offsets from 0x%x to 0x%x\n",detectorOffset, detectorOffset+n*NOFFSET);
|
||||
#endif
|
||||
for (imod=0; imod<n; imod++) {
|
||||
(detectorModules+imod)->dacs=detectorDacs+imod*NDAC;
|
||||
@@ -125,19 +119,9 @@ int initDetector(){
|
||||
(detectorModules+imod)->gain=0;
|
||||
(detectorModules+imod)->offset=0;
|
||||
(detectorModules+imod)->reg=0;
|
||||
/* initialize registers, dacs, retrieve sn, adc values etc */
|
||||
}
|
||||
for(i=0;i<NGAIN;i++)
|
||||
detectorGain[i] = default_gain_values[(int)STANDARD];
|
||||
for(i=0;i<NOFFSET;i++)
|
||||
detectorOffset[i] = default_offset_values[(int)STANDARD];
|
||||
thisSettings = UNINITIALIZED;
|
||||
/*sChan=noneSelected;
|
||||
sChip=noneSelected;
|
||||
sMod=noneSelected;
|
||||
sDac=noneSelected;
|
||||
sAdc=noneSelected;
|
||||
*/
|
||||
|
||||
|
||||
//Feb and Beb Initializations
|
||||
getModuleConfiguration();
|
||||
@@ -617,9 +601,10 @@ int64_t getCurrentTau(){
|
||||
|
||||
void setDefaultSettingsTau_in_nsec(int t){
|
||||
default_tau_from_file = t;
|
||||
printf("Default tau set to %d\n",default_tau_from_file);
|
||||
}
|
||||
|
||||
int setModule(sls_detector_module myMod, int* gain, int* offset,int* delay){
|
||||
int setModule(sls_detector_module myMod, int delay){
|
||||
int retval[2];
|
||||
int i;
|
||||
|
||||
@@ -627,25 +612,10 @@ int setModule(sls_detector_module myMod, int* gain, int* offset,int* delay){
|
||||
printf("Setting module with settings %d\n",myMod.reg);
|
||||
//#endif
|
||||
|
||||
//set the settings variable
|
||||
setSettings( (enum detectorSettings)myMod.reg,-1);
|
||||
|
||||
//set the gains and offset variables locally
|
||||
for(i=0;i<NGAIN;i++){
|
||||
if(gain[i]>=0){
|
||||
detectorGain[i] = gain[i];
|
||||
printf("gain[%d]:%d\n",i,detectorGain[i]);
|
||||
}else cprintf(RED,"gain not changed\n");
|
||||
}
|
||||
for(i=0;i<NOFFSET;i++){
|
||||
if(offset[i]>=0){
|
||||
detectorOffset[i] = offset[i];
|
||||
printf("offset[%d]:%d\n",i,detectorOffset[i]);
|
||||
}else cprintf(RED,"offset not changed\n");
|
||||
}
|
||||
|
||||
if(setIODelay(*delay, -1)!= (*delay)){
|
||||
cprintf(RED,"could not set iodelay %d\n",*delay);
|
||||
if(setIODelay(delay, -1)!= delay){
|
||||
cprintf(RED,"could not set iodelay %d\n",delay);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -657,46 +627,44 @@ int setModule(sls_detector_module myMod, int* gain, int* offset,int* delay){
|
||||
for(i=0;i<myMod.ndac;i++)
|
||||
setDAC((enum detDacIndex)i,myMod.dacs[i],myMod.module,0,retval);
|
||||
|
||||
//includ gap pixels
|
||||
unsigned int tt[263680];
|
||||
int iy,ichip,ix,ip=0,ich=0;
|
||||
for(iy=0;iy<256;iy++) {
|
||||
for (ichip=0; ichip<4; ichip++) {
|
||||
for(ix=0;ix<256;ix++) {
|
||||
tt[ip++]=myMod.chanregs[ich++];
|
||||
}
|
||||
if (ichip<3) {
|
||||
tt[ip++]=0;
|
||||
tt[ip++]=0;
|
||||
if(myMod.nchan==0 && myMod.nchip == 0)
|
||||
cprintf(BLUE,"Setting module without trimbits\n");
|
||||
else{
|
||||
cprintf(GREEN,"Setting module with trimbits\n");
|
||||
//includ gap pixels
|
||||
unsigned int tt[263680];
|
||||
int iy,ichip,ix,ip=0,ich=0;
|
||||
for(iy=0;iy<256;iy++) {
|
||||
for (ichip=0; ichip<4; ichip++) {
|
||||
for(ix=0;ix<256;ix++) {
|
||||
tt[ip++]=myMod.chanregs[ich++];
|
||||
}
|
||||
if (ichip<3) {
|
||||
tt[ip++]=0;
|
||||
tt[ip++]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//set trimbits
|
||||
if(!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(),tt)){
|
||||
cprintf(BG_RED,"Could not set trimbits\n");
|
||||
return FAIL;
|
||||
//set trimbits
|
||||
if(!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(),tt)){
|
||||
cprintf(BG_RED,"Could not set trimbits\n");
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return thisSettings;
|
||||
}
|
||||
|
||||
|
||||
int getModule(sls_detector_module *myMod, int* gain, int* offset){
|
||||
int getModule(sls_detector_module *myMod){
|
||||
int i;
|
||||
int retval[2];
|
||||
//printf("get gainval[0]:%d\n",detectorGain[0]);
|
||||
|
||||
//dacs
|
||||
for(i=0;i<NDAC;i++)
|
||||
setDAC((enum detDacIndex)i,-1,-1,0,retval);
|
||||
|
||||
//gains, offsets
|
||||
for(i=0;i<NGAIN;i++)
|
||||
gain[i] = detectorGain[i];
|
||||
for(i=0;i<NOFFSET;i++)
|
||||
offset[i] = detectorOffset[i];
|
||||
|
||||
//trimbits
|
||||
unsigned int* tt;
|
||||
tt = Feb_Control_GetTrimbits();
|
||||
@@ -736,38 +704,8 @@ int getThresholdEnergy(int imod){
|
||||
|
||||
int setThresholdEnergy(int ev, int imod){
|
||||
printf(" Setting threshold energy:%d\n",ev);
|
||||
int retval[2],i;
|
||||
int thrvalue[NGAIN];
|
||||
int average=0;
|
||||
if(ev >= 0) {
|
||||
|
||||
enum detDacIndex ind[NGAIN]={VCMP_LL,VCMP_LR,VCMP_RL, VCMP_RR};
|
||||
const char* vcmp[4]={"vcmp_ll","vcmp_lr","vcmp_rl","vcmp_rr"};
|
||||
int valid=0;
|
||||
|
||||
//calculate thrvalues for dacs
|
||||
for(i=0;i<NGAIN;i++){
|
||||
|
||||
thrvalue[i] = (int) (( ((double)detectorGain[i]/1000) * (-1) * ((double)ev/1000)) + ((double)detectorOffset[i]/1000));
|
||||
printf("detectorGain[i]:%d detectorOffset[i]:%d thrvalue[i]:%d\n",detectorGain[i],detectorOffset[i],thrvalue[i]);
|
||||
//put limits (VCMP SHOUDL ALWAYS BE BETWEEN 0 AND 2000
|
||||
|
||||
//setdacs
|
||||
if(thrvalue[i]>=0 && thrvalue[i]<2001)valid++;
|
||||
}//ngains
|
||||
|
||||
if( valid == NGAIN){
|
||||
eiger_photonenergy = ev;
|
||||
for(i=0;i<NGAIN;i++) {
|
||||
average+= thrvalue[i];
|
||||
setDAC(ind[i],thrvalue[i],-1,0,retval);
|
||||
if(retval[0] != thrvalue[i]) cprintf(BG_RED,"Failed to set %s to %d, got %d\n",vcmp[i], thrvalue[i],retval[0]);
|
||||
}
|
||||
average=(int) ((float)average/4.+0.5);
|
||||
setDAC(VCP,average,-1,0,retval);
|
||||
if(retval[0] != average) cprintf(BG_RED,"Failed to set VCP to %d, got %d\n",average, retval[0]);
|
||||
}
|
||||
}
|
||||
if(ev >= 0)
|
||||
eiger_photonenergy = ev;
|
||||
return getThresholdEnergy(imod);
|
||||
}
|
||||
|
||||
@@ -776,6 +714,7 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
|
||||
return thisSettings;
|
||||
}if(sett != GET_SETTINGS)
|
||||
thisSettings = sett;
|
||||
printf(" Settings: %d\n", thisSettings);
|
||||
return thisSettings;
|
||||
}
|
||||
|
||||
@@ -1192,11 +1131,13 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod){
|
||||
|
||||
destMod->serialnumber=srcMod->serialnumber;
|
||||
}
|
||||
if ((srcMod->nchip)>(destMod->nchip)) {
|
||||
//no trimbit feature
|
||||
if (destMod->nchip && ((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)) {
|
||||
//no trimbit feature
|
||||
if (destMod->nchan && ((srcMod->nchan)>(destMod->nchan))) {
|
||||
printf("Number of channels of source is larger than number of channels of destination\n");
|
||||
return FAIL;
|
||||
}
|
||||
@@ -1230,14 +1171,21 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod){
|
||||
if (srcMod->offset>=0)
|
||||
destMod->offset=srcMod->offset;
|
||||
|
||||
for (ichip=0; ichip<(srcMod->nchip); ichip++) {
|
||||
if (*((srcMod->chipregs)+ichip)>=0)
|
||||
*((destMod->chipregs)+ichip)=*((srcMod->chipregs)+ichip);
|
||||
}
|
||||
for (ichan=0; ichan<(srcMod->nchan); ichan++) {
|
||||
if (*((srcMod->chanregs)+ichan)>=0)
|
||||
*((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan);
|
||||
if((destMod->nchip!=0) || (destMod->nchan!=0)) {
|
||||
for (ichip=0; ichip<(srcMod->nchip); ichip++) {
|
||||
if (*((srcMod->chipregs)+ichip)>=0)
|
||||
*((destMod->chipregs)+ichip)=*((srcMod->chipregs)+ichip);
|
||||
}
|
||||
for (ichan=0; ichan<(srcMod->nchan); ichan++) {
|
||||
if (*((srcMod->chanregs)+ichan)>=0)
|
||||
*((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan);
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
printf("Not Copying trimbits\n");
|
||||
#endif
|
||||
|
||||
|
||||
for (idac=0; idac<(srcMod->ndac); idac++) {
|
||||
if (*((srcMod->dacs)+idac)>=0)
|
||||
*((destMod->dacs)+idac)=*((srcMod->dacs)+idac);
|
||||
@@ -1335,9 +1283,12 @@ enum synchronizationMode setSynchronization(enum synchronizationMode arg){
|
||||
return NO_SYNCHRONIZATION;
|
||||
}
|
||||
|
||||
void setAllTrimbits(int val){
|
||||
int setAllTrimbits(int val){
|
||||
int ichan;
|
||||
if(Feb_Control_SaveAllTrimbitsTo(val)){
|
||||
if(!Feb_Control_SaveAllTrimbitsTo(val)){
|
||||
cprintf(RED,"error in setting all trimbits to value\n");
|
||||
return FAIL;
|
||||
}else{
|
||||
#ifdef VERBOSE
|
||||
printf("Copying register %x value %d\n",destMod->reg,val);
|
||||
#endif
|
||||
@@ -1346,7 +1297,8 @@ void setAllTrimbits(int val){
|
||||
*((detectorModules->chanregs)+ichan)=val;
|
||||
}
|
||||
}
|
||||
}else printf("error in setting all trimbits to value\n");
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getAllTrimbits(){
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#define NCHIP 4
|
||||
#define NDAC 16
|
||||
#define NADC 0
|
||||
#define NGAIN 4
|
||||
#define NOFFSET 4
|
||||
#define NGAIN 0
|
||||
#define NOFFSET 0
|
||||
|
||||
#define NMAXMODX 1
|
||||
#define NMAXMODY 1
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware
|
||||
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: 230d6b36e9852214f4ba5ae7c92647f35000b24d
|
||||
Revision: 1313
|
||||
Branch: developer
|
||||
Repsitory UUID: 41acb4c1ab89fe85b049c329adb539c3ad5b107a
|
||||
Revision: 1350
|
||||
Branch: 2.3.2
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 1313
|
||||
Last Changed Date: 2016-11-30 10:36:34 +0100
|
||||
Last Changed Rev: 1350
|
||||
Last Changed Date: 2017-04-19 10:17:30 +0200
|
||||
|
||||
@@ -1139,46 +1139,59 @@ int multiSlsDetector::getThresholdEnergy(int pos) {
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings isettings) {
|
||||
int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings isettings, int tb) {
|
||||
|
||||
int i, posmin, posmax;
|
||||
int ret1=-100, ret;
|
||||
int posmin, posmax;
|
||||
int ret=-100;
|
||||
if (pos<0) {
|
||||
posmin=0;
|
||||
posmax=thisMultiDetector->numberOfDetectors;
|
||||
} else {
|
||||
posmin=pos;
|
||||
posmax=pos+1;
|
||||
}
|
||||
|
||||
if (pos<0) {
|
||||
posmin=0;
|
||||
posmax=thisMultiDetector->numberOfDetectors;
|
||||
} else {
|
||||
posmin=pos;
|
||||
posmax=pos+1;
|
||||
}
|
||||
|
||||
for (i=posmin; i<posmax; i++) {
|
||||
if (detectors[i]) {
|
||||
ret=detectors[i]->setThresholdEnergy(e_eV,-1,isettings);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
#ifdef VERBOSE
|
||||
cout << "detetcor " << i << " threshold " << ret << endl;
|
||||
#endif
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret<(ret1-200) || ret>(ret1+200))
|
||||
ret1=FAIL;
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "return value " << ret1 << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
thisMultiDetector->currentThresholdEV=ret1;
|
||||
return ret1;
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return -1;
|
||||
}else{
|
||||
//return storage values
|
||||
int* iret[posmax-posmin];
|
||||
for(int idet=posmin; idet<posmax; idet++){
|
||||
if(detectors[idet]){
|
||||
iret[idet]= new int(-1);
|
||||
Task* task = new Task(new func4_t<int,slsDetector,int,int,detectorSettings,int,int>(&slsDetector::setThresholdEnergy,
|
||||
detectors[idet],e_eV,-1,isettings,tb, iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
}
|
||||
threadpool->startExecuting();
|
||||
threadpool->wait_for_tasks_to_complete();
|
||||
for(int idet=posmin; idet<posmax; idet++){
|
||||
if(detectors[idet]){
|
||||
if(iret[idet] != NULL){
|
||||
if (ret==-100)
|
||||
ret=*iret[idet];
|
||||
else if (ret<(*iret[idet]-200) || ret>(*iret[idet]+200))
|
||||
ret=-1;
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
thisMultiDetector->currentThresholdEV=ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
slsDetectorDefs::detectorSettings multiSlsDetector::getSettings(int pos) {
|
||||
|
||||
int i, posmin, posmax;
|
||||
int posmin, posmax;
|
||||
int ret=-100;
|
||||
|
||||
if (pos<0) {
|
||||
@@ -1212,10 +1225,10 @@ slsDetectorDefs::detectorSettings multiSlsDetector::getSettings(int pos) {
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=GET_SETTINGS;
|
||||
delete iret[idet];
|
||||
}else ret=GET_SETTINGS;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1260,10 +1273,10 @@ slsDetectorDefs::detectorSettings multiSlsDetector::setSettings(detectorSettings
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=GET_SETTINGS;
|
||||
delete iret[idet];
|
||||
}else ret=GET_SETTINGS;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1423,7 +1436,7 @@ int* multiSlsDetector::getDataFromDetector() {
|
||||
int n = 0;
|
||||
int* retval= NULL;
|
||||
int *retdet, *p=retval;
|
||||
int nodata=1, nodatadet=-1;
|
||||
int nodatadet=-1;
|
||||
int nodatadetectortype = false;
|
||||
detectorType types = getDetectorsType();
|
||||
if(types == EIGER || types == JUNGFRAU){
|
||||
@@ -1442,7 +1455,6 @@ int* multiSlsDetector::getDataFromDetector() {
|
||||
if(!nodatadetectortype){
|
||||
n=detectors[id]->getDataBytes();
|
||||
if (retdet) {
|
||||
nodata=0;
|
||||
#ifdef VERBOSE
|
||||
cout << "Detector " << id << " returned " << n << " bytes " << endl;
|
||||
#endif
|
||||
@@ -1649,10 +1661,10 @@ int multiSlsDetector::startAndReadAllNoWait(){
|
||||
if(iret[idet] != NULL){
|
||||
if(*iret[idet] != OK)
|
||||
ret = FAIL;
|
||||
delete iret[idet];
|
||||
}else ret = FAIL;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2092,7 +2104,6 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int &n){
|
||||
n = 0;
|
||||
int num = 0,i,j;
|
||||
int ndet = thisMultiDetector->numberOfDetectors;
|
||||
int nroi[ndet];
|
||||
int maxroi = ndet*MAX_ROIS;
|
||||
ROI temproi;
|
||||
ROI roiLimits[maxroi];
|
||||
@@ -2107,7 +2118,6 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int &n){
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
|
||||
nroi[i] = index;
|
||||
if(temp){
|
||||
//#ifdef VERBOSE
|
||||
if(index)
|
||||
@@ -2319,7 +2329,7 @@ int multiSlsDetector::setFlatFieldCorrection(string fname){
|
||||
char ffffname[MAX_STR_LENGTH*2];
|
||||
int nch;//nbad=0,
|
||||
//int badlist[MAX_BADCHANS];
|
||||
int im=0;
|
||||
//int im=0;
|
||||
|
||||
if (fname=="default") {
|
||||
fname=string(thisMultiDetector->flatFieldFile);
|
||||
@@ -2591,7 +2601,7 @@ int multiSlsDetector::setRateCorrection(double t){
|
||||
ret=detectors[idet]->setRateCorrection(t);
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if (ret1 != OK)
|
||||
if (ret != OK)
|
||||
ret1=FAIL;
|
||||
}
|
||||
}
|
||||
@@ -3321,8 +3331,6 @@ char* multiSlsDetector::setNetworkParameter(networkParameter p, string s){
|
||||
|
||||
if (s.find('+')==string::npos) {
|
||||
|
||||
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
|
||||
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return getNetworkParameter(p);
|
||||
@@ -3343,6 +3351,7 @@ char* multiSlsDetector::setNetworkParameter(networkParameter p, string s){
|
||||
//doing nothing with the return values
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete sret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3987,10 +3996,10 @@ int multiSlsDetector::executeTrimming(trimMode mode, int par1, int par2, int imo
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=-1;
|
||||
delete iret[idet];
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4085,10 +4094,10 @@ int multiSlsDetector::loadSettingsFile(string fname, int imod) {
|
||||
if(iret[idet] != NULL){
|
||||
if(*iret[idet] != OK)
|
||||
ret = FAIL;
|
||||
delete iret[idet];
|
||||
}else ret = FAIL;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4162,10 +4171,10 @@ int multiSlsDetector::setAllTrimbits(int val, int imod){
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=-1;
|
||||
delete iret[idet];
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4210,10 +4219,10 @@ int multiSlsDetector::loadCalibrationFile(string fname, int imod) {
|
||||
if(iret[idet] != NULL){
|
||||
if(*iret[idet] != OK)
|
||||
ret = FAIL;
|
||||
delete iret[idet];
|
||||
}else ret = FAIL;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4498,9 +4507,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname){
|
||||
|
||||
|
||||
ofstream outfile;
|
||||
#ifdef VERBOSE
|
||||
int ret;
|
||||
#endif
|
||||
int iline = 0;
|
||||
|
||||
outfile.open(fname.c_str(),ios_base::out);
|
||||
if (outfile.is_open()) {
|
||||
@@ -4513,7 +4520,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname){
|
||||
cout << iv << " " << names[iv] << endl;
|
||||
strcpy(args[0],names[iv].c_str());
|
||||
outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl;
|
||||
|
||||
iline++;
|
||||
// single detector configuration
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
// sprintf(ext,".det%d",i);
|
||||
@@ -4531,6 +4538,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname){
|
||||
cout << iv << " " << names[iv] << endl;
|
||||
strcpy(args[0],names[iv].c_str());
|
||||
outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl;
|
||||
iline++;
|
||||
}
|
||||
|
||||
|
||||
@@ -4542,7 +4550,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname){
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "wrote " <<ret << " lines to configuration file " << std::endl;
|
||||
std::cout<< "wrote " << iline << " lines to configuration file " << std::endl;
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
@@ -4869,10 +4877,10 @@ int multiSlsDetector::startReceiver(){
|
||||
if(iret[idet] != NULL){
|
||||
if(*iret[idet] != OK)
|
||||
ret = FAIL;
|
||||
delete iret[idet];
|
||||
}else ret = FAIL;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4931,10 +4939,10 @@ int multiSlsDetector::stopReceiver(){
|
||||
if(iret[idet] != NULL){
|
||||
if(*iret[idet] != OK)
|
||||
ret = FAIL;
|
||||
delete iret[idet];
|
||||
}else ret = FAIL;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5149,45 +5157,51 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::getData(const int isocket, const bool masking, int* image, const int size, int &acqIndex, int &frameIndex, int &subframeIndex, string &filename){
|
||||
int multiSlsDetector::getData(const int isocket, const bool masking, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename){
|
||||
|
||||
zmq_msg_t message;
|
||||
zmq_msg_t header_message;
|
||||
|
||||
//scan header-------------------------------------------------------------------
|
||||
zmq_msg_init (&message);
|
||||
int len = zmq_msg_recv(&message, zmqsocket[isocket], 0);
|
||||
zmq_msg_init (&header_message);
|
||||
//cprintf(BLUE,"%d going to receive message\n", isocket);
|
||||
int len = zmq_msg_recv(&header_message, zmqsocket[isocket], 0);
|
||||
if (len == -1) {
|
||||
cprintf(BG_RED,"Could not read header for socket %d\n",isocket);
|
||||
zmq_msg_close(&message);
|
||||
zmq_msg_close(&header_message);
|
||||
cprintf(RED, "%d message null\n",isocket);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
// error if you print it
|
||||
// cout << isocket << " header len:"<<len<<" value:"<< (char*)zmq_msg_data(&message)<<endl;
|
||||
//cprintf(BLUE,"%d header %d\n",isocket,len);
|
||||
//cprintf(BLUE,"%d header len:%d value:%s\n",isocket, len, (char*)zmq_msg_data(&header_message));
|
||||
|
||||
rapidjson::Document d;
|
||||
d.Parse( (char*)zmq_msg_data(&message), zmq_msg_size(&message));
|
||||
rapidjson::ParseResult result = d.Parse( (char*)zmq_msg_data(&header_message), len);
|
||||
if (!result) {
|
||||
cprintf(RED,"%d Could not parse. len:%d: Message:%s \n", isocket, len, (char*)zmq_msg_data(&header_message) );
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
// htype is an array of strings
|
||||
rapidjson::Value::Array htype = d["htype"].GetArray();
|
||||
for(int i=0; i< htype.Size(); i++)
|
||||
for(int i=0; i< (signed int)htype.Size(); i++)
|
||||
std::cout << isocket << "htype: " << htype[i].GetString() << std::endl;
|
||||
// shape is an array of ints
|
||||
rapidjson::Value::Array shape = d["shape"].GetArray();
|
||||
cout << isocket << "shape: ";
|
||||
for(int i=0; i< shape.Size(); i++)
|
||||
for(int i=0; i< (signed int) shape.Size(); i++)
|
||||
cout << isocket << shape[i].GetInt() << " ";
|
||||
cout << endl;
|
||||
|
||||
cout << isocket << "type: " << d["type"].GetString() << endl;
|
||||
|
||||
#endif
|
||||
if(d["acqIndex"].GetInt()!=-9){ //!isocket &&
|
||||
acqIndex = d["acqIndex"].GetInt();
|
||||
frameIndex = d["fIndex"].GetInt();
|
||||
subframeIndex = d["subfnum"].GetInt();
|
||||
if(d["acqIndex"].GetUint64()!= (uint64_t)-1){ //!isocket &&
|
||||
acqIndex = d["acqIndex"].GetUint64();
|
||||
frameIndex = d["fIndex"].GetUint64();
|
||||
subframeIndex = -1;
|
||||
if(d["bitmode"].GetInt()==32 && d["detType"].GetUint()== EIGER) {
|
||||
subframeIndex = d["expLength"].GetUint();
|
||||
}
|
||||
filename = d["fname"].GetString();
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Acquisition index: " << acqIndex << endl;
|
||||
@@ -5195,20 +5209,22 @@ int multiSlsDetector::getData(const int isocket, const bool masking, int* image,
|
||||
cout << "Subframe index: " << subframeIndex << endl;
|
||||
cout << "File name: " << filename << endl;
|
||||
#endif
|
||||
if(frameIndex ==-1) cprintf(RED,"multi frame index -1!!\n");
|
||||
if(frameIndex == (long long unsigned int)-1) cprintf(RED,"multi frame index -1!!\n");
|
||||
}
|
||||
// close the message
|
||||
zmq_msg_close(&message);
|
||||
zmq_msg_close(&header_message);
|
||||
|
||||
|
||||
//scan data-------------------------------------------------------------------
|
||||
zmq_msg_init (&message);
|
||||
len = zmq_msg_recv(&message, zmqsocket[isocket], 0);
|
||||
//cprintf(BLUE,"%d data %d\n",isocket,len);
|
||||
zmq_msg_t data_message;
|
||||
zmq_msg_init (&data_message);
|
||||
len = zmq_msg_recv(&data_message, zmqsocket[isocket], 0);
|
||||
//cprintf(GREEN,"%d data %d\n",isocket,len);
|
||||
|
||||
//end of socket ("end")
|
||||
if(len == 3){
|
||||
//cprintf(RED,"%d Received end of acquisition\n", isocket);
|
||||
//end of socket ("end\0")
|
||||
if(len == 4){
|
||||
zmq_msg_close(&data_message); // close the message
|
||||
//cprintf(RED,"%d Received end of acquisition len:%d\n", isocket, len);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -5220,19 +5236,19 @@ int multiSlsDetector::getData(const int isocket, const bool masking, int* image,
|
||||
//actual image
|
||||
else{
|
||||
//actual data
|
||||
//cprintf(BLUE,"%d actual dataaa\n",isocket);
|
||||
memcpy((char*)image,(char*)zmq_msg_data(&message),size);
|
||||
// cprintf(GREEN,"%d actual dataaa\n",isocket);
|
||||
memcpy((char*)image,(char*)zmq_msg_data(&data_message),size);
|
||||
|
||||
//jungfrau masking adcval
|
||||
if(masking){
|
||||
int snel = size/sizeof(int);
|
||||
for(unsigned int i=0;i<snel;++i){
|
||||
for(unsigned int i=0;i<(unsigned int) snel;++i){
|
||||
image[i] = (image[i] & 0x3FFF3FFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zmq_msg_close(&message); // close the message
|
||||
zmq_msg_close(&data_message); // close the message
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -5262,17 +5278,18 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
}
|
||||
|
||||
//gui variables
|
||||
int currentAcquisitionIndex = -1;
|
||||
int currentFrameIndex = -1;
|
||||
int currentSubFrameIndex = -1;
|
||||
uint64_t currentAcquisitionIndex = -1;
|
||||
uint64_t currentFrameIndex = -1;
|
||||
uint32_t currentSubFrameIndex = -1;
|
||||
string currentFileName = "";
|
||||
|
||||
//getting sls values
|
||||
int slsdatabytes = 0, slsmaxchannels = 0, bytesperchannel = 0, slsmaxX = 0, slsmaxY=0, nx=0, ny=0;
|
||||
int slsdatabytes = 0, slsmaxchannels = 0, slsmaxX = 0, slsmaxY=0, nx=0, ny=0;
|
||||
double bytesperchannel = 0;
|
||||
if(detectors[0]){
|
||||
slsdatabytes = detectors[0]->getDataBytes();
|
||||
slsmaxchannels = detectors[0]->getMaxNumberOfChannels();
|
||||
bytesperchannel = slsdatabytes/slsmaxchannels;
|
||||
bytesperchannel = (double)slsdatabytes/(double)slsmaxchannels;
|
||||
slsmaxX = detectors[0]->getTotalNumberOfChannels(X);
|
||||
slsmaxY = detectors[0]->getTotalNumberOfChannels(Y);
|
||||
}
|
||||
@@ -5339,17 +5356,17 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
if(bottom[isocket]){
|
||||
//if((((isocket/numSocketsPerSLSDetector)+1)%2) == 0){
|
||||
for(int i=0;i<slsmaxY;++i){
|
||||
memcpy(((char*)multiframe) + offsetY[isocket] + offsetX[isocket] + ((slsmaxY-1-i)*maxX*bytesperchannel),
|
||||
(char*)image+ i*(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel,
|
||||
(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel);
|
||||
memcpy(((char*)multiframe) + offsetY[isocket] + offsetX[isocket] + (int)((slsmaxY-1-i)*maxX*bytesperchannel),
|
||||
(char*)image+ (int)(i*(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel),
|
||||
(int)(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel);
|
||||
}
|
||||
}
|
||||
//top
|
||||
else{
|
||||
for(int i=0;i<slsmaxY;++i){
|
||||
memcpy(((char*)multiframe) + offsetY[isocket] + offsetX[isocket] + (i*maxX*bytesperchannel),
|
||||
(char*)image+ i*(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel,
|
||||
(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel);
|
||||
memcpy(((char*)multiframe) + offsetY[isocket] + offsetX[isocket] + (int)(i*maxX*bytesperchannel),
|
||||
(char*)image+ (int)(i*(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel),
|
||||
(int)(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5553,7 +5570,7 @@ string multiSlsDetector::getErrorMessage(int &critical){
|
||||
slsMask=detectors[idet]->getErrorMask();
|
||||
#ifdef VERYVERBOSE
|
||||
//append sls det error mask
|
||||
sprintf(sNumber,"0x%x",slsMask);
|
||||
sprintf(sNumber,"0x%lx",slsMask);
|
||||
retval.append("Error Mask " + string(sNumber)+string("\n"));
|
||||
#endif
|
||||
//get the error critical level
|
||||
@@ -5786,10 +5803,10 @@ uint64_t multiSlsDetector::setCTBWord(int addr,uint64_t word) {
|
||||
ret1=detectors[idet]->setCTBWord(addr, word);
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if(ret==-100)
|
||||
if(ret== (long long unsigned int)-100)
|
||||
ret=ret1;
|
||||
else if (ret!=ret1)
|
||||
ret=-1;
|
||||
ret=(long long unsigned int)-1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -5900,10 +5917,10 @@ int multiSlsDetector::pulsePixel(int n,int x,int y) {
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=-1;
|
||||
delete iret[idet];
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5937,10 +5954,10 @@ int multiSlsDetector::pulsePixelNMove(int n,int x,int y) {
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=-1;
|
||||
delete iret[idet];
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5974,10 +5991,10 @@ int multiSlsDetector::pulseChip(int n) {
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=-1;
|
||||
delete iret[idet];
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
/** flag for acquiring */
|
||||
bool acquiringFlag;
|
||||
|
||||
};
|
||||
}sharedMultiSlsDetector;
|
||||
|
||||
|
||||
|
||||
@@ -453,9 +453,10 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
\param e_eV threshold in eV
|
||||
\param imod module number (-1 all)
|
||||
\param isettings ev. change settings
|
||||
\param tb 1 to include trimbits, 0 to exclude
|
||||
\returns current threshold value for imod in ev (-1 failed)
|
||||
*/
|
||||
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS);
|
||||
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS, int tb=1);
|
||||
|
||||
/**
|
||||
get detector settings
|
||||
@@ -1410,7 +1411,7 @@ private:
|
||||
/**
|
||||
* Gets data from socket
|
||||
*/
|
||||
int getData(const int isocket, const bool masking, int* image, const int size, int &acqIndex, int &frameIndex, int &subframeIndex, string &filename);
|
||||
int getData(const int isocket, const bool masking, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename);
|
||||
|
||||
/** Ensures if sockets created successfully */
|
||||
bool dataSocketsStarted;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//#define SVNPATH ""
|
||||
#define SVNURLLIB "git@git.psi.ch:sls_detectors_software/sls_detector_software.git"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUIDLIB "230d6b36e9852214f4ba5ae7c92647f35000b24d"
|
||||
//#define SVNREV 0x1313
|
||||
#define SVNREPUUIDLIB "41acb4c1ab89fe85b049c329adb539c3ad5b107a"
|
||||
//#define SVNREV 0x1350
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTHLIB "Dhanya_Maliakal"
|
||||
#define SVNREVLIB 0x1313
|
||||
#define SVNDATELIB 0x20161130
|
||||
#define SVNREVLIB 0x1350
|
||||
#define SVNDATELIB 0x20170419
|
||||
//
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -506,11 +506,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
\param fname name of the file to be written
|
||||
\param imod module number
|
||||
\param iodelay io delay (detector specific)
|
||||
\param tau tau (detector specific)
|
||||
\returns OK or FAIL if the file could not be written
|
||||
\sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
|
||||
*/
|
||||
using energyConversion::writeSettingsFile;
|
||||
int writeSettingsFile(string fname, int imod, int* iodelay=0);
|
||||
int writeSettingsFile(string fname, int imod, int iodelay, int tau);
|
||||
|
||||
|
||||
/**
|
||||
@@ -947,14 +948,16 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
/**
|
||||
configure chip
|
||||
\param module module to be set - must contain correct module number and also channel and chip registers
|
||||
\param gainval pointer to extra gain values
|
||||
\param offsetval pointer to extra offset values
|
||||
\param iodelay iodelay (detector specific)
|
||||
\param tau tau (detector specific)
|
||||
\param e_eV threashold in eV (detector specific)
|
||||
\param gainval pointer to extra gain values
|
||||
\param offsetval pointer to extra offset values
|
||||
\param tb 1 to include trimbits, 0 to exclude (used for eiger)
|
||||
\returns current register value
|
||||
\sa ::sls_detector_module
|
||||
*/
|
||||
int setModule(sls_detector_module module, int* gainval, int* offsetval,int* iodelay, int64_t tau);
|
||||
int setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval=0, int* offsetval=0, int tb=1);
|
||||
//virtual int setModule(sls_detector_module module);
|
||||
|
||||
/**
|
||||
@@ -985,9 +988,19 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
\param e_eV threshold in eV
|
||||
\param imod module number (-1 all)
|
||||
\param isettings ev. change settings
|
||||
\param tb 1 to include trimbits, 0 to exclude
|
||||
\returns current threshold value for imod in ev (-1 failed)
|
||||
*/
|
||||
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS);
|
||||
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS, int tb=1);
|
||||
|
||||
/**
|
||||
set threshold energy
|
||||
\param e_eV threshold in eV
|
||||
\param isettings ev. change settings
|
||||
\param tb 1 to include trimbits, 0 to exclude
|
||||
\returns OK if successful, else FAIL
|
||||
*/
|
||||
int setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb=1);
|
||||
|
||||
/**
|
||||
get detector settings
|
||||
|
||||
@@ -75,10 +75,10 @@ int slsDetectorActions::setActionScript(int iaction, string fname) {
|
||||
|
||||
|
||||
int slsDetectorActions::setActionParameter(int iaction, string par) {
|
||||
int am;
|
||||
// int am;
|
||||
|
||||
if (iaction>=0 && iaction<MAX_ACTIONS) {
|
||||
am= 1& ( (*actionMask) << iaction);
|
||||
//am= 1& ( (*actionMask) << iaction);
|
||||
|
||||
if (par!="") {
|
||||
strcpy(actionParameter[iaction],par.c_str());
|
||||
|
||||
@@ -210,7 +210,7 @@ class slsDetectorActions : public virtual slsDetectorBase
|
||||
/* *\/ */
|
||||
/* virtual detectorType getDetectorsType(int pos=-1)=0; */
|
||||
|
||||
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
|
||||
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
|
||||
virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0;
|
||||
|
||||
|
||||
|
||||
@@ -429,14 +429,10 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
||||
virtual externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE)=0;
|
||||
int setTimingMode(int i=-1){return slsDetectorUsers::getTimingMode( externalCommunicationType( setExternalCommunicationMode(externalCommunicationType( slsDetectorUsers::getTimingMode(i) ) ) ) );};
|
||||
|
||||
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS)=0;
|
||||
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
|
||||
int setThresholdEnergy(int e_eV){return setThresholdEnergy(e_eV,-1);};
|
||||
|
||||
|
||||
// int getBeamEnergy(){return 2*getThresholdEnergy();};
|
||||
//int setBeamEnergy(int e){return 2*setThresholdEnergy(e/2);};
|
||||
|
||||
|
||||
/**
|
||||
Prints receiver configuration
|
||||
\returns OK or FAIL
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
|
||||
myDet=det;
|
||||
@@ -184,7 +185,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="trimen";
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdUnderDevelopment;
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTrimEn;
|
||||
i++;
|
||||
|
||||
|
||||
@@ -551,6 +552,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="thresholdnotb"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="trimbits"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
|
||||
i++;
|
||||
@@ -647,10 +652,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="ib_test_c"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="dac0"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
|
||||
i++;
|
||||
@@ -900,6 +901,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="probesl"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft;
|
||||
i++;
|
||||
|
||||
// descrToFuncMap[i].m_pFuncName="progress";
|
||||
// descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
|
||||
// i++;
|
||||
@@ -1926,9 +1931,9 @@ string slsDetectorCommand::cmdEnablefwrite(int narg, char *args[], int action){
|
||||
string slsDetectorCommand::helpEnablefwrite(int narg, char *args[], int action){
|
||||
ostringstream os;
|
||||
if (action==GET_ACTION || action==HELP_ACTION)
|
||||
os << string("When Enabled writes the data into the file\n");
|
||||
os << string("enablefwrite \t When Enabled writes the data into the file\n");
|
||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
||||
os << string(" i \t should be 1 or 0 or -1\n");
|
||||
os << string("enablefwrite i \t should be 1 or 0 or -1\n");
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@@ -1958,9 +1963,9 @@ string slsDetectorCommand::cmdOverwrite(int narg, char *args[], int action){
|
||||
string slsDetectorCommand::helpOverwrite(int narg, char *args[], int action){
|
||||
ostringstream os;
|
||||
if (action==GET_ACTION || action==HELP_ACTION)
|
||||
os << string("When Enabled overwrites files\n");
|
||||
os << string("overwrite \t When Enabled overwrites files\n");
|
||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
||||
os << string(" i \t should be 1 or 0 or -1\n");
|
||||
os << string("overwrite i \t should be 1 or 0 or -1\n");
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@@ -1990,7 +1995,7 @@ string slsDetectorCommand::helpFileIndex(int narg, char *args[], int action){
|
||||
if (action==GET_ACTION || action==HELP_ACTION)
|
||||
os << string("index \t gets the file index for the next the data file\n");
|
||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
||||
os << string("fname i \t sets the fileindex for the next data file\n");
|
||||
os << string("index i \t sets the fileindex for the next data file\n");
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@@ -2866,7 +2871,7 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
|
||||
os << "txndelay_left \n gets detector transmission delay of the left port"<< std::endl;
|
||||
os << "txndelay_right \n gets detector transmission delay of the right port"<< std::endl;
|
||||
os << "txndelay_frame \n gets detector transmission delay of the entire frame"<< std::endl;
|
||||
os << "flowcontrol_10g \n sets flow control for 10g for eiger"<< std::endl;
|
||||
os << "flowcontrol_10g \n gets flow control for 10g for eiger"<< std::endl;
|
||||
}
|
||||
return os.str();
|
||||
|
||||
@@ -3278,18 +3283,50 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
|
||||
if (cmd=="settings") {
|
||||
if (action==PUT_ACTION)
|
||||
myDet->setSettings(myDet->getDetectorSettings(string(args[1])));
|
||||
detectorSettings sett = GET_SETTINGS;
|
||||
if (action==PUT_ACTION) {
|
||||
sett = myDet->setSettings(myDet->getDetectorSettings(string(args[1])));
|
||||
if (myDet->getDetectorsType() == EIGER) {
|
||||
return myDet->getDetectorSettings(sett);
|
||||
}
|
||||
}
|
||||
return myDet->getDetectorSettings(myDet->getSettings());
|
||||
} else if (cmd=="threshold") {
|
||||
if (action==PUT_ACTION) {
|
||||
if (sscanf(args[1],"%d",&val))
|
||||
myDet->setThresholdEnergy(val);
|
||||
else
|
||||
return string("invalid threshold value ")+cmd;
|
||||
if (!sscanf(args[1],"%d",&val)) {
|
||||
return string("invalid threshold value");
|
||||
}
|
||||
detectorType type = myDet->getDetectorsType();
|
||||
if (type != EIGER || (type == EIGER && narg<=2)) {
|
||||
myDet->setThresholdEnergy(val);
|
||||
} else {
|
||||
detectorSettings sett= myDet->getDetectorSettings(string(args[2]));
|
||||
if(sett == -1)
|
||||
return string("invalid settings value");
|
||||
myDet->setThresholdEnergy(val, -1, sett);
|
||||
}
|
||||
}
|
||||
sprintf(ans,"%d",myDet->getThresholdEnergy());
|
||||
return string(ans);
|
||||
} else if (cmd=="thresholdnotb") {
|
||||
if (action==PUT_ACTION) {
|
||||
if (!sscanf(args[1],"%d",&val)) {
|
||||
return string("invalid threshold value");
|
||||
}
|
||||
detectorType type = myDet->getDetectorsType();
|
||||
if (type != EIGER)
|
||||
return string("not implemented for this detector");
|
||||
if (narg<=2) {
|
||||
myDet->setThresholdEnergy(val, -1, GET_SETTINGS, 0);
|
||||
} else {
|
||||
detectorSettings sett= myDet->getDetectorSettings(string(args[2]));
|
||||
if(sett == -1)
|
||||
return string("invalid settings value");
|
||||
myDet->setThresholdEnergy(val, -1, sett, 0);
|
||||
}
|
||||
}
|
||||
sprintf(ans,"%d",myDet->getThresholdEnergy());
|
||||
return string(ans);
|
||||
} else if (cmd=="trimbits") {
|
||||
if (narg>=2) {
|
||||
string sval=string(args[1]);
|
||||
@@ -3372,7 +3409,8 @@ string slsDetectorCommand::helpSettings(int narg, char *args[], int action) {
|
||||
if (action==PUT_ACTION || action==HELP_ACTION) {
|
||||
os << "settings s \n sets the settings of the detector - can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain"
|
||||
"lownoise, dynamichg0,fixgain1,fixgain2,forceswitchg1, forceswitchg2"<< std::endl;
|
||||
os << "threshold eV\n sets the detector threshold in eV"<< std::endl;
|
||||
os << "threshold eV [sett]\n sets the detector threshold in eV. If sett is provided for eiger, uses settings sett"<< std::endl;
|
||||
os << "thresholdnotb eV [sett]\n sets the detector threshold in eV without loading trimbits. If sett is provided for eiger, uses settings sett"<< std::endl;
|
||||
os << "trimbits fname\n loads the trimfile fname to the detector. If no extension is specified, the serial number of each module will be attached."<< std::endl;
|
||||
os << "trim:mode fname\n trims the detector according to mode (can be noise, beam, improve, fix) and saves the resulting trimbits to file fname."<< std::endl;
|
||||
os << "trimval i \n sets all the trimbits to i" << std::endl;
|
||||
@@ -3413,7 +3451,11 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
|
||||
|
||||
|
||||
if (cmd=="thisversion"){
|
||||
sprintf(answer,"%llx",myDet->getId(THIS_SOFTWARE_VERSION));
|
||||
int64_t retval = myDet->getId(THIS_SOFTWARE_VERSION);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
}
|
||||
|
||||
@@ -3423,37 +3465,61 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
|
||||
if (cmd=="moduleversion") {
|
||||
int ival=-1;
|
||||
if (sscanf(args[0],"moduleversion:%d",&ival)) {
|
||||
sprintf(answer,"%llx",myDet->getId(MODULE_FIRMWARE_VERSION,ival));
|
||||
int64_t retval = myDet->getId(MODULE_FIRMWARE_VERSION, ival);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
} else
|
||||
return string("undefined module number");
|
||||
}
|
||||
if (cmd=="detectornumber") {
|
||||
sprintf(answer,"%llx",myDet->getId(DETECTOR_SERIAL_NUMBER));
|
||||
int64_t retval = myDet->getId(DETECTOR_SERIAL_NUMBER);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
}
|
||||
if (cmd.find("modulenumber")!=string::npos) {
|
||||
int ival=-1;
|
||||
if (sscanf(args[0],"modulenumber:%d",&ival)) {
|
||||
sprintf(answer,"%llx",myDet->getId(MODULE_SERIAL_NUMBER,ival));
|
||||
int64_t retval = myDet->getId(MODULE_SERIAL_NUMBER, ival);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
} else
|
||||
return string("undefined module number");
|
||||
}
|
||||
|
||||
if (cmd=="detectorversion") {
|
||||
sprintf(answer,"%llx",myDet->getId(DETECTOR_FIRMWARE_VERSION));
|
||||
int64_t retval = myDet->getId(DETECTOR_FIRMWARE_VERSION);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
}
|
||||
|
||||
if (cmd=="softwareversion") {
|
||||
sprintf(answer,"%llx",myDet->getId(DETECTOR_SOFTWARE_VERSION));
|
||||
int64_t retval = myDet->getId(DETECTOR_SOFTWARE_VERSION);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
}
|
||||
|
||||
if (cmd=="receiverversion") {
|
||||
myDet->setReceiverOnline(ONLINE_FLAG);
|
||||
sprintf(answer,"%llx",myDet->getId(RECEIVER_VERSION));
|
||||
int64_t retval = myDet->getId(RECEIVER_VERSION);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
}
|
||||
return string("unknown id mode ")+cmd;
|
||||
@@ -3944,13 +4010,13 @@ string slsDetectorCommand::helpDAC(int narg, char *args[], int action) {
|
||||
|
||||
|
||||
os << "dac0 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac1 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac2 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac3 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac4 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac5 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac6 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac7 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac1 " << "\t gets dac 1" << std::endl;
|
||||
os << "dac2 " << "\t gets dac 2" << std::endl;
|
||||
os << "dac3 " << "\t gets dac 3" << std::endl;
|
||||
os << "dac4 " << "\t gets dac 4" << std::endl;
|
||||
os << "dac5 " << "\t gets dac 5" << std::endl;
|
||||
os << "dac6 " << "\t gets dac 6" << std::endl;
|
||||
os << "dac7 " << "\t gets dac 7" << std::endl;
|
||||
|
||||
os << "vsvp" << "dacu\t gets vsvp" << std::endl;
|
||||
os << "vsvn" << "dacu\t gets vsvn" << std::endl;
|
||||
@@ -4478,7 +4544,7 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
|
||||
if (action==GET_ACTION)
|
||||
return string("cannot get");
|
||||
#ifdef VERBOSE
|
||||
std::cout<< " resetting fpga " << sval << std::endl;
|
||||
std::cout<< " resetting fpga " << std::endl;
|
||||
#endif
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
if(myDet->resetFPGA() == OK)
|
||||
@@ -4514,11 +4580,13 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
|
||||
os << "flags mode \t sets the readout flags to mode. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl;
|
||||
os << "programfpga f \t programs the fpga with file f (with .pof extension)." << std::endl;
|
||||
os << "resetfpga f \t resets fpga, f can be any value" << std::endl;
|
||||
os << "powerchip i \t powers on or off the chip. i = 1 for on, i = 0 for off" << std::endl;
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION) {
|
||||
|
||||
os << "extsig:i \t gets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << 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;
|
||||
|
||||
}
|
||||
return os.str();
|
||||
@@ -4855,7 +4923,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
else
|
||||
return string("Could not scan address (hexadecimal fomat) ")+string(args[1]);
|
||||
|
||||
if (sscanf(args[2],"%llx",&word))
|
||||
if (sscanf(args[2],"%lx",&word))
|
||||
;
|
||||
else
|
||||
return string("Could not scan value (hexadecimal fomat) ")+string(args[2]);
|
||||
@@ -4871,7 +4939,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%llx",&word))
|
||||
if (sscanf(args[1],"%lx",&word))
|
||||
;
|
||||
else
|
||||
return string("Could not scan value (hexadecimal fomat) ")+string(args[1]);
|
||||
@@ -4888,7 +4956,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%llx",&word))
|
||||
if (sscanf(args[1],"%lx",&word))
|
||||
;
|
||||
else
|
||||
return string("Could not scan value (hexadecimal fomat) ")+string(args[1]);
|
||||
@@ -5159,7 +5227,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%lld",&t))
|
||||
if (sscanf(args[1],"%ld",&t))
|
||||
;
|
||||
else
|
||||
return string("Could not scan wait time")+string(args[1]);
|
||||
@@ -5182,7 +5250,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%lld",&t))
|
||||
if (sscanf(args[1],"%ld",&t))
|
||||
;
|
||||
else
|
||||
return string("Could not scan wait time ")+string(args[1]);
|
||||
@@ -5200,7 +5268,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
} else if (cmd=="patwaittime2") {
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%lld",&t))
|
||||
if (sscanf(args[1],"%ld",&t))
|
||||
;
|
||||
else
|
||||
return string("Could not scan wait time ")+string(args[1]);
|
||||
@@ -5319,13 +5387,11 @@ string slsDetectorCommand::cmdPulse(int narg, char *args[], int action) {
|
||||
|
||||
}
|
||||
|
||||
return string("");
|
||||
/*
|
||||
|
||||
if(retval == OK)
|
||||
return string(" successful");
|
||||
else
|
||||
return string(" failed");
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -147,14 +147,6 @@ int slsDetectorUsers::setThresholdEnergy(int e_eV){
|
||||
return myDetector->setThresholdEnergy(e_eV);
|
||||
}
|
||||
|
||||
int slsDetectorUsers::getBeamEnergy(){
|
||||
return 2*myDetector->getThresholdEnergy();
|
||||
}
|
||||
|
||||
int slsDetectorUsers::setBeamEnergy(int e_eV){
|
||||
return 2*myDetector->setThresholdEnergy(e_eV/2);
|
||||
}
|
||||
|
||||
double slsDetectorUsers::setExposureTime(double t, bool inseconds){
|
||||
int64_t tms = (int64_t)(t * (1E+9));
|
||||
if (t < 0) tms = -1;
|
||||
|
||||
@@ -302,19 +302,6 @@ class slsDetectorUsers
|
||||
*/
|
||||
int setThresholdEnergy(int e_eV);
|
||||
|
||||
/**
|
||||
@short get beam energy -- only for dectris!
|
||||
\returns current beam energy
|
||||
*/
|
||||
int getBeamEnergy();
|
||||
|
||||
|
||||
/**
|
||||
@short set beam energy -- only for dectris!
|
||||
\param e_eV beam in eV
|
||||
\returns current beam energyin ev (-1 failed)
|
||||
*/
|
||||
int setBeamEnergy(int e_eV);
|
||||
|
||||
/**
|
||||
@short set/get exposure time value
|
||||
|
||||
@@ -226,9 +226,6 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
for (int ip=0; ip<np; ip++) {
|
||||
|
||||
//let processing thread listen to these packets
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
|
||||
// cout << "positions " << endl;
|
||||
if (*stoppedFlag==0) {
|
||||
if (getNumberOfPositions()>0) {
|
||||
@@ -297,12 +294,17 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
setFileName(fileIO::getFileName());
|
||||
//start receiver
|
||||
if(startReceiver() == FAIL) {
|
||||
cout << "Start receiver failed " << endl;
|
||||
stopReceiver();
|
||||
*stoppedFlag=1;
|
||||
pthread_mutex_unlock(&mg);
|
||||
break;
|
||||
}
|
||||
pthread_mutex_unlock(&mg);
|
||||
|
||||
//let processing thread listen to these packets
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout << "Acquiring " << endl;
|
||||
@@ -796,7 +798,6 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
||||
slsDetectorCommand *cmd;
|
||||
string names[100];
|
||||
int nvar=0;
|
||||
int nvar1=0;
|
||||
|
||||
names[nvar++]="fname";
|
||||
names[nvar++]="index";
|
||||
@@ -876,6 +877,8 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
||||
names[nvar++]="patnloop2";
|
||||
names[nvar++]="patwait2";
|
||||
names[nvar++]="patwaittime2";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -906,6 +909,8 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
||||
names[nvar++]="flatfield";
|
||||
names[nvar++]="badchannels";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@@ -914,7 +919,8 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
||||
case MYTHEN:
|
||||
names[nvar++]="trimbits";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// char ext[100];
|
||||
|
||||
@@ -421,7 +421,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
// double* convertAngles(){return convertAngles(currentPosition);};
|
||||
// virtual double* convertAngles(double pos)=0;
|
||||
|
||||
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
|
||||
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
|
||||
virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0;
|
||||
|
||||
virtual double getRateCorrectionTau()=0;
|
||||
|
||||
@@ -255,8 +255,8 @@ int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod,
|
||||
angOff[nm].etilt=epitch;
|
||||
|
||||
}
|
||||
// cout << angOff[nm].center << " " << \
|
||||
// angOff[nm].r_conversion << " " << \
|
||||
// cout << angOff[nm].center << " " <<
|
||||
// angOff[nm].r_conversion << " " <<
|
||||
// angOff[nm].offset << endl;
|
||||
|
||||
} else
|
||||
|
||||
@@ -17,20 +17,20 @@ int energyConversion::readCalibrationFile(string fname, double &gain, double &of
|
||||
string str;
|
||||
ifstream infile;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Opening file "<< fname << std::endl;
|
||||
printf( "Opening file %s \n", fname.c_str() );
|
||||
#endif
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
getline(infile,str);
|
||||
#ifdef VERBOSE
|
||||
std::cout<< str << std::endl;
|
||||
printf( "%s \n", str.c_str() );
|
||||
#endif
|
||||
istringstream ssstr(str);
|
||||
ssstr >> offset >> gain;
|
||||
infile.close();
|
||||
cout << "Calibration file loaded: " << fname << endl;
|
||||
printf( "Calibration file loaded: %s \n", fname.c_str() );
|
||||
} else {
|
||||
std::cout<< "Could not open calibration file "<< fname << std::endl;
|
||||
printf( "Could not open calibration file %s \n", fname.c_str() );
|
||||
gain=0.;
|
||||
offset=0.;
|
||||
#ifndef MYROOT
|
||||
@@ -45,7 +45,7 @@ int energyConversion::readCalibrationFile(string fname, double &gain, double &of
|
||||
};
|
||||
|
||||
int energyConversion::writeCalibrationFile(string fname, double gain, double offset){
|
||||
//std::cout<< "Function not yet implemented " << std::endl;
|
||||
//printf( "Function not yet implemented \n" );
|
||||
ofstream outfile;
|
||||
outfile.open (fname.c_str());
|
||||
|
||||
@@ -53,7 +53,7 @@ int energyConversion::writeCalibrationFile(string fname, double gain, double off
|
||||
if (outfile.is_open()) {
|
||||
outfile << offset << " " << gain << std::endl;
|
||||
} else {
|
||||
std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl;
|
||||
printf( "Could not open calibration file %s for writing \n", fname.c_str() );
|
||||
#ifndef MYROOT
|
||||
return FAIL;
|
||||
#endif
|
||||
@@ -69,87 +69,60 @@ int energyConversion::writeCalibrationFile(string fname, double gain, double off
|
||||
};
|
||||
|
||||
|
||||
int energyConversion::readCalibrationFile(string fname, int *gain, int *offset, int64_t &tau, detectorType myDetectorType){
|
||||
|
||||
|
||||
int energyConversion::readCalibrationFile(string fname, int *gain, int *offset){
|
||||
|
||||
string str;
|
||||
ifstream infile;
|
||||
double o,g;
|
||||
int ig=0;
|
||||
switch (myDetectorType) {
|
||||
case EIGER:
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Opening file "<< fname << std::endl;
|
||||
printf( "Opening file %s \n", fname.c_str() );
|
||||
#endif
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
//get gain and offset
|
||||
for (ig=0; ig<4; ig++) {
|
||||
//while ( (getline(infile,str)) > -1) {
|
||||
getline(infile,str);
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
//get gain and offset
|
||||
for (ig=0; ig<4; ig++) {
|
||||
//while ( (getline(infile,str)) > -1) {
|
||||
getline(infile,str);
|
||||
#ifdef VERBOSE
|
||||
std::cout<< str << std::endl;
|
||||
printf( "%s \n", str.c_str() );
|
||||
#endif
|
||||
istringstream ssstr(str);
|
||||
ssstr >> o >> g;
|
||||
offset[ig]=(int)(o*1000);
|
||||
gain[ig]=(int)(g*1000);
|
||||
// ig++;
|
||||
if (ig>=4)
|
||||
break;
|
||||
}
|
||||
//get tau
|
||||
if (myDetectorType == EIGER) {
|
||||
if(getline(infile,str)){
|
||||
istringstream ssstr(str);
|
||||
ssstr >> tau;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "tau:" << tau << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
infile.close();
|
||||
cout << "Calibration file loaded: " << fname << endl;
|
||||
} else {
|
||||
cout << "Could not open calibration file: "<< fname << std::endl;
|
||||
gain[0]=0;
|
||||
offset[0]=0;
|
||||
#ifndef MYROOT
|
||||
return FAIL;
|
||||
#endif
|
||||
return -1;
|
||||
istringstream ssstr(str);
|
||||
ssstr >> o >> g;
|
||||
offset[ig]=(int)(o*1000);
|
||||
gain[ig]=(int)(g*1000);
|
||||
// ig++;
|
||||
if (ig>=4)
|
||||
break;
|
||||
}
|
||||
infile.close();
|
||||
printf( "Calibration file loaded: %s \n", fname.c_str() );
|
||||
} else {
|
||||
printf( "Could not open calibration file: %s \n", fname.c_str() );
|
||||
gain[0]=0;
|
||||
offset[0]=0;
|
||||
#ifndef MYROOT
|
||||
return OK;
|
||||
#endif
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
std::cout<< "Writing Calibration Files for this detector not defined\n" << std::endl;
|
||||
return FAIL;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
#ifndef MYROOT
|
||||
return OK;
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
};
|
||||
|
||||
int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset, int64_t tau, detectorType myDetectorType){
|
||||
//std::cout<< "Function not yet implemented " << std::endl;
|
||||
int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset){
|
||||
//printf( "Function not yet implemented \n" );
|
||||
ofstream outfile;
|
||||
switch (myDetectorType) {
|
||||
case EIGER:
|
||||
|
||||
outfile.open (fname.c_str());
|
||||
|
||||
// >> i/o operations here <<
|
||||
if (outfile.is_open()) {
|
||||
for (int ig=0; ig<4; ig++)
|
||||
outfile << ((double)offset[ig]/1000) << " " << ((double)gain[ig]/1000) << std::endl;
|
||||
outfile << tau << std::endl;
|
||||
} else {
|
||||
std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl;
|
||||
printf( "Could not open calibration file %s for writing \n", fname.c_str() );
|
||||
#ifndef MYROOT
|
||||
return FAIL;
|
||||
#endif
|
||||
@@ -161,21 +134,55 @@ int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset,
|
||||
return OK;
|
||||
#endif
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
std::cout<< "Writing Calibration Files for this detector not defined\n" << std::endl;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2, int tb){
|
||||
// only implemented for eiger currently (in terms of which dacs)
|
||||
if(myDetectorType != EIGER) {
|
||||
printf("Interpolation of Trim values not implemented for this detector!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sls_detector_module* myMod = createModule(myDetectorType);
|
||||
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};
|
||||
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);
|
||||
return NULL;
|
||||
}
|
||||
myMod->dacs[dacs_to_copy[i]] = a->dacs[dacs_to_copy[i]];
|
||||
}
|
||||
|
||||
//Interpolate vrf, vcmp, vcp
|
||||
int num_dacs_to_interpolate = 6;
|
||||
int dacs_to_interpolate[] = {VRF,VCMP_LL,VCMP_LR,VCMP_RL,VCMP_RR,VCP};
|
||||
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]]);
|
||||
}
|
||||
|
||||
//Interpolate all trimbits
|
||||
if(tb) {
|
||||
for (int i = 0; i<myMod->nchan; i++)
|
||||
myMod->chanregs[i] = linearInterpolation(energy, e1, e2, a->chanregs[i], b->chanregs[i]);
|
||||
}
|
||||
return myMod;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef MYROOT
|
||||
|
||||
/* I/O */
|
||||
|
||||
|
||||
slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module *myMod, int* iodelay){
|
||||
slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod, int tb){
|
||||
|
||||
|
||||
|
||||
@@ -246,16 +253,16 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
names[id++]="VDAC15";
|
||||
break;
|
||||
default:
|
||||
cout << "Unknown detector type - unknown format for settings file" << endl;
|
||||
printf( "Unknown detector type - unknown format for settings file \n" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "reading settings file for module number "<< myMod->module << std::endl;
|
||||
printf( " reading settings file for module number %d \n", myMod->module );
|
||||
#endif
|
||||
myfname=fname;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "file name is "<< myfname << std::endl;
|
||||
printf( "file name is %s \n", myfname.c_str() );
|
||||
#endif
|
||||
|
||||
switch (myDetectorType) {
|
||||
@@ -269,7 +276,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
istringstream ssstr(str);
|
||||
ssstr >> sargname >> ival;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl;
|
||||
printf( "%s dac nr. %d is %d \n", sargname.c_str(), idac, ival );
|
||||
#endif
|
||||
myMod->dacs[idac]=ival;
|
||||
idac++;
|
||||
@@ -278,24 +285,24 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
getline(infile,str);
|
||||
iline++;
|
||||
#ifdef VERYVERBOSE
|
||||
std::cout<< str << std::endl;
|
||||
printf( "%s \n", str.c_str() );
|
||||
#endif
|
||||
istringstream ssstr(str);
|
||||
ssstr >> sargname >> ival;
|
||||
#ifdef VERYVERBOSE
|
||||
std::cout<< "chip " << ichip << " " << sargname << " is " << ival << std::endl;
|
||||
printf( "chip %d %s is %d \n", ichip, sargname.c_str(), ival );
|
||||
#endif
|
||||
|
||||
myMod->chipregs[ichip]=ival;
|
||||
for (ichan=0; ichan<nch; ichan++) {
|
||||
getline(infile,str);
|
||||
#ifdef VERYVERBOSE
|
||||
std::cout<< str << std::endl;
|
||||
printf( " %s \n", str.c_str() );
|
||||
#endif
|
||||
istringstream ssstr(str);
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
std::cout<< "channel " << ichan+ichip*thisDetector->nChans <<" iline " << iline<< std::endl;
|
||||
printf( "channel %d iline %d \n", ichan+ichip*myMod->nchan, iline );
|
||||
#endif
|
||||
iline++;
|
||||
myMod->chanregs[ichip*nch+ichan]=0;
|
||||
@@ -305,42 +312,42 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
switch (iarg) {
|
||||
case 0:
|
||||
#ifdef VERYVERBOSE
|
||||
std::cout<< "trimbits " << ival ;
|
||||
printf( "trimbits %d", ival );
|
||||
#endif
|
||||
myMod->chanregs[ichip*nch+ichan]|=ival&TRIMBITMASK;
|
||||
break;
|
||||
case 1:
|
||||
#ifdef VERYVERBOSE
|
||||
std::cout<< " compen " << ival ;
|
||||
printf( " compen %d", ival );
|
||||
#endif
|
||||
myMod->chanregs[ichip*nch+ichan]|=ival<<9;
|
||||
break;
|
||||
case 2:
|
||||
#ifdef VERYVERBOSE
|
||||
std::cout<< " anen " << ival ;
|
||||
printf( " anen %d", ival );
|
||||
#endif
|
||||
myMod->chanregs[ichip*nch+ichan]|=ival<<8;
|
||||
break;
|
||||
case 3:
|
||||
#ifdef VERYVERBOSE
|
||||
std::cout<< " calen " << ival ;
|
||||
printf( " calen %d", ival ) ;
|
||||
#endif
|
||||
myMod->chanregs[ichip*nch+ichan]|=ival<<7;
|
||||
break;
|
||||
case 4:
|
||||
#ifdef VERBOSE
|
||||
std::cout<< " outcomp " << ival ;
|
||||
printf( " outcomp %d", ival ) ;
|
||||
#endif
|
||||
myMod->chanregs[ichip*nch+ichan]|=ival<<10;
|
||||
break;
|
||||
case 5:
|
||||
#ifdef VERBOSE
|
||||
std::cout<< " counts " << ival << std::endl;
|
||||
printf( " counts %d \n", ival );
|
||||
#endif
|
||||
myMod->chanregs[ichip*nch+ichan]|=ival<<11;
|
||||
break;
|
||||
default:
|
||||
std::cout<< " too many columns" << std::endl;
|
||||
printf( " too many columns \n" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -348,12 +355,12 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
// }
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "read " << ichan*ichip << " channels" <<std::endl;
|
||||
printf( "read %d channels \n", ichan*ichip );
|
||||
#endif
|
||||
|
||||
infile.close();
|
||||
strcpy(settingsFile,fname.c_str());
|
||||
cout << "Settings file loaded: " << settingsFile << endl;
|
||||
printf("Settings file loaded: %s\n",settingsFile);
|
||||
return myMod;
|
||||
|
||||
}
|
||||
@@ -365,23 +372,27 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
infile.open(myfname.c_str(),ifstream::binary);
|
||||
if (infile.is_open()) {
|
||||
infile.read((char*) myMod->dacs,sizeof(dacs_t)*(myMod->ndac));
|
||||
infile.read((char*) iodelay,sizeof(*iodelay));
|
||||
infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan));
|
||||
infile.read((char*)&iodelay,sizeof(iodelay));
|
||||
infile.read((char*)&tau,sizeof(tau));
|
||||
#ifdef VERBOSE
|
||||
for(int i=0;i<myMod->ndac;i++)
|
||||
std::cout << "dac " << i << ":" << myMod->dacs[i] << std::endl;
|
||||
std::cout << "iodelay:" << *iodelay << std::endl;
|
||||
printf( "dac %d:%d \n", i, myMod->dacs[i] );
|
||||
printf( "iodelay:%d \n", iodelay );
|
||||
printf( "tau:%d \n", tau );
|
||||
#endif
|
||||
if(infile.eof()){
|
||||
cout<<endl<<"Error, could not load trimbits end of file, "<<myfname<<", reached."<<endl<<endl;
|
||||
if (nflag)
|
||||
deleteModule(myMod);
|
||||
if(tb) {
|
||||
infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan));
|
||||
if(infile.eof()){
|
||||
printf( "Error, could not load trimbits end of file reached: %s \n\n", myfname.c_str() );
|
||||
if (nflag)
|
||||
deleteModule(myMod);
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
infile.close();
|
||||
strcpy(settingsFile,fname.c_str());
|
||||
cout << "Settings file loaded: " << settingsFile << endl;
|
||||
printf("Settings file loaded: %s\n",settingsFile);
|
||||
return myMod;
|
||||
|
||||
}
|
||||
@@ -399,7 +410,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
getline(infile,str);
|
||||
iline++;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< str << std::endl;
|
||||
printf( "str: %s \n", str.c_str() );
|
||||
#endif
|
||||
istringstream ssstr(str);
|
||||
ssstr >> sargname >> ival;
|
||||
@@ -408,7 +419,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
myMod->dacs[i]=ival;
|
||||
idac++;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl;
|
||||
printf( " %s dac nr. %d is %d \n", sargname.c_str(), idac, ival );
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@@ -416,14 +427,14 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
}
|
||||
if (i < id) {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl;
|
||||
printf( " %s dac nr. %d is %d \n", sargname.c_str(), idac, ival );
|
||||
#endif
|
||||
}else
|
||||
std::cout<< "Unknown dac " << sargname << std::endl;
|
||||
printf( "Unknown dac %s \n", sargname.c_str() );
|
||||
|
||||
infile.close();
|
||||
strcpy(settingsFile,fname.c_str());
|
||||
cout << "Settings file loaded: " << settingsFile << endl;
|
||||
printf("Settings file loaded: %s\n",settingsFile);
|
||||
return myMod;
|
||||
|
||||
}
|
||||
@@ -432,14 +443,14 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
break;
|
||||
|
||||
default:
|
||||
std::cout<< "Unknown detector type - don't know how to read file" << myfname << std::endl;
|
||||
printf( "Unknown detector type - don't know how to read file %s\n", myfname.c_str());
|
||||
infile.close();
|
||||
deleteModule(myMod);
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
std::cout<< "Error: Could not open settings file " << myfname << std::endl;
|
||||
printf("Error: Could not open settings file %s\n", myfname.c_str());
|
||||
if (nflag)
|
||||
deleteModule(myMod);
|
||||
|
||||
@@ -450,7 +461,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
};
|
||||
|
||||
|
||||
int energyConversion::writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int* iodelay){
|
||||
int energyConversion::writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int iodelay, int tau){
|
||||
|
||||
ofstream outfile;
|
||||
|
||||
@@ -510,7 +521,7 @@ int energyConversion::writeSettingsFile(string fname, detectorType myDetectorTyp
|
||||
names[id++]="VDAC15";
|
||||
break;
|
||||
default:
|
||||
cout << "Unknown detector type - unknown format for settings file" << endl;
|
||||
printf( "Unknown detector type - unknown format for settings file \n" );
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -525,18 +536,20 @@ int energyConversion::writeSettingsFile(string fname, detectorType myDetectorTyp
|
||||
iv = 1150;
|
||||
#ifdef VERBOSE
|
||||
for(int i=0;i<mod.ndac;i++)
|
||||
std::cout << "dac " << i << ":" << mod.dacs[i] << std::endl;
|
||||
std::cout << "iodelay: " << *iodelay << std::endl;
|
||||
printf( "dac %d:%d \n", i, mod.dacs[i] );
|
||||
printf( "iodelay: %d \n", iodelay );
|
||||
printf( "tau: %d", tau);
|
||||
#endif
|
||||
outfile.write((char*)mod.dacs, sizeof(dacs_t)*(mod.ndac));
|
||||
outfile.write((char*)iodelay, sizeof(*iodelay));
|
||||
outfile.write(reinterpret_cast<char*>(&iodelay), sizeof(iodelay));
|
||||
outfile.write(reinterpret_cast<char*>(&tau), sizeof(tau));
|
||||
outfile.write((char*)mod.chanregs, sizeof(int)*(mod.nchan));
|
||||
|
||||
outfile.close();
|
||||
return slsDetectorDefs::OK;
|
||||
}
|
||||
|
||||
std::cout<< "could not open SETTINGS file " << fname << std::endl;
|
||||
printf("Could not open Settings file %s\n", fname.c_str());
|
||||
return slsDetectorDefs::FAIL;
|
||||
default:
|
||||
|
||||
@@ -578,7 +591,7 @@ int energyConversion::writeSettingsFile(string fname, detectorType myDetectorTyp
|
||||
outfile.close();
|
||||
return OK;
|
||||
}
|
||||
std::cout<< "could not open SETTINGS file " << fname << std::endl;
|
||||
printf( "could not open SETTINGS file %s \n", fname.c_str() );
|
||||
return FAIL;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//#include "sls_receiver_defs.h"
|
||||
#include "sls_detector_defs.h"
|
||||
//#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
@@ -35,7 +35,9 @@ class energyConversion
|
||||
reads a calibration file
|
||||
\param fname file to be read
|
||||
\param gain reference to the gain variable
|
||||
\offset reference to the offset variable
|
||||
\param offset reference to the offset variable
|
||||
\returns OK if successful, else FAIL or -1
|
||||
|
||||
*/
|
||||
static int readCalibrationFile(string fname, double &gain, double &offset);
|
||||
|
||||
@@ -44,36 +46,52 @@ class energyConversion
|
||||
\param fname file to be written
|
||||
\param gain
|
||||
\param offset
|
||||
\returns OK if successful, else FAIL or -1
|
||||
*/
|
||||
static int writeCalibrationFile(string fname, double gain, double offset);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
reads a calibration file
|
||||
\param fname file to be read
|
||||
\param gain reference to the gain variable
|
||||
\offset reference to the offset variable
|
||||
\tau tau
|
||||
\tau tau
|
||||
\param offset reference to the offset variable
|
||||
\returns OK if successful, else FAIL or -1
|
||||
*/
|
||||
static int readCalibrationFile(string fname, int *gain, int *offset, int64_t &tau, detectorType myDetectorType);
|
||||
static int readCalibrationFile(string fname, int *gain, int *offset);
|
||||
|
||||
/**
|
||||
writes a calibration file
|
||||
\param fname file to be written
|
||||
\param gain
|
||||
\param offset
|
||||
\param tau
|
||||
\param gain reference to the gain variable
|
||||
\param offset reference to the offset variable
|
||||
\returns OK if successful, else FAIL or -1
|
||||
*/
|
||||
static int writeCalibrationFile(string fname, int *gain, int *offset, int64_t tau, detectorType myDetectorType);
|
||||
|
||||
static int writeCalibrationFile(string fname, int *gain, int *offset);
|
||||
|
||||
|
||||
|
||||
//Template function to do linear interpolation between two points
|
||||
template <typename E, typename V>
|
||||
V linearInterpolation(const E x, const E x1, const E x2, const V y1, const V y2){
|
||||
double k = static_cast<double>(y2-y1)/(x2-x1);
|
||||
double m = y1-k*x1;
|
||||
int y = round( k*x+m );
|
||||
return static_cast<V>(y);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* interpolates dacs and trimbits between 2 trim files
|
||||
\param myDetectorType detector type (needed for which dacs that neeeds to be interpolated & which kept same)
|
||||
\param a first module structure
|
||||
\param b second module structure
|
||||
\param energy energy to trim at
|
||||
\param e1 reference trim value
|
||||
\param e2 reference trim value
|
||||
\param tb 1 to include trimbits, 0 to exclude (used for eiger)
|
||||
\returns the pointer to the module structure with interpolated values or NULL if error
|
||||
*/
|
||||
sls_detector_module* interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2, int tb=1);
|
||||
|
||||
|
||||
|
||||
@@ -83,12 +101,14 @@ class energyConversion
|
||||
reads a trim/settings file
|
||||
\param fname name of the file to be read
|
||||
\param myDetectorType detector type (needed for number of channels, chips, dacs etc.)
|
||||
\param myMod pointer to the module structure which has to be set. <BR> If it is NULL a new module structure will be created
|
||||
\param iodelay io delay (detector specific)
|
||||
\param tau tau (detector specific)
|
||||
\param myMod pointer to the module structure which has to be set. <BR> If it is NULL a new module structure will be created
|
||||
\param tb 1 to include trimbits, 0 to exclude (used for eiger)
|
||||
\returns the pointer to myMod or NULL if reading the file failed
|
||||
*/
|
||||
|
||||
sls_detector_module* readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module* myMod=NULL, int* iodelay=0);
|
||||
sls_detector_module* readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod=NULL, int tb=1);
|
||||
|
||||
/**
|
||||
writes a trim/settings file
|
||||
@@ -96,11 +116,12 @@ class energyConversion
|
||||
\param myDetectorType detector type (needed for number of channels, chips, dacs etc.)
|
||||
\param mod module structure which has to be written to file
|
||||
\param iodelay io delay (detector specific)
|
||||
\param tau tau (detector specific)
|
||||
\returns OK or FAIL if the file could not be written
|
||||
|
||||
\sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module)
|
||||
*/
|
||||
int writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int* iodelay=0);
|
||||
int writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int iodelay, int tau);
|
||||
|
||||
/** allocates the momery for a detector module structure
|
||||
\param myDetectorType detector type (needed for number of channels, chips, dacs etc.)
|
||||
@@ -114,6 +135,7 @@ class energyConversion
|
||||
*/
|
||||
virtual void deleteModule(sls_detector_module *myMod)=0;
|
||||
|
||||
|
||||
protected:
|
||||
/** pointer to settings file name */
|
||||
char *settingsFile;
|
||||
|
||||
@@ -534,9 +534,7 @@ class fileIOStatic {
|
||||
static int readDataFile(int nch, string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f') { \
|
||||
ifstream infile; \
|
||||
int iline=0; \
|
||||
int maxchans; \
|
||||
string str; \
|
||||
maxchans=nch; \
|
||||
infile.open(fname.c_str(), ios_base::in); \
|
||||
if (infile.is_open()) { \
|
||||
iline=readDataFile(nch, infile, data, err, ang, dataformat, 0); \
|
||||
|
||||
@@ -38,7 +38,7 @@ int postProcessing::kbhit(){
|
||||
}
|
||||
|
||||
|
||||
postProcessing::postProcessing(): expTime(NULL), ang(NULL), val(NULL), err(NULL), numberOfChannels(0), badChannelMask(NULL){
|
||||
postProcessing::postProcessing(): expTime(NULL), badChannelMask(NULL), ang(NULL), val(NULL), err(NULL), numberOfChannels(0) {
|
||||
pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER;
|
||||
mp=mp1;
|
||||
pthread_mutex_init(&mp, NULL);
|
||||
@@ -422,10 +422,9 @@ void* postProcessing::processData(int delflag) {
|
||||
|
||||
|
||||
int *myData;
|
||||
char *p;
|
||||
int dum=1;
|
||||
int nf=1, ii, nch;
|
||||
int jctb=0;
|
||||
// int nf=1, ii, nch;
|
||||
// int jctb=0;
|
||||
|
||||
|
||||
// if (getDetectorsType()==JUNGFRAUCTB) {
|
||||
@@ -456,7 +455,7 @@ void* postProcessing::processData(int delflag) {
|
||||
|
||||
|
||||
// if (jctb) {
|
||||
// p=(char*)myData;
|
||||
// char* p=(char*)myData;
|
||||
// for (ii=0; ii<nf; ii++) {
|
||||
// processFrame((int*)p,delflag, 1);
|
||||
// p+=2*nch;
|
||||
@@ -880,10 +879,14 @@ void postProcessing::startThread(int delflag) {
|
||||
else
|
||||
ret = pthread_create(&dataProcessingThread, &tattr,startProcessDataNoDelete, (void*)this);
|
||||
|
||||
if (ret)
|
||||
printf("ret %d\n", ret);
|
||||
|
||||
pthread_attr_destroy(&tattr);
|
||||
|
||||
// scheduling parameters of target thread
|
||||
ret = pthread_setschedparam(dataProcessingThread, policy, ¶m);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ INCLUDES?= -I../commonFiles -I../slsDetector -I ../MySocketTCP -I../usersFuncti
|
||||
LIBDIR?=../
|
||||
LIBS?= -L$(LIBDIR) -lSlsDetector
|
||||
|
||||
LDFLAG= -L/usr/lib64/ -lpthread
|
||||
LDFLAG= -L/usr/lib64/ -pthread
|
||||
|
||||
|
||||
DESTDIR ?= bin
|
||||
|
||||
@@ -2,7 +2,7 @@ CFLAGS= -DC_ONLY
|
||||
FLAGS=-DVERBOSE
|
||||
INCLUDES= -I../slsDetectorSoftware/commonFiles -I../slsDetectorSoftware/slsDetector -I ../slsDetectorSoftware/MySocketTCP -I../slsDetectorSoftware/usersFunctions -I../slsDetectorSoftware/multiSlsDetector -I../slsDetectorSoftware/slsDetectorAnalysis
|
||||
LIBS= -L../slsDetectorSoftware/
|
||||
LDFLAG= -lSlsDetector -lpthread
|
||||
LDFLAG= -lSlsDetector -pthread
|
||||
|
||||
EPICSFLAGS=-DEPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom
|
||||
|
||||
|
||||
@@ -72,14 +72,12 @@ int getChip(sls_detector_chip *myChip);
|
||||
|
||||
|
||||
#ifdef EIGERD
|
||||
int setModule(sls_detector_module myMod, int* gain, int* offset,int* delay);
|
||||
int getModule(sls_detector_module *myMod, int* gain, int* offset);
|
||||
int setModule(sls_detector_module myMod, int delay);
|
||||
#else
|
||||
int setModule(sls_detector_module myMod);
|
||||
int getModule(sls_detector_module *myMod);
|
||||
#endif
|
||||
|
||||
|
||||
int getModule(sls_detector_module *myMod);
|
||||
enum detectorSettings setSettings(enum detectorSettings sett, int imod);
|
||||
enum detectorSettings getSettings();
|
||||
|
||||
@@ -150,7 +148,7 @@ enum synchronizationMode setSynchronization(enum synchronizationMode arg);
|
||||
#ifdef EIGERD
|
||||
int startReceiver(int d);
|
||||
void setExternalGating(int enable[]);
|
||||
void setAllTrimbits(int val);
|
||||
int setAllTrimbits(int val);
|
||||
int getAllTrimbits();
|
||||
int getBebFPGATemp();
|
||||
int activate(int enable);
|
||||
|
||||
@@ -1246,8 +1246,25 @@ int set_dac(int file_des) {
|
||||
retval[0] = setHighVoltage(val,imod);
|
||||
else if(ind == IO_DELAY)
|
||||
retval[0] = setIODelay(val,imod);
|
||||
else
|
||||
else{
|
||||
setDAC(idac,val,imod,mV,retval);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1867,10 +1884,9 @@ int set_module(int file_des) {
|
||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||
sls_detector_module myModule;
|
||||
#ifdef EIGERD
|
||||
int *myGain = (int*)malloc(getNumberOfGainsPerModule()*sizeof(int));
|
||||
int *myOffset = (int*)malloc(getNumberOfOffsetsPerModule()*sizeof(int));
|
||||
int *myIODelay = (int*)malloc(sizeof(int));
|
||||
int64_t myTau=-1;
|
||||
int myIODelay = -1;
|
||||
int myTau = -1;
|
||||
int myEV = -1;
|
||||
#endif
|
||||
int *myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int));
|
||||
int *myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int));
|
||||
@@ -1902,16 +1918,6 @@ int set_module(int file_des) {
|
||||
sprintf(mess,"could not allocate chans\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
#ifdef EIGERD
|
||||
if (!myGain){
|
||||
sprintf(mess,"could not allocate gains\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
if (!myOffset){
|
||||
sprintf(mess,"could not allocate offsets\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
#endif
|
||||
myModule.nchip=getNumberOfChipsPerModule();
|
||||
myModule.nchan=getNumberOfChannelsPerModule();
|
||||
myModule.ndac=getNumberOfDACsPerModule();
|
||||
@@ -1923,10 +1929,9 @@ int set_module(int file_des) {
|
||||
#endif
|
||||
ret=receiveModule(file_des, &myModule);
|
||||
#ifdef EIGERD
|
||||
n = receiveData(file_des,myGain,sizeof(int)*getNumberOfGainsPerModule(),INT32);
|
||||
n = receiveData(file_des,myOffset,sizeof(int)*getNumberOfOffsetsPerModule(),INT32);
|
||||
n = receiveData(file_des,myIODelay,sizeof(int),INT32);
|
||||
n = receiveData(file_des,&myTau,sizeof(myTau),INT64);
|
||||
n = receiveData(file_des,&myIODelay,sizeof(myIODelay),INT32);
|
||||
n = receiveData(file_des,&myTau,sizeof(myTau),INT32);
|
||||
n = receiveData(file_des,&myEV,sizeof(myEV),INT32);
|
||||
#endif
|
||||
if (ret>=0)
|
||||
ret=OK;
|
||||
@@ -1937,17 +1942,14 @@ int set_module(int file_des) {
|
||||
#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);
|
||||
#ifdef EIGERD
|
||||
int i;
|
||||
for(i=0;i<getNumberOfGainsPerModule();i++)
|
||||
printf("gain[%d]:%d\t%f\n",i,myGain[i],((double)myGain[i]/1000));
|
||||
for(i=0;i<getNumberOfOffsetsPerModule();i++)
|
||||
printf("offset[%d]:%d\t%f\n",i,myOffset[i],((double)myOffset[i]/1000));
|
||||
printf("IO Delay:%d\n",*myIODelay);
|
||||
printf("Tau:%lld\n",(long long int)myTau);
|
||||
printf("IO Delay:%d\n",myIODelay);
|
||||
printf("Tau:%d\n",myTau);
|
||||
printf("eV:%d\n",myEV);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef EIGERD
|
||||
switch(myModule.reg){
|
||||
case GET_SETTINGS:
|
||||
case STANDARD:
|
||||
case HIGHGAIN:
|
||||
case LOWGAIN:
|
||||
@@ -1961,7 +1963,7 @@ int set_module(int file_des) {
|
||||
cprintf(RED,"%s",mess);
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (ret==OK) {
|
||||
if (differentClients==1 && lockStatus==1) {
|
||||
@@ -1969,33 +1971,39 @@ int set_module(int file_des) {
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
} else {
|
||||
#ifdef EIGERD
|
||||
ret=setModule(myModule, myGain, myOffset,myIODelay);
|
||||
//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
|
||||
if(myTau > -2){ //ignore -2: from load settings)
|
||||
|
||||
//set default tau value (-1 or a normal value)
|
||||
setDefaultSettingsTau_in_nsec(myTau);
|
||||
|
||||
//switch off rate correction: no value read from load calib/load settings)
|
||||
if(myTau == -1){
|
||||
if(getRateCorrectionEnable()){
|
||||
ret = FAIL;
|
||||
setRateCorrection(0);
|
||||
strcat(mess,"Cannot set Rate correction. No default tau provided. Deactivating Rate Correction\n");
|
||||
cprintf(RED,"%s",mess);
|
||||
}
|
||||
//switch off rate correction: no value read from load calib/load settings)
|
||||
if(myTau == -1){
|
||||
if(getRateCorrectionEnable()){
|
||||
ret = FAIL;
|
||||
setRateCorrection(0);
|
||||
strcat(mess,"Cannot set Rate correction. No default tau provided. Deactivating Rate Correction\n");
|
||||
cprintf(RED,"%s",mess);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//normal tau value (only if enabled)
|
||||
else if (getRateCorrectionEnable()){
|
||||
int64_t retvalTau = setRateCorrection(myTau); //myTau will not be -1 here
|
||||
//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
|
||||
@@ -2027,10 +2035,6 @@ int set_module(int file_des) {
|
||||
free(myChan);
|
||||
free(myDac);
|
||||
free(myAdc);
|
||||
#ifdef EIGERD
|
||||
free(myGain);
|
||||
free(myOffset);
|
||||
#endif
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
@@ -2048,10 +2052,6 @@ int get_module(int file_des) {
|
||||
sls_detector_module myModule;
|
||||
|
||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||
#ifdef EIGERD
|
||||
int *myGain = (int*)malloc(getNumberOfGainsPerModule()*sizeof(int));
|
||||
int *myOffset = (int*)malloc(getNumberOfOffsetsPerModule()*sizeof(int));
|
||||
#endif
|
||||
int *myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int));
|
||||
int *myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int));
|
||||
int *myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int));
|
||||
@@ -2082,16 +2082,6 @@ int get_module(int file_des) {
|
||||
sprintf(mess,"could not allocate chans\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
#ifdef EIGERD
|
||||
if (!myGain){
|
||||
sprintf(mess,"could not allocate gains\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
if (!myOffset){
|
||||
sprintf(mess,"could not allocate offsets\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
#endif
|
||||
myModule.ndac=getNumberOfDACsPerModule();
|
||||
myModule.nchip=getNumberOfChipsPerModule();
|
||||
myModule.nchan=getNumberOfChannelsPerModule();
|
||||
@@ -2114,18 +2104,7 @@ int get_module(int file_des) {
|
||||
if (imod>=0) {
|
||||
ret=OK;
|
||||
myModule.module=imod;
|
||||
#ifdef EIGERD
|
||||
getModule(&myModule, myGain, myOffset);
|
||||
#ifdef VERBOSE
|
||||
for(i=0;i<getNumberOfGainsPerModule();i++)
|
||||
printf("gain[%d]:%d\t%f\n",i,myGain[i],((double)myGain[i]/1000));
|
||||
for(i=0;i<getNumberOfOffsetsPerModule();i++)
|
||||
printf("offset[%d]:%d\t%f\n",i,myOffset[i],((double)myOffset[i]/1000));
|
||||
#endif
|
||||
#else
|
||||
getModule(&myModule);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Returning module %d of register %x\n", imod, myModule.reg);
|
||||
@@ -2144,10 +2123,6 @@ int get_module(int file_des) {
|
||||
if (ret!=FAIL) {
|
||||
/* send return argument */
|
||||
ret=sendModule(file_des, &myModule);
|
||||
#ifdef EIGERD
|
||||
n = sendData(file_des,myGain,sizeof(int)*getNumberOfGainsPerModule(),INT32);
|
||||
n = sendData(file_des,myOffset,sizeof(int)*getNumberOfOffsetsPerModule(),INT32);
|
||||
#endif
|
||||
} else {
|
||||
n += sendData(file_des,mess,sizeof(mess),OTHER);
|
||||
}
|
||||
@@ -2157,10 +2132,6 @@ int get_module(int file_des) {
|
||||
free(myChan);
|
||||
free(myDac);
|
||||
free(myAdc);
|
||||
#ifdef EIGERD
|
||||
free(myGain);
|
||||
free(myOffset);
|
||||
#endif
|
||||
#endif
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
@@ -2300,7 +2271,7 @@ int set_threshold_energy(int file_des) {
|
||||
int ret=OK,ret1=OK;
|
||||
int arg[3];
|
||||
int n;
|
||||
#if defined(MYTHEND) || defined(EIGERD)
|
||||
#if defined(MYTHEND)
|
||||
int ethr, imod;
|
||||
enum detectorSettings isett;
|
||||
#endif
|
||||
@@ -2311,7 +2282,7 @@ int set_threshold_energy(int file_des) {
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
#if defined(MYTHEND) || defined(EIGERD)
|
||||
#if defined(MYTHEND)
|
||||
ethr=arg[0];
|
||||
imod=arg[1];
|
||||
isett=arg[2];
|
||||
@@ -2338,6 +2309,14 @@ int set_threshold_energy(int file_des) {
|
||||
sprintf(mess,"Setting threshold of module %d: wrote %d but read %d\n", imod, ethr, retval);
|
||||
}
|
||||
#endif
|
||||
#elif defined(EIGERD)
|
||||
sprintf(mess,"Setting Threshold only via settings implemented for this detector\n");
|
||||
cprintf(RED, "%s",mess);
|
||||
ret=FAIL;
|
||||
#else
|
||||
sprintf(mess,"Not implemented for this detector\n");
|
||||
cprintf(RED, "%s",mess);
|
||||
ret=FAIL;
|
||||
#endif
|
||||
if (ret==OK && differentClients==1)
|
||||
ret=FORCE_UPDATE;
|
||||
@@ -3741,8 +3720,12 @@ int set_all_trimbits(int file_des){
|
||||
ret = FAIL;
|
||||
strcpy(mess,"Cant set trimbits to this value\n");
|
||||
}else {
|
||||
if(arg >= 0)
|
||||
setAllTrimbits(arg);
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -3993,39 +3976,28 @@ int set_rate_correct(int file_des) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
} else {
|
||||
|
||||
//tau = -1, use default tau of settings
|
||||
if((ret==OK)&&(tau_ns<0)){
|
||||
tau_ns = getDefaultSettingsTau_in_nsec();
|
||||
}
|
||||
//still negative (not set)
|
||||
if(tau_ns < 0){
|
||||
ret = FAIL;
|
||||
if(getRateCorrectionEnable()){
|
||||
setRateCorrection(0);
|
||||
strcpy(mess,"Cannot set rate correction as default tau not provided. Switching off Rate Correction\n");
|
||||
}else{
|
||||
strcpy(mess,"Cannot set rate correction as default tau not provided\n");
|
||||
}
|
||||
cprintf(RED,"%s",mess);
|
||||
}
|
||||
|
||||
//set rate
|
||||
//wrong bit mode
|
||||
if((setDynamicRange(-1)!=32) && (setDynamicRange(-1)!=16) && (tau_ns!=0)){
|
||||
strcpy(mess,"Rate correction Deactivated, must be in 32 or 16 bit mode\n");
|
||||
cprintf(RED,"%s",mess);
|
||||
ret=FAIL;
|
||||
}
|
||||
//16 or 32 bit mode
|
||||
else{
|
||||
//not 32 or 16 bit mode
|
||||
if((setDynamicRange(-1)!=32) && (setDynamicRange(-1)!=16) && (tau_ns!=0)){
|
||||
strcpy(mess,"Rate correction Deactivated, must be in 32 or 16 bit mode\n");
|
||||
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){
|
||||
cprintf(RED,"%s",mess);
|
||||
ret=FAIL;
|
||||
}
|
||||
//32 bit mode
|
||||
else{
|
||||
int64_t retval = setRateCorrection(tau_ns); //tau_ns will not be -1 here
|
||||
if(tau_ns != retval){
|
||||
cprintf(RED,"%s",mess);
|
||||
ret=FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,20 +2,20 @@ OBJPATH=bin/obj
|
||||
EXAMPLEPATH=bin/example
|
||||
|
||||
all:
|
||||
g++ CondVar.cpp -lpthread -c -g -o $(OBJPATH)/CondVar.o
|
||||
g++ Mutex.cpp -lpthread -c -g -o $(OBJPATH)/Mutex.o
|
||||
#g++ Task.cpp -lpthread -c -g -o $(OBJPATH)/Task.o
|
||||
g++ ThreadPool.cpp -lpthread -c -g -o $(OBJPATH)/ThreadPool.o
|
||||
g++ Multi.cpp -lpthread -c -g -o $(OBJPATH)/Multi.o
|
||||
#g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/Task.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -lpthread -I . -g -o $(EXAMPLEPATH)threadpool_test
|
||||
g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -lpthread -I . -g -o $(EXAMPLEPATH)threadpool_test
|
||||
g++ CondVar.cpp -pthread -c -g -o $(OBJPATH)/CondVar.o
|
||||
g++ Mutex.cpp -pthread -c -g -o $(OBJPATH)/Mutex.o
|
||||
#g++ Task.cpp -pthread -c -g -o $(OBJPATH)/Task.o
|
||||
g++ ThreadPool.cpp -pthread -c -g -o $(OBJPATH)/ThreadPool.o
|
||||
g++ Multi.cpp -pthread -c -g -o $(OBJPATH)/Multi.o
|
||||
#g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/Task.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -pthread -I . -g -o $(EXAMPLEPATH)threadpool_test
|
||||
g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -pthread -I . -g -o $(EXAMPLEPATH)threadpool_test
|
||||
|
||||
#all:
|
||||
# g++ threadpool.cpp -lpthread -fpic -c -o bin/obj/threadpool.o
|
||||
# g++ -L./bin bin/obj/threadpool.o -lpthread threadpool_test.cpp -o bin/example/threadpool_test
|
||||
# g++ threadpool.cpp -pthread -fpic -c -o bin/obj/threadpool.o
|
||||
# g++ -L./bin bin/obj/threadpool.o -pthread threadpool_test.cpp -o bin/example/threadpool_test
|
||||
|
||||
#threadpool:
|
||||
# g++ threadpool.cpp -lpthread -fpic -c -o bin/obj/threadpool.o
|
||||
# g++ threadpool.cpp -pthread -fpic -c -o bin/obj/threadpool.o
|
||||
# g++ -shared -fPIC bin/obj/threadpool.o -o bin/lib/libthreadpool.so
|
||||
#example:
|
||||
# g++ -L./bin/lib -lthreadpool threadpool_test.cpp -o threadpool_test
|
||||
|
||||
@@ -24,8 +24,8 @@ public:
|
||||
~func00_t() {}
|
||||
void operator()() const {((m_ptr->*m_fn)());}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)();
|
||||
_Class* m_ptr;
|
||||
};
|
||||
|
||||
template<typename _Ret, typename _Class, typename _Store>
|
||||
@@ -36,8 +36,8 @@ public:
|
||||
~func0_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)());}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)();
|
||||
_Class* m_ptr;
|
||||
_Store* m_store;
|
||||
};
|
||||
|
||||
@@ -49,8 +49,8 @@ public:
|
||||
~func1_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1));}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)(_Arg1);
|
||||
_Class* m_ptr;
|
||||
_Arg1 m_arg1;
|
||||
_Store* m_store;
|
||||
};
|
||||
@@ -63,8 +63,8 @@ public:
|
||||
~func2_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2));}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)(_Arg1,_Arg2);
|
||||
_Class* m_ptr;
|
||||
_Arg1 m_arg1;
|
||||
_Arg2 m_arg2;
|
||||
_Store* m_store;
|
||||
@@ -78,8 +78,8 @@ public:
|
||||
~func3_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3));}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)(_Arg1,_Arg2,_Arg3);
|
||||
_Class* m_ptr;
|
||||
_Arg1 m_arg1;
|
||||
_Arg2 m_arg2;
|
||||
_Arg3 m_arg3;
|
||||
@@ -94,8 +94,8 @@ public:
|
||||
~func4_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3,m_arg4));}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)(_Arg1,_Arg2,_Arg3,_Arg4);
|
||||
_Class* m_ptr;
|
||||
_Arg1 m_arg1;
|
||||
_Arg2 m_arg2;
|
||||
_Arg3 m_arg3;
|
||||
@@ -106,29 +106,31 @@ private:
|
||||
class Task: public virtual slsDetectorDefs{
|
||||
public:
|
||||
/* Return: int, Param: int */
|
||||
Task(func1_t <int,slsDetector,int,int>* t): m1(t),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func1_t <int,slsDetector,int,int>* t): m1(t),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: int, Param: string,int */
|
||||
Task(func2_t <int,slsDetector,string,int,int>* t): m1(0),m2(t),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func2_t <int,slsDetector,string,int,int>* t): m1(0),m2(t),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: string, Param: string */
|
||||
Task(func1_t <string,slsDetector,string,string>* t): m1(0),m2(0),m3(t),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func1_t <string,slsDetector,string,string>* t): m1(0),m2(0),m3(t),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: char*, Param: char* */
|
||||
Task(func1_t <char*,slsDetector,char*,string>* t): m1(0),m2(0),m3(0),m4(t),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func1_t <char*,slsDetector,char*,string>* t): m1(0),m2(0),m3(0),m4(t),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: detectorSettings, Param: int */
|
||||
Task(func1_t <detectorSettings,slsDetector,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(t),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func1_t <detectorSettings,slsDetector,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(t),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: detectorSettings, Param: detectorSettings,int */
|
||||
Task(func2_t <detectorSettings,slsDetector,detectorSettings,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(t),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func2_t <detectorSettings,slsDetector,detectorSettings,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(t),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: int, Param: int,int */
|
||||
Task(func2_t <int,slsDetector,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(t),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
/* Return: int, Param: int,int */
|
||||
Task(func3_t <int,slsDetector,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(t),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func2_t <int,slsDetector,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(t),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: int, Param: int,int,int */
|
||||
Task(func3_t <int,slsDetector,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(t),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: int, Param: trimMode,int,int,int */
|
||||
Task(func4_t <int,slsDetector,trimMode,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(t),m10(0),m11(0),m12(0){};
|
||||
Task(func4_t <int,slsDetector,trimMode,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(t),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: int, Param: none */
|
||||
Task(func0_t <int,slsDetector,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(t),m11(0),m12(0){};
|
||||
/* Return: char*, Param: networkParameter,string,string */
|
||||
Task(func2_t <char*,slsDetector,networkParameter,string,string>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(t),m12(0){};
|
||||
Task(func0_t <int,slsDetector,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(t),m11(0),m12(0),m13(0){};
|
||||
/* Return: char*, Param: networkParameter,string */
|
||||
Task(func2_t <char*,slsDetector,networkParameter,string,string>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(t),m12(0),m13(0){};
|
||||
/* Return: void, Param: none */
|
||||
Task(func00_t <void,slsDetector>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(t){};
|
||||
Task(func00_t <void,slsDetector>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(t),m13(0){};
|
||||
/* Return: int, Param: int,int,detectorSettings,int */
|
||||
Task(func4_t <int,slsDetector,int,int,detectorSettings,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(t){};
|
||||
|
||||
|
||||
|
||||
@@ -147,6 +149,7 @@ public:
|
||||
else if(m10) (*m10)();
|
||||
else if(m11) (*m11)();
|
||||
else if(m12) (*m12)();
|
||||
else if(m13) (*m13)();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -164,16 +167,18 @@ private:
|
||||
func2_t <detectorSettings,slsDetector,detectorSettings,int,int>* m6;
|
||||
/* Return: int, Param: int,int */
|
||||
func2_t <int,slsDetector,int,int,int>* m7;
|
||||
/* Return: int, Param: int,int */
|
||||
/* Return: int, Param: int,int,int */
|
||||
func3_t <int,slsDetector,int,int,int,int>* m8;
|
||||
/* Return: int, Param: trimMode,int,int,int */
|
||||
func4_t <int,slsDetector,trimMode,int,int,int,int>* m9;
|
||||
/* Return: int, Param: int */
|
||||
func0_t <int,slsDetector,int>* m10;
|
||||
/* Return: char*, Param: networkParameter,string,string */
|
||||
/* Return: char*, Param: networkParameter,string */
|
||||
func2_t <char*,slsDetector,networkParameter,string,string>* m11;
|
||||
/* Return: void, Param: none */
|
||||
func00_t <void,slsDetector>* m12;
|
||||
/* Return: int, Param: int,int,detectorSettings */
|
||||
func4_t <int,slsDetector,int,int,detectorSettings,int,int>* m13;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -67,12 +67,13 @@ int ThreadPool::destroy_threadpool(){
|
||||
/*cout << "Broadcasting STOP signal to all threads..." << endl;*/
|
||||
m_task_cond_var.broadcast(); // notify all threads we are shttung down
|
||||
|
||||
int ret = -1;
|
||||
//int ret = -1;
|
||||
for (int i = 0; i < m_pool_size; i++) {
|
||||
void* result;
|
||||
sem_post(&semStart);
|
||||
sem_post(&semDone);
|
||||
ret = pthread_join(m_threads[i], &result);
|
||||
//ret =
|
||||
pthread_join(m_threads[i], &result);
|
||||
/*cout << "pthread_join() returned " << ret << ": " << strerror(errno) << endl;*/
|
||||
m_task_cond_var.broadcast(); // try waking up a bunch of threads that are still waiting
|
||||
}
|
||||
@@ -85,7 +86,8 @@ int ThreadPool::destroy_threadpool(){
|
||||
}
|
||||
|
||||
void* ThreadPool::execute_thread(){
|
||||
int ithread = current_thread_number;
|
||||
//for debugging seting ithread value
|
||||
// int ithread = current_thread_number;
|
||||
thread_started = true;
|
||||
Task* task = NULL;
|
||||
m_tasks_loaded = false;
|
||||
|
||||
@@ -54,7 +54,7 @@ $(BUILDDIR)/%.o : $(SRCDIR)/%.cpp Makefile
|
||||
ifeq ($(ROOTSLS),yes)
|
||||
$(CXX) -DROOTSLS -o $@ -c $< $(INCLUDES) $(DFLAGS) $(ROOTFLAGS) -fPIC $(EPICSFLAGS) $(LDFLAGRXR) -L/usr/lib64/ $(FLAGS)
|
||||
else
|
||||
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) $(LDFLAGRXR) -lpthread $(FLAGS) $(LIBZMQ) -lrt
|
||||
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) $(LDFLAGRXR) -pthread $(FLAGS) $(LIBZMQ) -lrt
|
||||
endif
|
||||
|
||||
lib: $(OBJS) $(DESTDIR)/libSlsReceiver.so $(DESTDIR)/libSlsReceiver.a
|
||||
@@ -63,7 +63,7 @@ receiver: $(DESTDIR)/slsReceiver
|
||||
|
||||
|
||||
$(DESTDIR)/libSlsReceiver.so: $(OBJS)
|
||||
$(CXX) -shared -Wl,-soname,libSlsReceiver.so -o libSlsReceiver.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64 -lpthread $(LIBZMQ) -lrt
|
||||
$(CXX) -shared -Wl,-soname,libSlsReceiver.so -o libSlsReceiver.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64 -pthread $(LIBZMQ) -lrt
|
||||
$(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR))
|
||||
mv libSlsReceiver.so $(DESTDIR)
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsReceiverSoftware
|
||||
URL: origin git@git.psi.ch:sls_detectors_software/sls_receiver_software.git
|
||||
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_receiver_software.git
|
||||
Repsitory UUID: 2f78f4e118bfba443f84a3f72b2839610a8858a3
|
||||
Revision: 493
|
||||
Branch: developer
|
||||
Repsitory UUID: 239415ea0db2b9cdccd9bce80f0c78216115ffea
|
||||
Revision: 527
|
||||
Branch: 2.3.2
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 493
|
||||
Last Changed Date: 2016-11-30 10:36:46 +0100
|
||||
Last Changed Rev: 527
|
||||
Last Changed Date: 2017-04-20 08:26:16 +0200
|
||||
|
||||
@@ -486,30 +486,40 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
* fileindex
|
||||
* datasize
|
||||
*
|
||||
* return value is the action which decides what the user and default responsibilities to save data are
|
||||
* 0 callback takes care of open,close,wrie file
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything
|
||||
* return value is insignificant at the moment
|
||||
* we write depending on file write enable
|
||||
* users get data to write depending on call backs registered
|
||||
*/
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg);
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg);
|
||||
|
||||
/**
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg);
|
||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg);
|
||||
|
||||
/**
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* framenum
|
||||
* datapointer
|
||||
* datasize in bytes
|
||||
* file descriptor
|
||||
* guidatapointer (NULL, no data required)
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
*/
|
||||
void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg);
|
||||
void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, void*),void *arg);
|
||||
|
||||
|
||||
|
||||
@@ -599,43 +609,54 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
|
||||
//***callback parameters***
|
||||
/**
|
||||
* function being called back for start acquisition
|
||||
* Call back for start acquisition
|
||||
* callback arguments are
|
||||
* filepath
|
||||
* filename
|
||||
* fileindex
|
||||
* datasize
|
||||
*
|
||||
* return value is
|
||||
* 0 callback takes care of open,close,wrie file
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything
|
||||
* return value is insignificant at the moment
|
||||
* we write depending on file write enable
|
||||
* users get data to write depending on call backs registered
|
||||
*/
|
||||
int (*startAcquisitionCallBack)(char*, char*,int, int, void*);
|
||||
int (*startAcquisitionCallBack)(char*, char*, uint64_t, uint32_t, void*);
|
||||
void *pStartAcquisition;
|
||||
|
||||
/**
|
||||
* function being called back for acquisition finished
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
void (*acquisitionFinishedCallBack)(int, void*);
|
||||
void (*acquisitionFinishedCallBack)(uint64_t, void*);
|
||||
void *pAcquisitionFinished;
|
||||
|
||||
|
||||
/**
|
||||
* function being called back for raw data
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* framenum
|
||||
* datapointer
|
||||
* datasize in bytes
|
||||
* file descriptor
|
||||
* guidatapointer (NULL, no data required)
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
*/
|
||||
void (*rawDataReadyCallBack)(int, char*, int, FILE*, char*, void*);
|
||||
void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, void*);
|
||||
void *pRawDataReady;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "logger.h"
|
||||
|
||||
|
||||
class UDPInterface {
|
||||
class UDPInterface: public Logger {
|
||||
|
||||
|
||||
/* abstract class that defines the UDP interface of an sls detector data receiver.
|
||||
@@ -543,30 +543,40 @@ class UDPInterface {
|
||||
* fileindex
|
||||
* datasize
|
||||
*
|
||||
* return value is
|
||||
* 0 callback takes care of open,close,wrie file
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything
|
||||
* return value is insignificant at the moment
|
||||
* we write depending on file write enable
|
||||
* users get data to write depending on call backs registered
|
||||
*/
|
||||
virtual void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg) = 0;
|
||||
virtual void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg) = 0;
|
||||
|
||||
/**
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
virtual void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg) = 0;
|
||||
virtual void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg) = 0;
|
||||
|
||||
/**
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* framenum
|
||||
* datapointer
|
||||
* datasize in bytes
|
||||
* file descriptor
|
||||
* guidatapointer (NULL, no data required)
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
*/
|
||||
virtual void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg) = 0;
|
||||
virtual void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, void*),void *arg) = 0;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@@ -630,7 +630,7 @@ private:
|
||||
bool fileCreateSuccess;
|
||||
|
||||
/** File header */
|
||||
const static unsigned int FILE_HEADER_SIZE = 500;
|
||||
const static unsigned int FILE_HEADER_SIZE = 1024;
|
||||
char fileHeader[MAX_NUMBER_OF_WRITER_THREADS][FILE_HEADER_SIZE];
|
||||
|
||||
/** File Descriptor */
|
||||
@@ -739,7 +739,7 @@ private:
|
||||
|
||||
//***data call back thread parameters***
|
||||
/** Ensures if zmq threads created successfully */
|
||||
bool zmqThreadStarted;
|
||||
volatile bool zmqThreadStarted;
|
||||
|
||||
/** Number of data callback Threads */
|
||||
int numberofDataCallbackThreads;
|
||||
@@ -760,7 +760,7 @@ private:
|
||||
|
||||
//***general and listening thread parameters***
|
||||
/** Ensures if threads created successfully */
|
||||
bool threadStarted;
|
||||
volatile bool threadStarted;
|
||||
|
||||
/** Current Thread Index*/
|
||||
int currentThreadIndex;
|
||||
@@ -832,12 +832,6 @@ private:
|
||||
pthread_mutex_t progressMutex;
|
||||
|
||||
|
||||
//***callback***
|
||||
/** The action which decides what the user and default responsibilities to save data are
|
||||
* 0 raw data ready callback takes care of open,close,write file
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything */
|
||||
int cbAction;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ bool CircularFifo<Element>::isEmpty() const
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::isFull() const
|
||||
{
|
||||
int tailCheck = (tail+1) % Capacity;
|
||||
int tailCheck = increment(tail);
|
||||
return (tailCheck == head);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ using namespace std;
|
||||
#define DEFAULT_BACKLOG 5
|
||||
#define DEFAULT_UDP_PORTNO 50001
|
||||
#define DEFAULT_GUI_PORTNO 65000
|
||||
#define DEFAULT_ZMQ_PORTNO 70001
|
||||
#define DEFAULT_ZMQ_PORTNO 40001
|
||||
|
||||
|
||||
|
||||
@@ -111,8 +111,8 @@ enum communicationProtocol{
|
||||
total_sent(0),// sender (client): where to? ip
|
||||
header_packet_size(0)
|
||||
{
|
||||
memset(&serverAddress, 0, sizeof(serverAddress));
|
||||
memset(&clientAddress, 0, sizeof(clientAddress));
|
||||
memset(&serverAddress, 0,sizeof(serverAddress));
|
||||
memset(&clientAddress,0,sizeof(clientAddress));
|
||||
// strcpy(hostname,host_ip_or_name);
|
||||
|
||||
strcpy(lastClientIP,"none");
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//#define SVNPATH ""
|
||||
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_receiver_software.git"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID "2f78f4e118bfba443f84a3f72b2839610a8858a3"
|
||||
//#define SVNREV 0x493
|
||||
#define SVNREPUUID "239415ea0db2b9cdccd9bce80f0c78216115ffea"
|
||||
//#define SVNREV 0x527
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "Dhanya_Maliakal"
|
||||
#define SVNREV 0x493
|
||||
#define SVNDATE 0x20161130
|
||||
#define SVNREV 0x527
|
||||
#define SVNDATE 0x20170420
|
||||
//
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//#ifndef __LOG_H__
|
||||
//#define __LOG_H__
|
||||
#ifndef __LOG_H__
|
||||
#define __LOG_H__
|
||||
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -7,240 +8,82 @@
|
||||
#include <unistd.h>
|
||||
#include <ansi.h>
|
||||
|
||||
#ifdef VERBOSE
|
||||
#define FILELOG_MAX_LEVEL logDEBUG
|
||||
#endif
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
#define FILELOG_MAX_LEVEL logDEBUG4
|
||||
#endif
|
||||
|
||||
#ifdef FIFODEBUG
|
||||
#define FILELOG_MAX_LEVEL logDEBUG5
|
||||
#elif VERYVERBOSE
|
||||
#define FILELOG_MAX_LEVEL logDEBUG4
|
||||
#elif VERBOSE
|
||||
#define FILELOG_MAX_LEVEL logDEBUG1
|
||||
#endif
|
||||
|
||||
#ifndef FILELOG_MAX_LEVEL
|
||||
#define FILELOG_MAX_LEVEL logINFO
|
||||
#endif
|
||||
|
||||
#define REPORT_LEVEL logDEBUG5
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define TOSTRING(x) STRINGIFY(x)
|
||||
#define MYCONCAT(x,y)
|
||||
#define __AT__ string(__FILE__) + string("::") + string(__func__) + string("(): ")
|
||||
#define __SHORT_FORM_OF_FILE__ \
|
||||
(strrchr(__FILE__,'/') \
|
||||
? strrchr(__FILE__,'/')+1 \
|
||||
: __FILE__ \
|
||||
)
|
||||
#define __SHORT_AT__ string(__SHORT_FORM_OF_FILE__) + string("::") + string(__func__) + string("(): ")
|
||||
|
||||
//":" TOSTRING(__LINE__)
|
||||
|
||||
/*
|
||||
void error(const char *location, const char *msg){
|
||||
printf("Error at %s: %s\n", location, msg);
|
||||
}
|
||||
*/
|
||||
|
||||
inline std::string NowTime();
|
||||
|
||||
enum TLogLevel {logERROR, logWARNING, logINFO, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5};
|
||||
|
||||
template <typename T> class Log{
|
||||
public:
|
||||
Log();
|
||||
virtual ~Log();
|
||||
std::ostringstream& Get(TLogLevel level = logINFO);
|
||||
static TLogLevel& ReportingLevel();
|
||||
static std::string ToString(TLogLevel level);
|
||||
static TLogLevel FromString(const std::string& level);
|
||||
protected:
|
||||
std::ostringstream os;
|
||||
TLogLevel lev;
|
||||
private:
|
||||
Log(const Log&);
|
||||
Log& operator =(const Log&);
|
||||
};
|
||||
|
||||
|
||||
class Output2FILE {
|
||||
public:
|
||||
static FILE*& Stream();
|
||||
static void Output(const std::string& msg);
|
||||
static void Output(const std::string& msg, TLogLevel level);
|
||||
};
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||
# if defined (BUILDING_FILELOG_DLL)
|
||||
# define FILELOG_DECLSPEC __declspec (dllexport)
|
||||
# elif defined (USING_FILELOG_DLL)
|
||||
# define FILELOG_DECLSPEC __declspec (dllimport)
|
||||
# else
|
||||
# define FILELOG_DECLSPEC
|
||||
# endif // BUILDING_DBSIMPLE_DLL
|
||||
#else
|
||||
# define FILELOG_DECLSPEC
|
||||
#endif // _WIN32
|
||||
|
||||
class FILELOG_DECLSPEC FILELog : public Log<Output2FILE> {};
|
||||
//typedef Log<Output2FILE> FILELog;
|
||||
|
||||
#ifdef REST
|
||||
#define FILE_LOG(level) \
|
||||
if (level > FILELOG_MAX_LEVEL) ; \
|
||||
else if (level > FILELog::ReportingLevel() || !Output2FILE::Stream()) ; \
|
||||
else FILELog().Get(level)
|
||||
#else
|
||||
#define FILE_LOG(level) \
|
||||
if (level > FILELOG_MAX_LEVEL) ; \
|
||||
else if (level > FILELog::ReportingLevel() || !Output2FILE::Stream()) ; \
|
||||
else FILELog().Get(level)
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
inline std::string NowTime()
|
||||
|
||||
{
|
||||
const int MAX_LEN = 200;
|
||||
char buffer[MAX_LEN];
|
||||
if (GetTimeFormatA(LOCALE_USER_DEFAULT, 0, 0,
|
||||
"HH':'mm':'ss", buffer, MAX_LEN) == 0)
|
||||
return "Error in NowTime()";
|
||||
|
||||
char result[100] = {0};
|
||||
static DWORD first = GetTickCount();
|
||||
sprintf(result, "%s.%03ld", buffer, (long)(GetTickCount() - first) % 1000);
|
||||
return result;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
inline std::string NowTime()
|
||||
{
|
||||
char buffer[11];
|
||||
time_t t;
|
||||
time(&t);
|
||||
tm r = {0};
|
||||
strftime(buffer, sizeof(buffer), "%X", localtime_r(&t, &r));
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, 0);
|
||||
char result[100] = {0};
|
||||
sprintf(result, "%s.%03ld", buffer, (long)tv.tv_usec / 1000);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif //WIN32
|
||||
class Logger {
|
||||
public:
|
||||
Logger(){};
|
||||
|
||||
enum TLogLevel {logERROR, logWARNING, logINFO, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5};
|
||||
|
||||
|
||||
template <typename T> Log<T>::Log():lev(logDEBUG){}
|
||||
static void FILE_LOG(TLogLevel level, char const* msg)
|
||||
{
|
||||
|
||||
template <typename T> std::ostringstream& Log<T>::Get(TLogLevel level)
|
||||
{
|
||||
lev = level;
|
||||
os << "- " << NowTime();
|
||||
os << " " << ToString(level) << ": ";
|
||||
os << std::string(level > logDEBUG ? level - logDEBUG : 0, '\t');
|
||||
return os;
|
||||
}
|
||||
if(level > FILELOG_MAX_LEVEL) return;
|
||||
|
||||
template <typename T> Log<T>::~Log()
|
||||
{
|
||||
os << std::endl;
|
||||
#ifdef REST
|
||||
T::Output( os.str());
|
||||
#else
|
||||
T::Output( os.str(),lev);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T> TLogLevel& Log<T>::ReportingLevel()
|
||||
{
|
||||
static TLogLevel reportingLevel = logDEBUG5;
|
||||
return reportingLevel;
|
||||
}
|
||||
|
||||
template <typename T> std::string Log<T>::ToString(TLogLevel level)
|
||||
{
|
||||
static const char* const buffer[] = {"ERROR", "WARNING", "INFO", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4","DEBUG5"};
|
||||
return buffer[level];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
TLogLevel Log<T>::FromString(const std::string& level)
|
||||
{
|
||||
if (level == "DEBUG5")
|
||||
return logDEBUG5;
|
||||
if (level == "DEBUG4")
|
||||
return logDEBUG4;
|
||||
if (level == "DEBUG3")
|
||||
return logDEBUG3;
|
||||
if (level == "DEBUG2")
|
||||
return logDEBUG2;
|
||||
if (level == "DEBUG1")
|
||||
return logDEBUG1;
|
||||
if (level == "DEBUG")
|
||||
return logDEBUG;
|
||||
if (level == "INFO")
|
||||
return logINFO;
|
||||
if (level == "WARNING")
|
||||
return logWARNING;
|
||||
if (level == "ERROR")
|
||||
return logERROR;
|
||||
Log<T>().Get(logWARNING) << "Unknown logging level '" << level << "'. Using INFO level as default.";
|
||||
return logINFO;
|
||||
}
|
||||
char buffer[11];
|
||||
const int buffer_len = sizeof(buffer);
|
||||
time_t t;
|
||||
time(&t);
|
||||
tm r = {0};
|
||||
strftime(buffer, buffer_len, "%X", localtime_r(&t, &r));
|
||||
buffer[buffer_len - 1] = 0;
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, 0);
|
||||
char result[100];
|
||||
const int result_len = sizeof(result);
|
||||
snprintf(result, result_len, "%s.%03ld", buffer, (long)tv.tv_usec / 1000);
|
||||
result[result_len - 1] = 0;
|
||||
|
||||
|
||||
inline FILE*& Output2FILE::Stream()
|
||||
{
|
||||
static FILE* pStream = stderr;
|
||||
return pStream;
|
||||
}
|
||||
/*
|
||||
const char* const slevel[] = {"ERROR", "WARNING", "INFO", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4","DEBUG5"};
|
||||
ostringstream os;
|
||||
os << "- " << string(result);
|
||||
os << " " << string(slevel[level]) << ": ";
|
||||
// if (level > logDEBUG)
|
||||
// os << std::string(level - logDEBUG, '\t');
|
||||
os << msg;
|
||||
string smessage = os.str();
|
||||
|
||||
inline void Output2FILE::Output(const std::string& msg)
|
||||
{
|
||||
FILE* pStream = Stream();
|
||||
if (!pStream)
|
||||
return;
|
||||
fprintf(pStream, "%s", msg.c_str());
|
||||
fflush(pStream);
|
||||
}
|
||||
switch(level){
|
||||
case logERROR: cprintf(RED BOLD, "%s\n", smessage.c_str()); break;
|
||||
case logWARNING: cprintf(YELLOW BOLD, "%s\n", smessage.c_str()); break;
|
||||
case logINFO: cprintf(GRAY, "%s\n", smessage.c_str()); break;
|
||||
default: break;
|
||||
}
|
||||
*/
|
||||
|
||||
inline void Output2FILE::Output(const std::string& msg, TLogLevel level)
|
||||
{
|
||||
FILE* pStream = Stream();
|
||||
if (!pStream)
|
||||
return;
|
||||
switch(level){
|
||||
case logERROR: cprintf(RED BOLD,"%s",msg.c_str()); break;
|
||||
case logWARNING: cprintf(YELLOW BOLD,"%s",msg.c_str()); break;
|
||||
case logINFO: cprintf(GRAY,"%s",msg.c_str());break;
|
||||
// case logINFO: cprintf(DARKGRAY BOLD,"%s",msg.c_str());break;
|
||||
default: fprintf(pStream,"%s",msg.c_str()); break;
|
||||
}
|
||||
fflush(pStream);
|
||||
}
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||
# if defined (BUILDING_FILELOG_DLL)
|
||||
# define FILELOG_DECLSPEC __declspec (dllexport)
|
||||
# elif defined (USING_FILELOG_DLL)
|
||||
# define FILELOG_DECLSPEC __declspec (dllimport)
|
||||
# else
|
||||
# define FILELOG_DECLSPEC
|
||||
# endif // BUILDING_DBSIMPLE_DLL
|
||||
#else
|
||||
# define FILELOG_DECLSPEC
|
||||
#endif // _WIN32
|
||||
switch(level){
|
||||
case logERROR: cprintf(RED BOLD, "- %s ERROR: %s \n", result, msg); break;
|
||||
case logWARNING: cprintf(YELLOW BOLD,"- %s WARNING: %s \n", result, msg); break;
|
||||
case logINFO: cprintf(GRAY, "- %s INFO: %s \n", result, msg); break;
|
||||
default: cprintf(GRAY, "- %s DEBUG: %s \n", result, msg); break;
|
||||
}
|
||||
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
//#endif //__LOG_H__
|
||||
};
|
||||
|
||||
|
||||
#endif //__LOG_H__
|
||||
|
||||
@@ -47,8 +47,7 @@ typedef struct {
|
||||
#define GOODBYE -200
|
||||
|
||||
#define DO_NOTHING 0
|
||||
#define CREATE_FILES 1
|
||||
#define DO_EVERYTHING 2
|
||||
#define DO_EVERYTHING 1
|
||||
|
||||
#define BUF_SIZE (16*1024*1024) //16mb
|
||||
#define SAMPLE_TIME_IN_NS 100000000//100ms
|
||||
@@ -58,8 +57,12 @@ typedef struct {
|
||||
#define HEADER_SIZE_NUM_PACKETS 1
|
||||
#define ALL_MASK_32 0xFFFFFFFF
|
||||
|
||||
#define FILE_FRAME_HEADER_LENGTH 16
|
||||
#define FILE_HEADER_BUNCHID_OFFSET 8
|
||||
#define SLS_DETECTOR_HEADER_VERSION 0x1
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
//#define FILE_FRAME_HEADER_LENGTH (8*3)
|
||||
//#define FILE_HEADER_TIMESTAMP_OFFSET 8 //start of frame/ bunch id
|
||||
//#define FILE_HEADER_EXPLENGTH_OFFSET 16 //exposure length/ sub frame number
|
||||
|
||||
|
||||
|
||||
//all max frames defined in sls_receiver_defs.h. 20000 gotthard, 100000 for short gotthard, 1000 for moench, eiger 20000
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*@short creates the UDP and TCP class objects
|
||||
*/
|
||||
|
||||
class slsReceiver : private virtual slsReceiverDefs {
|
||||
class slsReceiver : public Logger, private virtual slsReceiverDefs {
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -58,28 +58,48 @@ class slsReceiver : private virtual slsReceiverDefs {
|
||||
int64_t getReceiverVersion();
|
||||
|
||||
/**
|
||||
@sort register calbback for starting the acquisition
|
||||
@param func callback to be called when starting the acquisition. Its arguments are filepath filename fileindex data size
|
||||
\returns 0 callback takes care of open,close,write file; 1 callback writes file, we have to open, close it; 2 we open, close, write file, callback does not do anything
|
||||
* Call back for start acquisition
|
||||
* callback arguments are
|
||||
* filepath
|
||||
* filename
|
||||
* fileindex
|
||||
* datasize
|
||||
*
|
||||
* return value is undefined at the moment
|
||||
* we write depending on file write enable
|
||||
* users get data to write depending on call backs registered
|
||||
*/
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg);
|
||||
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg);
|
||||
|
||||
/**
|
||||
callback argument is
|
||||
toatal farmes caught
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg);
|
||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg);
|
||||
|
||||
/**
|
||||
args to raw data ready callback are
|
||||
framenum
|
||||
datapointer
|
||||
datasize in bytes
|
||||
file descriptor
|
||||
guidatapointer (NULL, no data required)
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
*/
|
||||
void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg);
|
||||
void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, void*),void *arg);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*@short interface between receiver and client
|
||||
*/
|
||||
|
||||
class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
class slsReceiverTCPIPInterface : public Logger, private virtual slsReceiverDefs {
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -65,31 +65,40 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
* fileindex
|
||||
* datasize
|
||||
*
|
||||
* return value is the action which decides what the user and default responsibilities to save data are
|
||||
* 0 callback takes care of open,close,wrie file
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything
|
||||
* return value is insignificant at the moment
|
||||
* we write depending on file write enable
|
||||
* users get data to write depending on call backs registered
|
||||
*/
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg);
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg);
|
||||
|
||||
/**
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg);
|
||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg);
|
||||
|
||||
/**
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* framenum
|
||||
* datapointer
|
||||
* datasize in bytes
|
||||
* file descriptor
|
||||
* guidatapointer (NULL, no data required)
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
*/
|
||||
void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg);
|
||||
|
||||
void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, void*),void *arg);
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -292,40 +301,50 @@ private:
|
||||
|
||||
//***callback parameters***
|
||||
/**
|
||||
* function being called back for start acquisition
|
||||
* Call back for start acquisition
|
||||
* callback arguments are
|
||||
* filepath
|
||||
* filename
|
||||
* fileindex
|
||||
* datasize
|
||||
*
|
||||
* return value is
|
||||
* 0 callback takes care of open,close,wrie file
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything
|
||||
* return value is insignificant at the moment
|
||||
* we write depending on file write enable
|
||||
* users get data to write depending on call backs registered
|
||||
*/
|
||||
int (*startAcquisitionCallBack)(char*, char*,int, int, void*);
|
||||
int (*startAcquisitionCallBack)(char*, char*, uint64_t, uint32_t, void*);
|
||||
void *pStartAcquisition;
|
||||
|
||||
/**
|
||||
* function being called back for acquisition finished
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
void (*acquisitionFinishedCallBack)(int, void*);
|
||||
void (*acquisitionFinishedCallBack)(uint64_t, void*);
|
||||
void *pAcquisitionFinished;
|
||||
|
||||
|
||||
/**
|
||||
* function being called back for raw data
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* framenum
|
||||
* datapointer
|
||||
* datasize in bytes
|
||||
* file descriptor
|
||||
* guidatapointer (NULL, no data required)
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
*/
|
||||
void (*rawDataReadyCallBack)(int, char*, int, FILE*, char*, void*);
|
||||
void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, void*);
|
||||
void *pRawDataReady;
|
||||
|
||||
|
||||
|
||||
@@ -55,13 +55,10 @@ public:
|
||||
/**
|
||||
|
||||
@sort register calbback for starting the acquisition
|
||||
\param func callback to be called when starting the acquisition. Its arguments are filepath filename fileindex data size
|
||||
|
||||
\returns 0 callback takes care of open,close,write file; 1 callback writes file, we have to open, close it; 2 we open, close, write file, callback does not do anything
|
||||
|
||||
\param func callback to be called when starting the acquisition. Its arguments are filepath, filename, fileindex, datasize
|
||||
\return value is insignificant at the moment, we write depending on file write enable, users get data to write depending on call backs registered
|
||||
*/
|
||||
|
||||
void registerCallBackStartAcquisition(int (*func)(char* filepath, char* filename,int fileindex, int datasize, void*),void *arg);
|
||||
void registerCallBackStartAcquisition(int (*func)(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*),void *arg);
|
||||
|
||||
|
||||
/**
|
||||
@@ -69,20 +66,19 @@ public:
|
||||
\param func end of acquisition callback. Argument nf is total frames caught
|
||||
\returns nothing
|
||||
*/
|
||||
|
||||
|
||||
void registerCallBackAcquisitionFinished(void (*func)(int nf, void*),void *arg);
|
||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t nf, void*),void *arg);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@sort register callback to be called when data are available (to process and/or save the data).
|
||||
\param func raw data ready callback. arguments are framenum datapointer datasize file descriptor guidatapointer (NULL, no data required)
|
||||
\returns nothing
|
||||
*/
|
||||
\param func raw data ready callback. arguments are frameNumber, expLength, packetNumber, bunchId, timestamp, modId, xCoord, yCoord, zCoord, debug, roundRNumber, detType, version, dataPointer, dataSize
|
||||
\returns nothing
|
||||
*/
|
||||
void registerCallBackRawDataReady(void (*func)(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp,
|
||||
uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version,
|
||||
char* datapointer, uint32_t datasize, void*),void *arg);
|
||||
|
||||
void registerCallBackRawDataReady(void (*func)(int framenumber, char* datapointer, int datasize, FILE* filedescriptor, char* guidatapointer, void*),void *arg);
|
||||
|
||||
//receiver object
|
||||
slsReceiver* receiver;
|
||||
};
|
||||
|
||||
@@ -116,6 +116,40 @@ public:
|
||||
STOPPED /**< acquisition stopped externally */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
/** returns string from enabled/disabled
|
||||
\param b true or false
|
||||
|
||||
@@ -19,7 +19,6 @@ using namespace std;
|
||||
* They access local cache of configuration or detector parameters *******
|
||||
*************************************************************************/
|
||||
UDPBaseImplementation::UDPBaseImplementation(){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
initializeMembers();
|
||||
|
||||
@@ -33,9 +32,7 @@ UDPBaseImplementation::UDPBaseImplementation(){
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::initializeMembers(){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
FILE_LOG(logDEBUG) << "Info: Initializing base members";
|
||||
//**detector parameters***
|
||||
myDetectorType = GENERIC;
|
||||
strcpy(detHostname,"");
|
||||
@@ -93,7 +90,6 @@ UDPBaseImplementation::~UDPBaseImplementation(){}
|
||||
|
||||
/**initial parameters***/
|
||||
char *UDPBaseImplementation::getDetectorHostname() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
//not initialized
|
||||
if(!strlen(detHostname))
|
||||
@@ -106,7 +102,6 @@ char *UDPBaseImplementation::getDetectorHostname() const{
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::getFlippedData(int axis) const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
if(axis<0 || axis > 1) return -1;
|
||||
return flippedData[axis];
|
||||
}
|
||||
@@ -114,7 +109,6 @@ int UDPBaseImplementation::getFlippedData(int axis) const{
|
||||
|
||||
/***file parameters***/
|
||||
char *UDPBaseImplementation::getFileName() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
//not initialized
|
||||
if(!strlen(fileName))
|
||||
@@ -127,7 +121,6 @@ char *UDPBaseImplementation::getFileName() const{
|
||||
}
|
||||
|
||||
char *UDPBaseImplementation::getFilePath() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
//not initialized
|
||||
if(!strlen(filePath))
|
||||
@@ -139,25 +132,24 @@ char *UDPBaseImplementation::getFilePath() const{
|
||||
return output;
|
||||
}
|
||||
|
||||
uint64_t UDPBaseImplementation::getFileIndex() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return fileIndex;}
|
||||
uint64_t UDPBaseImplementation::getFileIndex() const{ return fileIndex;}
|
||||
|
||||
int UDPBaseImplementation::getScanTag() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return scanTag;}
|
||||
int UDPBaseImplementation::getScanTag() const{ return scanTag;}
|
||||
|
||||
bool UDPBaseImplementation::getFrameIndexEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return frameIndexEnable;}
|
||||
bool UDPBaseImplementation::getFrameIndexEnable() const{ return frameIndexEnable;}
|
||||
|
||||
bool UDPBaseImplementation::getFileWriteEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return fileWriteEnable;}
|
||||
bool UDPBaseImplementation::getFileWriteEnable() const{ return fileWriteEnable;}
|
||||
|
||||
bool UDPBaseImplementation::getOverwriteEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return overwriteEnable;}
|
||||
bool UDPBaseImplementation::getOverwriteEnable() const{ return overwriteEnable;}
|
||||
|
||||
bool UDPBaseImplementation::getDataCompressionEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return dataCompressionEnable;}
|
||||
bool UDPBaseImplementation::getDataCompressionEnable() const{ return dataCompressionEnable;}
|
||||
|
||||
/***acquisition count parameters***/
|
||||
uint64_t UDPBaseImplementation::getTotalFramesCaught() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return (totalPacketsCaught/packetsPerFrame);}
|
||||
uint64_t UDPBaseImplementation::getTotalFramesCaught() const{ return (totalPacketsCaught/packetsPerFrame);}
|
||||
|
||||
uint64_t UDPBaseImplementation::getFramesCaught() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return (packetsCaught/packetsPerFrame);}
|
||||
uint64_t UDPBaseImplementation::getFramesCaught() const{ return (packetsCaught/packetsPerFrame);}
|
||||
|
||||
int64_t UDPBaseImplementation::getAcquisitionIndex() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
if(!totalPacketsCaught)
|
||||
return -1;
|
||||
@@ -166,12 +158,12 @@ int64_t UDPBaseImplementation::getAcquisitionIndex() const{
|
||||
|
||||
|
||||
/***connection parameters***/
|
||||
uint32_t UDPBaseImplementation::getUDPPortNumber() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return udpPortNum[0];}
|
||||
uint32_t UDPBaseImplementation::getUDPPortNumber() const{ return udpPortNum[0];}
|
||||
|
||||
uint32_t UDPBaseImplementation::getUDPPortNumber2() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return udpPortNum[1];}
|
||||
uint32_t UDPBaseImplementation::getUDPPortNumber2() const{ return udpPortNum[1];}
|
||||
|
||||
char *UDPBaseImplementation::getEthernetInterface() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
|
||||
char* output = new char[MAX_STR_LENGTH]();
|
||||
strcpy(output,eth);
|
||||
@@ -181,30 +173,30 @@ char *UDPBaseImplementation::getEthernetInterface() const{
|
||||
|
||||
|
||||
/***acquisition parameters***/
|
||||
int UDPBaseImplementation::getShortFrameEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return shortFrameEnable;}
|
||||
int UDPBaseImplementation::getShortFrameEnable() const{ return shortFrameEnable;}
|
||||
|
||||
uint32_t UDPBaseImplementation::getFrameToGuiFrequency() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return frameToGuiFrequency;}
|
||||
uint32_t UDPBaseImplementation::getFrameToGuiFrequency() const{ return frameToGuiFrequency;}
|
||||
|
||||
uint32_t UDPBaseImplementation::getFrameToGuiTimer() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return frameToGuiTimerinMS;}
|
||||
uint32_t UDPBaseImplementation::getFrameToGuiTimer() const{ return frameToGuiTimerinMS;}
|
||||
|
||||
uint32_t UDPBaseImplementation::getDataStreamEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return dataStreamEnable;}
|
||||
uint32_t UDPBaseImplementation::getDataStreamEnable() const{ return dataStreamEnable;}
|
||||
|
||||
uint64_t UDPBaseImplementation::getAcquisitionPeriod() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return acquisitionPeriod;}
|
||||
uint64_t UDPBaseImplementation::getAcquisitionPeriod() const{ return acquisitionPeriod;}
|
||||
|
||||
uint64_t UDPBaseImplementation::getAcquisitionTime() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return acquisitionTime;}
|
||||
uint64_t UDPBaseImplementation::getAcquisitionTime() const{ return acquisitionTime;}
|
||||
|
||||
uint64_t UDPBaseImplementation::getNumberOfFrames() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return numberOfFrames;}
|
||||
uint64_t UDPBaseImplementation::getNumberOfFrames() const{ return numberOfFrames;}
|
||||
|
||||
uint32_t UDPBaseImplementation::getDynamicRange() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return dynamicRange;}
|
||||
uint32_t UDPBaseImplementation::getDynamicRange() const{ return dynamicRange;}
|
||||
|
||||
bool UDPBaseImplementation::getTenGigaEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return tengigaEnable;}
|
||||
bool UDPBaseImplementation::getTenGigaEnable() const{ return tengigaEnable;}
|
||||
|
||||
uint32_t UDPBaseImplementation::getFifoDepth() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return fifoDepth;}
|
||||
uint32_t UDPBaseImplementation::getFifoDepth() const{ return fifoDepth;}
|
||||
|
||||
/***receiver status***/
|
||||
slsReceiverDefs::runStatus UDPBaseImplementation::getStatus() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return status;}
|
||||
slsReceiverDefs::runStatus UDPBaseImplementation::getStatus() const{ return status;}
|
||||
|
||||
int UDPBaseImplementation::getActivate() const{FILE_LOG(logDEBUG) << __AT__ << " starting"; return activated;}
|
||||
int UDPBaseImplementation::getActivate() const{ return activated;}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
@@ -214,29 +206,32 @@ int UDPBaseImplementation::getActivate() const{FILE_LOG(logDEBUG) << __AT__ << "
|
||||
|
||||
/**initial parameters***/
|
||||
void UDPBaseImplementation::configure(map<string, string> config_map){
|
||||
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
|
||||
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
|
||||
FILE_LOG(logERROR, " must be overridden by child classes");
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setFlippedData(int axis, int enable){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
if(axis<0 || axis>1) return;
|
||||
flippedData[axis] = enable==0?0:1;
|
||||
FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1];
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Flipped Data: %d , %d ", flippedData[0], flippedData[1]);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
|
||||
/***file parameters***/
|
||||
void UDPBaseImplementation::setFileName(const char c[]){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
if(strlen(c))
|
||||
strcpy(fileName, c);
|
||||
FILE_LOG(logINFO) << "File name:" << fileName;
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "File name: %s ", fileName);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setFilePath(const char c[]){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
if(strlen(c)){
|
||||
//check if filepath exists
|
||||
@@ -245,55 +240,67 @@ void UDPBaseImplementation::setFilePath(const char c[]){
|
||||
strcpy(filePath,c);
|
||||
else{
|
||||
strcpy(filePath,"");
|
||||
FILE_LOG(logWARNING) << "FilePath does not exist:" << filePath;
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "FilePath does not exist: %s ", filePath);
|
||||
FILE_LOG(logWARNING, cstreambuf);
|
||||
}
|
||||
strcpy(filePath, c);
|
||||
}
|
||||
FILE_LOG(logDEBUG) << "Info: File path:" << filePath;
|
||||
/*{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "File path:: %s ", filePath);
|
||||
FILE_LOG(logDEBUG, cstreambuf);
|
||||
}*/
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setFileIndex(const uint64_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
fileIndex = i;
|
||||
FILE_LOG(logINFO) << "File Index:" << fileIndex;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "File Index: %lu ", fileIndex);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
//FIXME: needed?
|
||||
void UDPBaseImplementation::setScanTag(const int i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
scanTag = i;
|
||||
FILE_LOG(logINFO) << "Scan Tag:" << scanTag;
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Scan Tag: %d ", scanTag);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setFrameIndexEnable(const bool b){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
frameIndexEnable = b;
|
||||
FILE_LOG(logINFO) << "Frame Index Enable: " << stringEnable(frameIndexEnable);
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Frame Index Enable: %s ", stringEnable(frameIndexEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setFileWriteEnable(const bool b){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
fileWriteEnable = b;
|
||||
FILE_LOG(logINFO) << "File Write Enable: " << stringEnable(fileWriteEnable);
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "File Write Enable: %s ", stringEnable(fileWriteEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setOverwriteEnable(const bool b){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
overwriteEnable = b;
|
||||
FILE_LOG(logINFO) << "Overwrite Enable: " << stringEnable(overwriteEnable);
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Overwrite Enable: %s ", stringEnable(overwriteEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::setDataCompressionEnable(const bool b){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
dataCompressionEnable = b;
|
||||
FILE_LOG(logINFO) << "Data Compression : " << stringEnable(dataCompressionEnable);
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Data Compression: %s ", stringEnable(dataCompressionEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overridden methods might return FAIL
|
||||
return OK;
|
||||
@@ -302,58 +309,65 @@ int UDPBaseImplementation::setDataCompressionEnable(const bool b){
|
||||
|
||||
/***connection parameters***/
|
||||
void UDPBaseImplementation::setUDPPortNumber(const uint32_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
udpPortNum[0] = i;
|
||||
FILE_LOG(logINFO) << "UDP Port Number[0]:" << udpPortNum[0];
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "UDP Port Number[0]: %u ", udpPortNum[0]);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setUDPPortNumber2(const uint32_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
udpPortNum[1] = i;
|
||||
FILE_LOG(logINFO) << "UDP Port Number[1]:" << udpPortNum[1];
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "UDP Port Number[1]: %u ", udpPortNum[1]);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setEthernetInterface(const char* c){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
strcpy(eth, c);
|
||||
FILE_LOG(logINFO) << "Ethernet Interface: " << eth;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Ethernet Interface: %s ", eth);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
|
||||
/***acquisition parameters***/
|
||||
void UDPBaseImplementation::setShortFrameEnable(const int i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
shortFrameEnable = i;
|
||||
FILE_LOG(logINFO) << "Short Frame Enable: " << stringEnable(shortFrameEnable);
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Short Frame Enable: %d ", shortFrameEnable);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::setFrameToGuiFrequency(const uint32_t freq){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
frameToGuiFrequency = freq;
|
||||
FILE_LOG(logINFO) << "Frame To Gui Frequency:" << frameToGuiFrequency;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Frame To Gui Frequency: %u ", frameToGuiFrequency);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
return OK;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setFrameToGuiTimer(const uint32_t time_in_ms){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
frameToGuiTimerinMS = time_in_ms;
|
||||
FILE_LOG(logINFO) << "Frame To Gui Timer:" << frameToGuiTimerinMS;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Frame To Gui Timer: %u ", frameToGuiTimerinMS);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
|
||||
uint32_t UDPBaseImplementation::setDataStreamEnable(const uint32_t enable){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
dataStreamEnable = enable;
|
||||
FILE_LOG(logINFO) << "Streaming Data from Receiver:" << dataStreamEnable;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Streaming Data from Receiver: %d ", dataStreamEnable);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
return OK;
|
||||
@@ -361,60 +375,66 @@ uint32_t UDPBaseImplementation::setDataStreamEnable(const uint32_t enable){
|
||||
|
||||
|
||||
int UDPBaseImplementation::setAcquisitionPeriod(const uint64_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
acquisitionPeriod = i;
|
||||
FILE_LOG(logINFO) << "Acquisition Period:" << (double)acquisitionPeriod/(1E9) << "s";
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Acquisition Period: %f s ", (double)acquisitionPeriod/(1E9));
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
return OK;
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::setAcquisitionTime(const uint64_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
acquisitionTime = i;
|
||||
FILE_LOG(logINFO) << "Acquisition Time:" << (double)acquisitionTime/(1E9) << "s";
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Acquisition Time: %f s ", (double)acquisitionTime/(1E9));
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
return OK;
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::setNumberOfFrames(const uint64_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
numberOfFrames = i;
|
||||
FILE_LOG(logINFO) << "Number of Frames:" << numberOfFrames;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Number of Frames: %lu ", numberOfFrames);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
return OK;
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::setDynamicRange(const uint32_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
dynamicRange = i;
|
||||
FILE_LOG(logINFO) << "Dynamic Range:" << dynamicRange;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Dynamic Range: %u ", dynamicRange);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
return OK;
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::setTenGigaEnable(const bool b){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
tengigaEnable = b;
|
||||
FILE_LOG(logINFO) << "Ten Giga Enable: " << stringEnable(tengigaEnable);
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Ten Giga Enable: %s ", stringEnable(tengigaEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overridden functions might return FAIL
|
||||
return OK;
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::setFifoDepth(const uint32_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
fifoDepth = i;
|
||||
FILE_LOG(logINFO) << "Fifo Depth: " << i;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Fifo Depth: %u ", i);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overridden functions might return FAIL
|
||||
return OK;
|
||||
@@ -428,96 +448,106 @@ int UDPBaseImplementation::setFifoDepth(const uint32_t i){
|
||||
|
||||
/***initial functions***/
|
||||
int UDPBaseImplementation::setDetectorType(const detectorType d){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
myDetectorType = d;
|
||||
//if eiger, set numberofListeningThreads = 2;
|
||||
FILE_LOG(logINFO) << "Detector Type:" << getDetectorType(d);
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Detector Type: %s ", getDetectorType(d).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::initialize(const char *c){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
if(strlen(c))
|
||||
strcpy(detHostname, c);
|
||||
FILE_LOG(logINFO) << "Detector Hostname:" << detHostname;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Detector Hostname: %s ", detHostname);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***acquisition functions***/
|
||||
void UDPBaseImplementation::resetAcquisitionCount(){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
|
||||
totalPacketsCaught = 0;
|
||||
FILE_LOG(logINFO) << "totalPacketsCaught:" << totalPacketsCaught;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Total Packets Caught: %lu ", totalPacketsCaught);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::startReceiver(char *c){
|
||||
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
|
||||
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
|
||||
|
||||
FILE_LOG(logERROR, " must be overridden by child classes");
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::stopReceiver(){
|
||||
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
|
||||
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
|
||||
|
||||
FILE_LOG(logERROR, " must be overridden by child classes");
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::startReadout(){
|
||||
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
|
||||
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
|
||||
|
||||
FILE_LOG(logERROR, " must be overridden by child classes");
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::shutDownUDPSockets(){
|
||||
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
|
||||
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
|
||||
|
||||
FILE_LOG(logERROR, " must be overridden by child classes");
|
||||
|
||||
//overridden functions might return FAIL
|
||||
return OK;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::readFrame(int ithread, char* c,char** raw, int64_t &startAcquisitionIndex, int64_t &startFrameIndex){
|
||||
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
|
||||
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
|
||||
|
||||
FILE_LOG(logERROR, " must be overridden by child classes");
|
||||
}
|
||||
|
||||
|
||||
//FIXME: needed, isnt stopReceiver enough?
|
||||
void UDPBaseImplementation::abort(){
|
||||
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
|
||||
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
|
||||
|
||||
FILE_LOG(logERROR, " must be overridden by child classes");
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::closeFile(int ithread){
|
||||
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
|
||||
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
|
||||
|
||||
FILE_LOG(logERROR, " must be overridden by child classes");
|
||||
}
|
||||
|
||||
|
||||
int UDPBaseImplementation::setActivate(int enable){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
if(enable != -1){
|
||||
activated = enable;
|
||||
FILE_LOG(logINFO) << "Activation: " << stringEnable(activated);
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Activation: %s ", stringEnable(activated).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
return activated;
|
||||
}
|
||||
|
||||
/***callback functions***/
|
||||
void UDPBaseImplementation::registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){
|
||||
void UDPBaseImplementation::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){
|
||||
startAcquisitionCallBack=func;
|
||||
pStartAcquisition=arg;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){
|
||||
void UDPBaseImplementation::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
|
||||
acquisitionFinishedCallBack=func;
|
||||
pAcquisitionFinished=arg;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){
|
||||
void UDPBaseImplementation::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, void*),void *arg){
|
||||
rawDataReadyCallBack=func;
|
||||
pRawDataReady=arg;
|
||||
}
|
||||
|
||||
@@ -22,18 +22,21 @@ using namespace std;
|
||||
|
||||
UDPInterface * UDPInterface::create(string receiver_type){
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Starting %s ", receiver_type.c_str());
|
||||
|
||||
if (receiver_type == "standard"){
|
||||
FILE_LOG(logINFO) << "Starting " << receiver_type;
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
return new UDPStandardImplementation();
|
||||
}
|
||||
#ifdef REST
|
||||
else if (receiver_type == "REST"){
|
||||
FILE_LOG(logINFO) << "Starting " << receiver_type;
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
return new UDPRESTImplementation();
|
||||
}
|
||||
#endif
|
||||
else{
|
||||
FILE_LOG(logWARNING) << "[ERROR] UDP interface not supported, using standard implementation";
|
||||
FILE_LOG(logWARNING, "[ERROR] UDP interface not supported, using standard implementation");
|
||||
return new UDPBaseImplementation();
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -104,7 +104,6 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
//start tcp server thread
|
||||
if(receiver->start() == slsReceiverDefs::OK){
|
||||
FILE_LOG(logDEBUG1) << "DONE!" << endl;
|
||||
string str;
|
||||
cin>>str;
|
||||
//wait and look for an exit keyword
|
||||
|
||||
@@ -106,23 +106,32 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
||||
|
||||
if( !fname.empty() ){
|
||||
try{
|
||||
FILE_LOG(logINFO) << "config file name " << fname;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "config file name : %s ",fname.c_str());
|
||||
FILE_LOG(logDEBUG1, cstreambuf);
|
||||
|
||||
success = read_config_file(fname, &tcpip_port_no, &configuration_map);
|
||||
//VERBOSE_PRINT("Read configuration file of " + iline + " lines");
|
||||
}
|
||||
catch(...){
|
||||
FILE_LOG(logERROR) << "Error opening configuration file " << fname ;
|
||||
success = FAIL;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Error opening configuration file : %s ",fname.c_str());
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
|
||||
success = FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(success != OK){
|
||||
FILE_LOG(logERROR) << "Failed: see output above for more information " ;
|
||||
FILE_LOG(logERROR, "Failed: see output above for more information ");
|
||||
}
|
||||
|
||||
if (success==OK){
|
||||
FILE_LOG(logINFO) << "SLS Receiver starting " << udp_interface_type << " on port " << tcpip_port_no << endl;
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "SLS Receiver starting %s on port %d ",udp_interface_type.c_str(), tcpip_port_no);
|
||||
FILE_LOG(logDEBUG1, cstreambuf);
|
||||
#ifdef REST
|
||||
udp_interface = UDPInterface::create(udp_interface_type);
|
||||
udp_interface->configure(configuration_map);
|
||||
@@ -160,7 +169,7 @@ int64_t slsReceiver::getReceiverVersion(){
|
||||
}
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){
|
||||
void slsReceiver::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){
|
||||
//tcpipInterface
|
||||
if(udp_interface)
|
||||
udp_interface->registerCallBackStartAcquisition(func,arg);
|
||||
@@ -170,7 +179,7 @@ void slsReceiver::registerCallBackStartAcquisition(int (*func)(char*, char*,int,
|
||||
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){
|
||||
void slsReceiver::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
|
||||
//tcpipInterface
|
||||
if(udp_interface)
|
||||
udp_interface->registerCallBackAcquisitionFinished(func,arg);
|
||||
@@ -179,7 +188,8 @@ void slsReceiver::registerCallBackAcquisitionFinished(void (*func)(int, void*),v
|
||||
}
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){
|
||||
void slsReceiver::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, void*),void *arg){
|
||||
//tcpipInterface
|
||||
if(udp_interface)
|
||||
udp_interface->registerCallBackRawDataReady(func,arg);
|
||||
|
||||
@@ -28,17 +28,17 @@ slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
||||
}
|
||||
|
||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface* rbase, int pn):
|
||||
myDetectorType(GOTTHARD),
|
||||
receiverBase(rbase),
|
||||
ret(OK),
|
||||
lockStatus(0),
|
||||
shortFrame(-1),
|
||||
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME),
|
||||
dynamicrange(16),
|
||||
killTCPServerThread(0),
|
||||
tenGigaEnable(0),
|
||||
portNumber(DEFAULT_PORTNO+2),
|
||||
mySock(NULL){
|
||||
myDetectorType(GOTTHARD),
|
||||
receiverBase(rbase),
|
||||
ret(OK),
|
||||
lockStatus(0),
|
||||
shortFrame(-1),
|
||||
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME),
|
||||
dynamicrange(16),
|
||||
killTCPServerThread(0),
|
||||
tenGigaEnable(0),
|
||||
portNumber(DEFAULT_PORTNO+2),
|
||||
mySock(NULL){
|
||||
|
||||
strcpy(SET_RECEIVER_ERR_MESSAGE,"Receiver not set up. Please use rx_hostname first.\n");
|
||||
|
||||
@@ -126,14 +126,17 @@ int slsReceiverTCPIPInterface::setPortNumber(int pn){
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::start(){
|
||||
FILE_LOG(logDEBUG) << "Creating TCP Server Thread" << endl;
|
||||
|
||||
FILE_LOG(logDEBUG1, "Creating TCP Server Thread");
|
||||
|
||||
killTCPServerThread = 0;
|
||||
if(pthread_create(&TCPServer_thread, NULL,startTCPServerThread, (void*) this)){
|
||||
cout << "Could not create TCP Server thread" << endl;
|
||||
return FAIL;
|
||||
}
|
||||
//#ifdef VERYVERBOSE
|
||||
FILE_LOG(logDEBUG) << "TCP Server thread created successfully." << endl;
|
||||
FILE_LOG(logDEBUG1, "TCP Server thread created successfully.");
|
||||
|
||||
//#endif
|
||||
return OK;
|
||||
}
|
||||
@@ -387,23 +390,27 @@ int slsReceiverTCPIPInterface::set_detector_type(){
|
||||
receiverBase->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady);
|
||||
}
|
||||
#endif
|
||||
myDetectorType = dr;
|
||||
ret=receiverBase->setDetectorType(myDetectorType);
|
||||
retval = myDetectorType;
|
||||
myDetectorType = dr;
|
||||
ret=receiverBase->setDetectorType(myDetectorType);
|
||||
retval = myDetectorType;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
//#ifdef VERYVERBOSE
|
||||
//#ifdef VERYVERBOSE
|
||||
if(ret!=FAIL)
|
||||
FILE_LOG(logDEBUG) << "detector type " << dr;
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Detector Type %d ", (int)dr);
|
||||
FILE_LOG(logDEBUG1, cstreambuf);
|
||||
}
|
||||
else
|
||||
cprintf(RED, "%s\n", mess);
|
||||
//#endif
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -470,7 +477,7 @@ int slsReceiverTCPIPInterface::set_file_name() {
|
||||
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -545,7 +552,7 @@ int slsReceiverTCPIPInterface::set_file_dir() {
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -617,7 +624,7 @@ int slsReceiverTCPIPInterface::set_file_index() {
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -695,7 +702,7 @@ int slsReceiverTCPIPInterface::set_frame_index() {
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -759,12 +766,16 @@ int slsReceiverTCPIPInterface::setup_udp(){
|
||||
receiverBase->setUDPPortNumber2(udpport2);
|
||||
//setup udpip
|
||||
//get ethernet interface or IP to listen to
|
||||
FILE_LOG(logINFO) << "Receiver UDP IP: " << args[0];
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Receiver UDP IP: %s ",args[0]);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
temp = genericSocket::ipToName(args[0]);
|
||||
if(temp=="none"){
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Failed to get ethernet interface or IP\n");
|
||||
FILE_LOG(logERROR) << mess;
|
||||
FILE_LOG(logERROR, "Failed to get ethernet interface or IP ");
|
||||
}
|
||||
else{
|
||||
strcpy(eth,temp.c_str());
|
||||
@@ -785,7 +796,10 @@ int slsReceiverTCPIPInterface::setup_udp(){
|
||||
}
|
||||
else{
|
||||
strcpy(retval,temp.c_str());
|
||||
FILE_LOG(logINFO) << "Reciever MAC Address: " << retval;
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "Reciever MAC Address: %s ",retval);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -793,14 +807,16 @@ int slsReceiverTCPIPInterface::setup_udp(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
// send answer
|
||||
mySock->SendDataOnly(&ret,sizeof(ret));
|
||||
if(ret==FAIL){
|
||||
FILE_LOG(logERROR) << mess;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
sprintf(cstreambuf, "%s ", mess);
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
mySock->SendDataOnly(mess,sizeof(mess));
|
||||
}
|
||||
mySock->SendDataOnly(retval,MAX_STR_LENGTH);
|
||||
@@ -849,7 +865,7 @@ int slsReceiverTCPIPInterface::start_receiver(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -897,7 +913,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -928,7 +944,7 @@ int slsReceiverTCPIPInterface::get_status(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -959,7 +975,7 @@ int slsReceiverTCPIPInterface::get_frames_caught(){
|
||||
}else retval=receiverBase->getTotalFramesCaught();
|
||||
#endif
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -991,7 +1007,7 @@ int slsReceiverTCPIPInterface::get_frame_index(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -1036,7 +1052,7 @@ int slsReceiverTCPIPInterface::reset_frames_caught(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -1105,7 +1121,7 @@ int slsReceiverTCPIPInterface::set_short_frame() {
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -1287,7 +1303,7 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -1468,7 +1484,7 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -1622,7 +1638,7 @@ int slsReceiverTCPIPInterface::propix_read_frame(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -1657,7 +1673,7 @@ int slsReceiverTCPIPInterface::propix_read_frame(){
|
||||
|
||||
int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
ret=OK;
|
||||
/*
|
||||
/*
|
||||
char fName[MAX_STR_LENGTH]="";
|
||||
int acquisitionIndex = -1;
|
||||
int frameIndex= -1;
|
||||
@@ -1889,7 +1905,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -1910,7 +1926,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
delete [] retval;
|
||||
delete [] origVal;
|
||||
delete [] raw;
|
||||
*/
|
||||
*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2052,7 +2068,7 @@ int slsReceiverTCPIPInterface::jungfrau_read_frame(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -2130,7 +2146,7 @@ int slsReceiverTCPIPInterface::set_read_frequency(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -2196,7 +2212,7 @@ int slsReceiverTCPIPInterface::set_read_receiver_timer(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -2259,7 +2275,7 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -2319,7 +2335,7 @@ int slsReceiverTCPIPInterface::enable_file_write(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -2347,7 +2363,7 @@ int slsReceiverTCPIPInterface::get_id(){
|
||||
#endif
|
||||
|
||||
if(mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -2371,43 +2387,43 @@ int64_t slsReceiverTCPIPInterface::getReceiverVersion(){
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::start_readout(){cprintf(BLUE,"In start readout!\n");
|
||||
ret=OK;
|
||||
enum runStatus retval;
|
||||
ret=OK;
|
||||
enum runStatus retval;
|
||||
|
||||
// execute action if the arguments correctly arrived
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||
if (receiverBase == NULL){
|
||||
strcpy(mess,SET_RECEIVER_ERR_MESSAGE);
|
||||
ret=FAIL;
|
||||
}
|
||||
/*else if(receiverBase->getStatus()!= IDLE){
|
||||
if (receiverBase == NULL){
|
||||
strcpy(mess,SET_RECEIVER_ERR_MESSAGE);
|
||||
ret=FAIL;
|
||||
}
|
||||
/*else if(receiverBase->getStatus()!= IDLE){
|
||||
strcpy(mess,"Can not start receiver readout while receiver not idle\n");
|
||||
ret = FAIL;
|
||||
}*/
|
||||
else{
|
||||
receiverBase->startReadout();
|
||||
retval = receiverBase->getStatus();
|
||||
if((retval == TRANSMITTING) || (retval == RUN_FINISHED) || (retval == IDLE))
|
||||
ret = OK;
|
||||
else
|
||||
ret = FAIL;
|
||||
}
|
||||
else{
|
||||
receiverBase->startReadout();
|
||||
retval = receiverBase->getStatus();
|
||||
if((retval == TRANSMITTING) || (retval == RUN_FINISHED) || (retval == IDLE))
|
||||
ret = OK;
|
||||
else
|
||||
ret = FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
// send answer
|
||||
mySock->SendDataOnly(&ret,sizeof(ret));
|
||||
if(ret==FAIL){
|
||||
cprintf(RED,"%s\n",mess);
|
||||
mySock->SendDataOnly(mess,sizeof(mess));
|
||||
}
|
||||
mySock->SendDataOnly(&retval,sizeof(retval));
|
||||
//return ok/fail
|
||||
return ret;
|
||||
// send answer
|
||||
mySock->SendDataOnly(&ret,sizeof(ret));
|
||||
if(ret==FAIL){
|
||||
cprintf(RED,"%s\n",mess);
|
||||
mySock->SendDataOnly(mess,sizeof(mess));
|
||||
}
|
||||
mySock->SendDataOnly(&retval,sizeof(retval));
|
||||
//return ok/fail
|
||||
return ret;
|
||||
|
||||
|
||||
}
|
||||
@@ -2483,7 +2499,7 @@ int slsReceiverTCPIPInterface::set_timer() {
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -2555,7 +2571,7 @@ int slsReceiverTCPIPInterface::enable_compression() {
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -2621,7 +2637,7 @@ int slsReceiverTCPIPInterface::set_detector_hostname() {
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -2722,7 +2738,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range() {
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -2790,7 +2806,7 @@ int slsReceiverTCPIPInterface::enable_overwrite() {
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -2860,7 +2876,7 @@ int slsReceiverTCPIPInterface::enable_tengiga() {
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -2932,7 +2948,7 @@ int slsReceiverTCPIPInterface::set_fifo_depth() {
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -3006,7 +3022,7 @@ int slsReceiverTCPIPInterface::set_activate() {
|
||||
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -3070,7 +3086,7 @@ int slsReceiverTCPIPInterface::set_flipped_data(){
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
FILE_LOG(logDEBUG1,"Force update" );
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
@@ -3393,17 +3409,18 @@ int slsReceiverTCPIPInterface::exec_command() {
|
||||
|
||||
|
||||
/***callback functions***/
|
||||
void slsReceiverTCPIPInterface::registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){
|
||||
void slsReceiverTCPIPInterface::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){
|
||||
startAcquisitionCallBack=func;
|
||||
pStartAcquisition=arg;
|
||||
}
|
||||
|
||||
void slsReceiverTCPIPInterface::registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){
|
||||
void slsReceiverTCPIPInterface::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
|
||||
acquisitionFinishedCallBack=func;
|
||||
pAcquisitionFinished=arg;
|
||||
}
|
||||
|
||||
void slsReceiverTCPIPInterface::registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){
|
||||
void slsReceiverTCPIPInterface::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, void*),void *arg){
|
||||
rawDataReadyCallBack=func;
|
||||
pRawDataReady=arg;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user