mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 15:27:13 +02:00
Compare commits
594 Commits
Author | SHA1 | Date | |
---|---|---|---|
26c829d766 | |||
3fde5c5b55 | |||
3e5f546ebe | |||
9833a7d330 | |||
8f9155e578 | |||
9df1eac3c1 | |||
5ededf9be4 | |||
56c504abbb | |||
4d6346e678 | |||
dc7e448759 | |||
e658cbacda | |||
1e6c6dea71 | |||
0e5d4d1d8e | |||
a2986784d3 | |||
befdcf7f36 | |||
02f5c472a8 | |||
75ed2cd2e4 | |||
3be045f9b6 | |||
8fae982802 | |||
128ec88b5f | |||
d5fc158330 | |||
864e6e4c81 | |||
343d96ff16 | |||
4142328437 | |||
6c797988c7 | |||
215c262981 | |||
081b809078 | |||
9263567cd8 | |||
58e90a85be | |||
025c836e25 | |||
5d5abae3f4 | |||
e2ad46386e | |||
308d44e452 | |||
69da61b1fb | |||
460168ce04 | |||
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 | |||
111856ed7b | |||
0fdbac981e | |||
bd1601c2eb | |||
2d1c91c0e0 | |||
64843c1c76 | |||
f464be38a3 | |||
ed3129029d | |||
983f517e07 | |||
2a508435c7 | |||
3c0ce23bc2 | |||
a67f9d50de | |||
28b0897dd7 | |||
dd9387ef29 | |||
657d3e5759 | |||
f61d819599 | |||
d9016c95de | |||
ce086fe79d | |||
790cef37ff | |||
37ea7d425f | |||
1fe810d9d1 | |||
09645cbba8 | |||
466f1506a5 | |||
0c8ca874e4 | |||
5445552b17 | |||
af8c750b5a | |||
52dbb7f9fc | |||
b131f268e0 | |||
c70f453de4 | |||
96d8478b46 | |||
09d146ee55 | |||
9031b3998b | |||
394526a9c3 | |||
55408118b1 | |||
0ed9ee0e5d | |||
9d106f6c93 | |||
21e4201bb8 | |||
ebf102b8d9 | |||
e6c7dfc440 | |||
c639477f28 | |||
45fc87240f | |||
b980640a4c | |||
7ffba557f6 | |||
f13a42feeb | |||
b1a3a224ff | |||
4292bf1ce8 | |||
c364b28922 | |||
b1f658c439 | |||
9ee9fdea96 | |||
7d860cc7cd | |||
cec2e5c6b4 | |||
5189640cd7 | |||
8298486f27 | |||
fd666605aa | |||
acb900961a | |||
44d6b0ffc0 | |||
b55414cd38 | |||
70326f8b10 | |||
3c48065b5a | |||
6f43e9fcde | |||
37c0b5bdc1 | |||
753ed306d9 | |||
a4d4b05c1d | |||
149610aa51 | |||
f09e5ebad8 | |||
4a96b90296 | |||
f6b753f5d7 | |||
7cbd21651b | |||
6a2adb48aa | |||
b8ffe24c5f | |||
1a64fc30ca | |||
33d0563133 | |||
5f4a38416a | |||
964c76ac60 | |||
9b9876e287 | |||
7b2be5b009 | |||
d30e4a4d1c | |||
400eef6712 | |||
475e217cc5 | |||
0b5dc3a5a1 | |||
5c9d610dc4 | |||
a0b28503d0 | |||
c2c7365566 | |||
dec82ab850 | |||
d335dfaae4 | |||
2677fe3729 | |||
38857d6845 | |||
580b8ec649 | |||
54658040dc | |||
7a0efe60c8 | |||
6b67122a8e | |||
5316316c66 | |||
7e9760559c | |||
a42854d9a7 | |||
c7adfd52f2 | |||
f7654f8c94 | |||
76435c5981 | |||
7ca629a128 | |||
55e0bbd04f | |||
b4461207a7 | |||
cf5978d730 | |||
385941d75e | |||
93f99f9aa8 | |||
6d04f1ad68 | |||
cb5fa6223a | |||
abfcfa7dea | |||
cb274095fd | |||
8aea36b4ef | |||
96e79c7b99 | |||
9effdab69b | |||
2eade342ad | |||
cbd077e984 | |||
01db6b988b | |||
a5c4434ae8 | |||
8fd1b9b617 | |||
c6dbeda8b7 | |||
52cf790dde | |||
39a2317d8d | |||
e4dcd1cb6b | |||
a337feba7f | |||
1825ebd426 | |||
96284fde87 | |||
a17e65c22f | |||
3a3e2e26d8 | |||
8caa9d8779 | |||
ede6ccd720 | |||
6df77b5ff2 | |||
3f9c5af61c | |||
57979ce970 | |||
d673367667 | |||
3b07fd602b | |||
e2299b5269 | |||
11d3392064 | |||
25780a2b4f | |||
947a0e5f41 | |||
e4a8933d97 | |||
771e5323b4 | |||
15cc7a21f5 | |||
7aae906c62 | |||
79d5a24af4 | |||
ff1b2ac19a | |||
11d3511460 | |||
d4733543ab | |||
78c1372950 | |||
44eb790f2d | |||
f7b7939ca1 | |||
8c53ce9f87 | |||
aee60c3dbc | |||
8066618345 | |||
493f3169f8 | |||
6f60f011d1 | |||
a659fa96dc | |||
fa9bac144f | |||
8b6689e167 | |||
f865026c3d | |||
a6423b30dd | |||
68241924a5 | |||
b89f0a1663 | |||
48ae4b4ec2 | |||
4b65c3b694 | |||
274fffa609 | |||
5fb38694d3 | |||
fbd0f01fa7 | |||
37cdb3db4f | |||
3a3e5668d7 | |||
3ed427e7f0 | |||
6498b20612 | |||
0cc89efb20 | |||
dfe39ef3e5 | |||
26d8d6e108 | |||
54458f0af0 | |||
b7ead7e61e | |||
20918f2d52 | |||
7c58f43717 | |||
3f66504f89 | |||
eeaaef1a99 | |||
df3e0f3f93 | |||
404323e13a | |||
7fdc127356 | |||
4b99ff7fbe | |||
5523bc4a09 | |||
2eac6cc116 | |||
014175689f | |||
170d314540 | |||
b33ec4ac2e | |||
84bdf873ce | |||
0aecad6644 | |||
754a4f8bdc | |||
40babc23a3 | |||
941b3dbb02 | |||
8efc455e58 | |||
5fd1818ec7 | |||
8eb91bc46d | |||
b8187a5bf2 | |||
f0c82d9027 | |||
b9caa1e1e1 | |||
a4fcf622a9 | |||
e2d6bf31a3 | |||
ece614eb7e | |||
f71378e67f | |||
525831e8af | |||
55c35b6669 | |||
237e761588 | |||
9069e2eba4 | |||
fa0580ccac | |||
5783e3f9d2 | |||
50596d87d1 | |||
4035f9263a | |||
b9ac75330c | |||
88d5e4c9a0 | |||
f0ac9a2e9c | |||
1f3a418d93 | |||
e0aee67dcd | |||
5de9ade51d | |||
7fc82723b5 | |||
8bb0249d5b | |||
19caeb3e38 | |||
0c257dbcdd | |||
a3cab06a40 | |||
92305a9f7a | |||
d6e78c19ad | |||
7374a37115 | |||
59b5844de6 | |||
cf8bbad937 | |||
2edeb74213 | |||
9c7fb4da38 | |||
2a7a11b80f | |||
5b4528925d | |||
d6d6a050bd | |||
a7288dc0de | |||
a330706d86 | |||
1c073b70bd | |||
e2684e1f66 | |||
d5c5a0e3c3 | |||
6e0f9eaa78 | |||
ca93ff798b | |||
58228ed00f | |||
d789b4a606 | |||
ad304094ba | |||
8b5612f4aa | |||
81b162c465 | |||
10a6bc7157 | |||
a2b8d9beb9 | |||
e7bddd54fa | |||
59ade286c2 | |||
13d225377d | |||
21ccb211c1 | |||
966b513f8f | |||
cc11ff29bf | |||
502a26beff | |||
d2a4483e48 | |||
f81ede500d | |||
bd74a25072 | |||
78cfbb92d8 | |||
8f318f19ff | |||
351d911f46 | |||
89928246d2 | |||
25e010a3d8 | |||
e030a79aba | |||
63d9e3ca5f | |||
6a843b28d1 | |||
cc2346be67 | |||
e3455fe1ff | |||
873d536729 | |||
ac87ae3d5b | |||
eb68a69e38 | |||
5cc17a77c7 | |||
4c6c078442 | |||
f5f9e535de | |||
a1639a9a72 | |||
622e0a480e | |||
434fa863d0 | |||
391ad67e8c | |||
e908beb38a | |||
c2c80c6bf6 | |||
de53e48078 | |||
7541c2bcf0 | |||
942f024761 | |||
3c646c3545 | |||
d38989b340 | |||
b28c68127a | |||
64094be4e3 | |||
d1fd6f0883 | |||
a8fb66483d | |||
fde7d2359c | |||
f2abf0fbfd | |||
a6fecca2b8 | |||
e6f17ed9d5 | |||
d97f1c1677 | |||
7a93fd8a58 | |||
a7658b2b94 | |||
64965e2a1a | |||
51c0ca8c6e | |||
ac4c758636 | |||
cd6b952d64 | |||
81190d29b0 | |||
7803e94d79 | |||
1e361bb3ba | |||
f7898bc62b | |||
994ccac75b | |||
e312098e56 | |||
7b36c63d8f | |||
636d5840aa | |||
4fb26f833a | |||
0fddcd162d | |||
173c5b9611 | |||
38b2a272ee | |||
28005b7875 | |||
b38d71b298 | |||
39b9fcba43 | |||
58b48aefe2 | |||
18c6e8208a | |||
7eda5f9de5 | |||
31d48411db | |||
94ff6cb092 | |||
cf9c3d4f08 | |||
0cd9261332 | |||
899adbce5b | |||
266506e67f | |||
12574f4c05 | |||
2f749bb91d | |||
d1de27992b | |||
dd0a1f60c6 | |||
8bc2755759 | |||
e819ed26e1 | |||
7eafce87f9 | |||
8d5259d653 | |||
09c853ae26 | |||
fa7536e1d1 | |||
81d96a047d | |||
44a69e2aee | |||
121e9faf56 | |||
673e7c8f20 | |||
749c64204e | |||
e49f97a03c | |||
f535e11bba | |||
028ba57876 | |||
ca89835035 | |||
1e9ebc6f37 | |||
4bfbd24144 | |||
18046379ab | |||
8502a7b79f | |||
0f8a33d71f | |||
a7e8ff1c42 | |||
82884370b5 | |||
eec812f92c | |||
cdaeff76d5 | |||
de5037ae2b | |||
208c12b72c | |||
e00ad76e55 | |||
3a6d97b4f3 | |||
01366b7273 | |||
9f28cc686c | |||
37c0ea7453 | |||
1bade91254 | |||
b0bedc516d | |||
a6d9f681d8 | |||
5c4d55af6b | |||
e45b89695b | |||
55c352a9cd | |||
03cdda99ae | |||
28f96f4b51 | |||
f751e060b9 | |||
47516cafde | |||
6751132466 | |||
dce9911164 | |||
4d1c6a1940 | |||
d4122726ec | |||
16adb444b9 | |||
d54392c6eb | |||
51e45baeff | |||
125c3a789a | |||
831bd8e160 | |||
1545d37f36 | |||
dc16d52d49 | |||
59f3aef703 | |||
b1dde586e1 | |||
cce93ebbcf | |||
e6db70354c | |||
ed8a779f7f | |||
6f6199ad20 | |||
54b78363b0 | |||
65acd118c5 | |||
c5e7d44b15 | |||
2fdc4389e2 | |||
5082435501 | |||
de2de6315c | |||
723df0e9fb | |||
09e8bf4144 | |||
6da59ca382 | |||
bf54c15560 | |||
489b623afd | |||
39a1f16b33 | |||
94667c5dde | |||
39baeade37 | |||
13cff71faf | |||
9cfd914a3e | |||
f6b7fd7aa3 | |||
7ead69a761 | |||
a4bb3fe4dd | |||
984698efad | |||
2a4bd8022e | |||
0979d04693 | |||
1aec6a71a1 | |||
f513fb06fb | |||
dcee737faf | |||
d3c4d52118 | |||
01ed24263f | |||
5ae3522028 | |||
813b7ba6e7 | |||
c093da38ae | |||
8a80cb489d | |||
5c81abdce0 | |||
5f4a4b0d90 | |||
1b61e10e36 | |||
d904f7b32e | |||
c678199802 | |||
44870480be | |||
1aff36efb8 | |||
d0501c3139 | |||
d6ca7ecbc4 | |||
a1df8bdc15 | |||
acb5e50870 | |||
9f2430cace | |||
bdcbdba2ab | |||
d751c626b3 | |||
611f3a26c2 | |||
904d21d0be | |||
6a244c1057 | |||
38d477a1ad | |||
189834bb53 | |||
82669103af | |||
57e741c36c | |||
f517eb7a41 | |||
6abb1d2ae9 | |||
e9a3310042 | |||
c16f251442 | |||
9c8f663b8e | |||
1263e80d21 | |||
895dae6d68 | |||
e0dc25905b | |||
58713a90aa | |||
1da4b07e73 | |||
e1604a081f | |||
7d86e62045 | |||
a821442b1a | |||
0f9a841c4a | |||
a80da4f677 | |||
721249231f | |||
c80b1c9a91 | |||
33807b7fac | |||
557eccb74d | |||
3ed738b949 | |||
652d29f2d9 | |||
988426dc96 | |||
258e671420 | |||
5f6b4c1b79 | |||
fdffe8dc1e | |||
4eceb3b5f7 | |||
5b3ab9a2b4 | |||
eea2809136 | |||
6152ca66b4 | |||
f8b62bba64 | |||
b8944a3156 | |||
a3369a7d21 | |||
fbf6e2bff1 | |||
be2bc15ab5 | |||
e9b7a11cf6 | |||
f17a2ba2b8 | |||
0a2a88e23f | |||
b440c11a46 | |||
f50f4752dd | |||
7a3e08406a | |||
46b23dba24 | |||
3fbcbd5153 | |||
b64af8dc8d |
2
Makefile
Executable file → Normal file
2
Makefile
Executable file → Normal file
@ -19,7 +19,7 @@ CALWIZDIR = $(WD)/calibrationWizards
|
||||
MANDIR = $(WD)/manual
|
||||
CALIBDIR = $(WD)/slsDetectorCalibration
|
||||
|
||||
|
||||
|
||||
INCLUDES=-I. -I$(LIBRARYDIR)/commonFiles -I$(LIBRARYDIR)/slsDetector -I$(LIBRARYDIR)/usersFunctions -I$(LIBRARYDIR)/multiSlsDetector -I$(LIBRARYDIR)/slsDetectorUtils -I$(LIBRARYDIR)/slsDetectorCommand -I$(LIBRARYDIR)/slsDetectorAnalysis -I$(LIBRARYDIR)/slsReceiverInterface -I$(LIBRARYRXRDIR)/include -I$(LIBRARYDIR)/threadFiles -I$(ASM)
|
||||
|
||||
INCLUDESRXR += -I. -I$(LIBRARYRXRDIR)/include -I$(CALIBDIR) -I$(ASM)
|
||||
|
@ -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.
|
||||
|
||||
|
@ -10,6 +10,8 @@ git clone $1@git.psi.ch:sls_detectors_software/sls_receiver_software.git slsRece
|
||||
|
||||
git clone $1@git.psi.ch:sls_detectors_software/sls_detector_calibration.git slsDetectorCalibration
|
||||
|
||||
git clone $1@git.psi.ch:sls_detectors_software/sls_image_reconstruction.git slsImageReconstruction
|
||||
#git clone $1@git.psi.ch:sls_detectors_software/sls_image_reconstruction.git slsImageReconstruction
|
||||
|
||||
git clone $1@git.psi.ch:sls_detectors_software/calibration_wizards.git calibrationWizards
|
||||
|
||||
#git clone git@git.psi.ch:sls_detectors_software/tests.git tests
|
||||
|
@ -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
|
||||
|
||||
|
@ -11,29 +11,30 @@
|
||||
\title{\E - short manual}
|
||||
\date{\today}
|
||||
\maketitle
|
||||
\tableofcontents
|
||||
|
||||
\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$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}
|
||||
|
||||
The Client talks to control over 1~Gb ethernet connection using TCP/IP to the detector and to the receiver. The detector sends data in UDP packets to the receiver. This data sending can be done over 1~Gb/s or 10~Gb/s.
|
||||
The Client talks to control over 1~Gb Ethernet connection using TCP/IP to the detector and to the receiver. The detector sends data in UDP packets to the receiver. This data sending can be done over 1~Gb/s or 10~Gb/s.
|
||||
|
||||
|
||||
\subsection{Mandatory setup - Receiver}
|
||||
@ -42,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}
|
||||
|
||||
@ -59,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:
|
||||
@ -70,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}
|
||||
@ -82,7 +112,7 @@ sls_detector_put 0-parameters setup.det
|
||||
In the case of \E, the proper bias voltage of the sensor has to be setup, i.e. the {\tt{setup.det}} file needs to contain the line {\tt{vhighvoltage 150}}. Other detector functionality, which are rarely changed can be setup here.
|
||||
Other important settings that are configured in the {\tt{setup.det}} file are:
|
||||
\begin{itemize}
|
||||
\item {\tt{tengiga 0/1}}, which sets whether the detector is enabled to send data through the 1~or the 10~Gb ethernet.
|
||||
\item {\tt{tengiga 0/1}}, which sets whether the detector is enabled to send data through the 1~or the 10~Gb Ethernet.
|
||||
\item {\tt{flags parallel/nonparallel}}, which sets whether the detector is set in parallel acquisition and readout or in sequential mode. This changes the readout time of the chip and affects the frame rate capability (faster is {\tt{parallel}}, with higher noise but needed when the frame rate is $>2$~kHz.
|
||||
\item {\tt{dr 32/16}} sets the detector in autosumming mode (32 bit counter or not autosumming, 12 bit out of the chip). This is strictly connected to what is required for the readout clock of chip. See next point.
|
||||
\item {\tt{clkdivider 0/1/2}}. Changes the readout clock: 200, 100, 50~MHz. Note that autosumming mode ({\tt{dr 32}} only works at {clkdivider 2}). By selecting Refer to readout timing specifications in~section\ref{timing} for how to set the detector.
|
||||
@ -92,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.
|
||||
|
||||
\subsection{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:
|
||||
\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}
|
||||
|
||||
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.
|
||||
@ -123,19 +178,43 @@ 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.
|
||||
|
||||
\subsection{Readout timing- maximum frame rate}\label{timing}
|
||||
\section{Readout timing- maximum frame rate}\label{timing}
|
||||
IMPORTANT: to have faster readout and smaller dead time, one can configure {\tt{clkdivider}}, i.e. the speed at which the data are read, i.e. 200/100/50~MHz for {\tt{clkdivider 0/1/2}} and the dead time between frames through {\tt{flags parallel}}, i.e. acquire and read at the same time or acquire and then read out.
|
||||
The configuration of this timing variables allows to achieve different frame rates. NOTE THAT IN EIGER, WHATEVER YOU DO, THE FRAME RATE LIMITATIONS COME FROM THE NETWORK BOTTLENECK AS THE HARDWARE GOES FASTER THAN THE DATA OUT.
|
||||
|
||||
@ -150,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\\
|
||||
@ -162,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)\\
|
||||
@ -189,11 +270,12 @@ 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.
|
||||
|
||||
|
||||
\subsection{External triggering options}
|
||||
\section{External triggering options}
|
||||
The detector can be setup such to receive external triggers. Connect a LEMO signal to the TRIGGER IN connector in the Power Distribution Board. The logic 0 for the board is passed by low level 0$-$0.7~V, the logic 1 is passed to the board with a signal between 1.2$-$5~V. Eiger is 50~$\Omega$ terminated. By default the positive polarity is used (negative should not be passed to the board).
|
||||
\begin{verbatim}
|
||||
sls_detector_put 0-timing [auto/trigger/burst_trigger/gating]
|
||||
@ -214,9 +296,8 @@ Here are the implemented options so far:
|
||||
Hardware-wise, the ENABLE OUT signal outputs when the chips are really acquiring. This means that the single subframes will be outputted in 32 bit mode. The TRIGGER OUT outputs the sum-up-signal at the moment (which is useless). This will be changed in the future to output the envelop of the enable signal.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
\subsection{Advanced 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.
|
||||
|
||||
@ -227,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]
|
||||
@ -236,14 +317,87 @@ 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}
|
||||
|
||||
Extremely advanced options allow to:
|
||||
\begin{itemize}
|
||||
\item Activate the flow control for 10~Gb/s~E (by default the 1~Gb/s~E is always active and cannot be switched off:
|
||||
\begin{verbatim}
|
||||
./sls_detector_put flowcontrol_10g 1
|
||||
\end{verbatim}
|
||||
\item Delay the transmission of the left port. This delay option is useful in the case of many simultaneous receivers running, such that it reduces the throughput to the receivers all at the same time. To be used board by board (i.e {\tt{X:, Y:,etc..}} with different units:
|
||||
\begin{verbatim}
|
||||
./sls_detector_put X:txndelay_left xxxx
|
||||
\end{verbatim}
|
||||
\item Transmission delay of the right port, same as above. The value here should be different from the left port to spread the transmission even more
|
||||
\begin{verbatim}
|
||||
./sls_detector_put X:txndelay_right yyyy
|
||||
\end{verbatim}
|
||||
As example:
|
||||
\begin{verbatim}
|
||||
for X in \$(seq 0 4); do ./sls_detector_put \$X:txndelay_left \$((X*100000)); done
|
||||
\end{verbatim}
|
||||
\begin{verbatim}
|
||||
./sls_detector_put \$X:txndelay_right \$((X*100000)); X=\$((X+1)); done
|
||||
\end{verbatim}
|
||||
|
||||
\item Set transmission delay of the entire frame. This is required as you want to finish sending the first frame to all receivers before starting sending the second frame to the receivers with shorter delay time. This value has to be greater than the maximum of the transmission delays of each port.
|
||||
\begin{verbatim}
|
||||
./sls_detector_put txndelay_frame zzzz
|
||||
\end{verbatim}
|
||||
In the example before, it would be: {\tt{zzzz}}=4*100000+ 100000
|
||||
|
||||
\item Readjust the size of the fifo of the receiver between listening and writing (useful when writing is limited)
|
||||
\begin{verbatim}
|
||||
./sls_detector_put rx_fifodepth xxxx
|
||||
\end{verbatim}
|
||||
{\tt{xxxx}} is 100 images by default.
|
||||
\item Deactivate a half module (for ROI or debugging):
|
||||
\begin{verbatim}
|
||||
./sls_detector_put X:activated 0
|
||||
\end{verbatim}
|
||||
where $X$ is the half module you want to deactivate.
|
||||
The receiver at this point will return fake data (overflow) for this module. If you wish to eliminate the receiver overall for this module, then you need to run a configuration file where this module has been removed.
|
||||
To activate back a module, do:
|
||||
\begin{verbatim}
|
||||
./sls_detector_put X:activated 1
|
||||
\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}}.
|
||||
|
||||
@ -266,30 +420,49 @@ eg.
|
||||
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]
|
||||
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)x3 (lomg side) modules.\\
|
||||
Missing packets in a frame and border pixels ($\times 2$ and $/times 4$ are given with value $-1$ at the present mode.
|
||||
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 poixel per double larger pixel, so to have an even number of counts everywhere. Virtual pixels (not filled ) between module gaps are also inserted.
|
||||
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}
|
||||
|
||||
\subsection{Read temperatures from boards}
|
||||
|
||||
|
||||
|
||||
\subsection{Delays in sending for 1Gb/s, 10Gb/s, 10Gb flow control}
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
||||
@ -316,21 +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 OK
|
||||
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 OK
|
||||
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 OK
|
||||
sleep 300; #or till the screen over netcat has told you Successful
|
||||
\end{verbatim}
|
||||
do the same for the other boards. You can programm in parallel many boards, but ou 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.
|
||||
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 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.
|
||||
|
||||
\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.
|
||||
|
||||
\item \textbf{Pulse analogically:} You want to really check the analogical part of the detcetor, not just the readout.
|
||||
|
||||
\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}
|
||||
sls_detector_put trimbits ../settingsdir/eiger/standard/eigernoise
|
||||
sls_detector_put vthreshold 4000
|
||||
sls_detector_put vtr 4000
|
||||
\end{verbatim}
|
||||
|
||||
\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}
|
||||
|
||||
|
@ -287,7 +287,7 @@ Please refer to SLS Detectors FAQ documentation for more detailed information ab
|
||||
\item[rx\_udpport i] sets the communication port between detector and receiver. Should be left to the configuration file.
|
||||
\item[rx\_hostname s] sets the hostname (or IP address) of the receiver for the TCP/IP interface with the client.
|
||||
\item[rx\_udpip ip] sets the IP address of the receiver for the UDP interface with the detector.
|
||||
\item[rx\_fifodepth v] sets receiver fifo depth to value v. Default for \E is 100.
|
||||
\item[rx\_fifodepth v] sets receiver fifo depth to value v. Default for \E is 100 frames betweeen listening and writing.
|
||||
\item[r\_online b] sets the receiver in online (1) or offline (0) mode.
|
||||
%\item[r\_checkonline]
|
||||
%\item[framescaught]
|
||||
|
@ -1 +1 @@
|
||||
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv2.0.5.14.0
|
||||
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv2.3.0.16.2
|
@ -1 +1 @@
|
||||
../slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServerv2.0.3
|
||||
../slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServerv2.2.1
|
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,17 +1,8 @@
|
||||
VDAC0 1250
|
||||
VDAC1 600
|
||||
VDAC2 3000
|
||||
VDAC3 830
|
||||
VDAC4 1630
|
||||
VDAC0 1220
|
||||
VDAC1 3000
|
||||
VDAC2 1053
|
||||
VDAC3 1450
|
||||
VDAC4 750
|
||||
VDAC5 1000
|
||||
VDAC6 480
|
||||
VDAC7 400
|
||||
VDAC8 1500
|
||||
VDAC9 3000
|
||||
VDAC10 1053
|
||||
VDAC11 1000
|
||||
VDAC12 750
|
||||
VDAC13 1220
|
||||
VDAC14 0
|
||||
VDAC15 0
|
||||
|
||||
VDAC7 420
|
||||
|
1
settingsdir/jungfrau/dynamichg0
Symbolic link
1
settingsdir/jungfrau/dynamichg0
Symbolic link
@ -0,0 +1 @@
|
||||
dynamicgain
|
@ -1 +0,0 @@
|
||||
../dynamicgain/calibration.sn
|
@ -1 +0,0 @@
|
||||
../dynamicgain/settings.sn
|
1
settingsdir/jungfrau/fixgain1
Symbolic link
1
settingsdir/jungfrau/fixgain1
Symbolic link
@ -0,0 +1 @@
|
||||
dynamicgain
|
@ -1 +0,0 @@
|
||||
../dynamicgain/calibration.sn
|
@ -1 +0,0 @@
|
||||
../dynamicgain/settings.sn
|
1
settingsdir/jungfrau/fixgain2
Symbolic link
1
settingsdir/jungfrau/fixgain2
Symbolic link
@ -0,0 +1 @@
|
||||
dynamicgain
|
@ -1 +0,0 @@
|
||||
../dynamicgain/calibration.sn
|
@ -1 +0,0 @@
|
||||
../dynamicgain/settings.sn
|
1
settingsdir/jungfrau/forceswitchg1
Symbolic link
1
settingsdir/jungfrau/forceswitchg1
Symbolic link
@ -0,0 +1 @@
|
||||
dynamicgain
|
@ -1 +0,0 @@
|
||||
../dynamicgain/calibration.sn
|
@ -1 +0,0 @@
|
||||
../dynamicgain/settings.sn
|
1
settingsdir/jungfrau/forceswitchg2
Symbolic link
1
settingsdir/jungfrau/forceswitchg2
Symbolic link
@ -0,0 +1 @@
|
||||
dynamicgain
|
@ -1 +0,0 @@
|
||||
../dynamicgain/calibration.sn
|
@ -1 +0,0 @@
|
||||
../dynamicgain/settings.sn
|
@ -19,169 +19,91 @@ public:
|
||||
*/
|
||||
|
||||
|
||||
eigerHalfModuleData(int dr, int np, int bsize, int dsize, bool top, double c=0): slsReceiverData<uint32_t>(xpixels, ypixels, np, bsize),
|
||||
xtalk(c), bufferSize(bsize), actualDataSize(dsize), dynamicRange(dr), numberOfPackets(np), top(top),header_t(0), footer_t(0){
|
||||
eigerHalfModuleData(bool t, bool l, int dr, int tg, int psize, int dsize, int npf, int x, int y, double c=0):
|
||||
slsReceiverData<uint32_t>(x, y, npf, psize),
|
||||
top(t), left(l),
|
||||
dynamicRange(dr), tenGiga(tg),
|
||||
packetSize(psize), onepacketdataSize(dsize), numberofPacketsPerFrame(npf),
|
||||
xtalk(c),
|
||||
header_t(0), footer_t(0){
|
||||
|
||||
tenGiga = false;
|
||||
if(actualDataSize == TEN_GIGA_PACKET_SIZE)
|
||||
tenGiga = true;
|
||||
|
||||
int **dMap;
|
||||
uint32_t **dMask;
|
||||
|
||||
dMap=new int*[ypixels];
|
||||
dMask=new uint32_t*[ypixels];
|
||||
dMap=new int*[ny];
|
||||
dMask=new uint32_t*[ny];
|
||||
|
||||
|
||||
for (int i = 0; i < ypixels; i++) {
|
||||
dMap[i] = new int[xpixels];
|
||||
dMask[i] = new uint32_t[xpixels];
|
||||
for (int i = 0; i < ny; i++) {
|
||||
dMap[i] = new int[nx];
|
||||
dMask[i] = new uint32_t[nx];
|
||||
}
|
||||
|
||||
//Map
|
||||
int totalNumberOfBytes = numberOfPackets * bufferSize;
|
||||
int iPacket1 = 8;
|
||||
int iPacket2 = (totalNumberOfBytes/2) + 8;
|
||||
int iData1 = 0, iData2 = 0;
|
||||
int totalNumberOfBytes = numberofPacketsPerFrame * packetSize;
|
||||
int iPacket = 8;
|
||||
int iData = 0;
|
||||
int increment = (dynamicRange/8);
|
||||
int ic_increment = 1;
|
||||
if (dynamicRange == 4) {
|
||||
increment = 1;
|
||||
ic_increment = 2;
|
||||
}
|
||||
int iPort;
|
||||
|
||||
if(top){
|
||||
for (int ir=0; ir<ypixels; ir++) {
|
||||
for (int ic=0; ic<xpixels; ic = ic + ic_increment) {
|
||||
iPort = ic / (xpixels/2);
|
||||
if(!iPort){
|
||||
dMap[ir][ic] = iPacket1;
|
||||
iPacket1 += increment;
|
||||
iData1 += increment;
|
||||
//increment header
|
||||
if(iData1 >= actualDataSize){
|
||||
iPacket1 += 16;
|
||||
iData1 = 0;
|
||||
}
|
||||
}else{
|
||||
dMap[ir][ic] = iPacket2;
|
||||
iPacket2 += increment;
|
||||
iData2 += increment;
|
||||
//increment header
|
||||
if(iData2 >= actualDataSize){
|
||||
iPacket2 += 16;
|
||||
iData2 = 0;
|
||||
}
|
||||
for (int ir=0; ir<ny; ir++) {
|
||||
for (int ic=0; ic<nx; ic = ic + ic_increment) {
|
||||
dMap[ir][ic] = iPacket;
|
||||
iPacket += increment;
|
||||
iData += increment;
|
||||
//increment header
|
||||
if(iData >= onepacketdataSize){
|
||||
iPacket += 16;
|
||||
iData = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//bottom
|
||||
else{
|
||||
iData1 = 0; iData2 = 0;
|
||||
int numbytesperlineperport;
|
||||
|
||||
iData = 0;
|
||||
int numbytesperline;
|
||||
switch(dynamicRange){
|
||||
case 4: numbytesperlineperport = 256; break;
|
||||
case 8: numbytesperlineperport = 512; break;
|
||||
case 16:numbytesperlineperport = 1024; break;
|
||||
case 32:numbytesperlineperport = 2048; break;
|
||||
case 4: numbytesperline = 256; break;
|
||||
case 8: numbytesperline = 512; break;
|
||||
case 16:numbytesperline = 1024; break;
|
||||
case 32:numbytesperline = 2048; break;
|
||||
}
|
||||
iPacket = totalNumberOfBytes - numbytesperline - 8;
|
||||
if((dynamicRange == 32) && (!tenGiga))
|
||||
iPacket -= 16;
|
||||
|
||||
|
||||
|
||||
iPacket1 = (totalNumberOfBytes/2) - numbytesperlineperport - 8;
|
||||
iPacket2 = totalNumberOfBytes - numbytesperlineperport - 8;
|
||||
if (dynamicRange == 32){
|
||||
if(numbytesperlineperport>actualDataSize){ //1Giga
|
||||
iPacket1 -= 16;
|
||||
iPacket2 -= 16;
|
||||
}else{ //10Giga
|
||||
;//iPacket1 -= numbytesperlineperport;
|
||||
//iPacket2 -= numbytesperlineperport;
|
||||
}
|
||||
}
|
||||
|
||||
for (int ir=0; ir<ypixels; ir++) {
|
||||
for (int ic=0; ic<xpixels; ic = ic + ic_increment) {
|
||||
iPort = ic / (xpixels/2);
|
||||
if(!iPort){
|
||||
dMap[ir][ic] = iPacket1;
|
||||
iPacket1 += increment;
|
||||
iData1 += increment;
|
||||
|
||||
//--------------------32 bit -------------------------
|
||||
if(dynamicRange == 32){
|
||||
if(numbytesperlineperport>actualDataSize){ //1Giga
|
||||
if(iData1 == numbytesperlineperport){
|
||||
iPacket1 -= (numbytesperlineperport*2 + 16*3);//1giga
|
||||
iData1 = 0;
|
||||
}
|
||||
if(iData1 == actualDataSize){
|
||||
iPacket1 += 16;
|
||||
}
|
||||
}else{ //10Giga
|
||||
if((iData1 % numbytesperlineperport)==0){
|
||||
iPacket1 -= (numbytesperlineperport*2);
|
||||
}
|
||||
if(iData1 == actualDataSize){
|
||||
iPacket1 -= 16;
|
||||
iData1 = 0;
|
||||
}
|
||||
}
|
||||
}//------------end of 32 bit -------------------------
|
||||
|
||||
else if((iData1 % numbytesperlineperport) == 0){
|
||||
iPacket1 -= (numbytesperlineperport*2);
|
||||
if(iData1 == actualDataSize){
|
||||
iPacket1 -= 16;
|
||||
iData1 = 0;
|
||||
}
|
||||
for (int ir=0; ir<ny; ir++) {
|
||||
for (int ic=0; ic<nx; ic = ic + ic_increment) {
|
||||
dMap[ir][ic] = iPacket;
|
||||
iPacket += increment;
|
||||
iData += increment;
|
||||
//--------------------32 bit 1giga -------------------
|
||||
if((dynamicRange == 32) && (!tenGiga)){
|
||||
if(iData == numbytesperline){
|
||||
iPacket -= (numbytesperline*2 + 16*3);
|
||||
iData = 0;
|
||||
}
|
||||
//------------end of other bits -------------------------
|
||||
|
||||
}
|
||||
//other port
|
||||
else{
|
||||
dMap[ir][ic] = iPacket2;
|
||||
iPacket2 += increment;
|
||||
iData2 += increment;
|
||||
|
||||
|
||||
//--------------------32 bit -------------------------
|
||||
if(dynamicRange == 32){
|
||||
if(numbytesperlineperport>actualDataSize){ //1Giga
|
||||
if(iData2 == numbytesperlineperport){
|
||||
iPacket2 -= (numbytesperlineperport*2 + 16*3);
|
||||
iData2 = 0;
|
||||
}
|
||||
if(iData2 == actualDataSize){
|
||||
iPacket2 += 16;
|
||||
}
|
||||
}else{//10Giga
|
||||
if((iData2 % numbytesperlineperport)==0){
|
||||
iPacket2 -= (numbytesperlineperport*2);
|
||||
}
|
||||
if(iData2 == actualDataSize){
|
||||
iPacket2 -= 16;
|
||||
iData2 = 0;
|
||||
}
|
||||
}
|
||||
}//------------end of 32 bit -------------------------
|
||||
|
||||
else if((iData2 % numbytesperlineperport) == 0){
|
||||
iPacket2 -= (numbytesperlineperport*2);
|
||||
if(iData2 == actualDataSize){
|
||||
iPacket2 -= 16;
|
||||
iData2 = 0;
|
||||
}
|
||||
if(iData == onepacketdataSize){
|
||||
iPacket += 16;
|
||||
}
|
||||
}//------------end of 32 bit -------------------------
|
||||
else if((iData % numbytesperline) == 0){
|
||||
iPacket -= (numbytesperline*2);
|
||||
if(iData == onepacketdataSize){
|
||||
iPacket -= 16;
|
||||
iData = 0;
|
||||
}
|
||||
//------------end of other bits -------------------------
|
||||
|
||||
}
|
||||
//---------------------------------------------------
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -190,16 +112,13 @@ public:
|
||||
|
||||
|
||||
//Mask
|
||||
for(int ir=0; ir<ypixels; ++ir)
|
||||
for(int ic=0; ic<xpixels; ++ic)
|
||||
for(int ir=0; ir<ny; ++ir)
|
||||
for(int ic=0; ic<nx; ++ic)
|
||||
dMask[ir][ic] = 0x0;
|
||||
|
||||
setDataMap(dMap);
|
||||
setDataMask(dMask);
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -211,7 +130,7 @@ public:
|
||||
\returns frame number
|
||||
*/
|
||||
int getFrameNumber(char *buff){
|
||||
footer_t = (eiger_packet_footer_t*)(buff + actualDataSize + sizeof(eiger_packet_header_t));
|
||||
footer_t = (eiger_packet_footer_t*)(buff + onepacketdataSize + sizeof(eiger_packet_header_t));
|
||||
return ((uint32_t)(*( (uint64_t*) footer_t)));
|
||||
};
|
||||
|
||||
@ -224,7 +143,7 @@ public:
|
||||
\returns packet number
|
||||
*/
|
||||
int getPacketNumber(char *buff){
|
||||
footer_t = (eiger_packet_footer_t*)(buff + actualDataSize + sizeof(eiger_packet_header_t));
|
||||
footer_t = (eiger_packet_footer_t*)(buff + onepacketdataSize + sizeof(eiger_packet_header_t));
|
||||
return(*( (uint16_t*) footer_t->packetnum));
|
||||
};
|
||||
|
||||
@ -287,10 +206,10 @@ public:
|
||||
|
||||
// ------check if missing packet, get to pixel at start of packet-----------------
|
||||
|
||||
//to get the starting of a packet, ix is divided by 512pixels because of 2 ports (except 1g 32 bit)
|
||||
newix = ix - (ix%512);
|
||||
//to get the starting of a packet (except 1g 32 bit)
|
||||
newix = 0;
|
||||
// 0.5 Lines per packet for 1g 32 bit
|
||||
if(dynamicRange ==32 && !tenGiga)
|
||||
if(dynamicRange == 32 && !tenGiga)
|
||||
newix = ix - (ix%256);
|
||||
|
||||
//iy divided by linesperpacket depending on bitmode
|
||||
@ -300,9 +219,11 @@ public:
|
||||
newiy = (iy - (iy%linesperpacket));
|
||||
|
||||
header_t = (eiger_packet_header_t*)((char*)(data +(dataMap[newiy][newix]-8)));
|
||||
if(*( (uint16_t*) header_t->missingpacket)==0xFFFF){
|
||||
// cprintf(RED,"missing packet\n");
|
||||
return -1;
|
||||
uint16_t identifier = (uint16_t)*( (uint16_t*) header_t->missingpacket);
|
||||
|
||||
if(identifier==deactivatedPacketValue){
|
||||
// cprintf(RED,"deactivated packet\n");
|
||||
return -2;
|
||||
}
|
||||
// -----END OF CHECK -------------------------------------------------------------
|
||||
|
||||
@ -342,25 +263,188 @@ public:
|
||||
*/
|
||||
double getXTalk() {return xtalk;}
|
||||
|
||||
void getChannelArray(double* data, char* buffer){
|
||||
for(int iy = 0; iy < ny; iy++){
|
||||
for(int ix = 0; ix < nx; ix++){
|
||||
data[iy*nx+ix] = getValue((char*)buffer,ix,iy);
|
||||
//cprintf(BLUE,"%d,%d :%f\n",ix,iy,value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int* decodeData(int *datain) {
|
||||
|
||||
int dataBytes = numberofPacketsPerFrame * onepacketdataSize;
|
||||
int nch = nx*ny;
|
||||
int* dataout = new int [nch];
|
||||
char *ptr=(char*)datain;
|
||||
char iptr;
|
||||
|
||||
const int bytesize=8;
|
||||
int ival=0;
|
||||
int ipos=0, ichan=0, ibyte;
|
||||
|
||||
switch (dynamicRange) {
|
||||
case 4:
|
||||
for (ibyte=0; ibyte<dataBytes; ++ibyte) {//for every byte (1 pixel = 1/2 byte)
|
||||
iptr=ptr[ibyte]&0xff; //???? a byte mask
|
||||
for (ipos=0; ipos<2; ++ipos) { //loop over the 8bit (twice)
|
||||
ival=(iptr>>(ipos*4))&0xf; //pick the right 4bit
|
||||
dataout[ichan]=ival;
|
||||
ichan++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for (ichan=0; ichan<dataBytes; ++ichan) {//for every pixel (1 pixel = 1 byte)
|
||||
ival=ptr[ichan]&0xff; //????? a byte mask
|
||||
dataout[ichan]=ival;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
for (ichan=0; ichan<nch; ++ichan) { //for every pixel
|
||||
ival=0;
|
||||
for (ibyte=0; ibyte<2; ++ibyte) { //for each byte (concatenate 2 bytes to get 16 bit value)
|
||||
iptr=ptr[ichan*2+ibyte];
|
||||
ival|=((iptr<<(ibyte*bytesize))&(0xff<<(ibyte*bytesize)));
|
||||
}
|
||||
dataout[ichan]=ival;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//for every 32 bit (every element in datain array)
|
||||
for (ichan=0; ichan<nch; ++ichan) { //for every pixel
|
||||
ival=datain[ichan]&0xffffff;
|
||||
dataout[ichan]=ival;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return dataout;
|
||||
|
||||
};
|
||||
|
||||
|
||||
int* readNextFrameOnlyData(ifstream &filebin, int& fnum) {
|
||||
int framesize = numberofPacketsPerFrame * onepacketdataSize;
|
||||
|
||||
int* data = new int[framesize/(sizeof(int))];
|
||||
char *packet=new char[packetSize];
|
||||
fnum = -1;
|
||||
int pn=-1;
|
||||
int dataoffset = 0;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
|
||||
while (filebin.read(packet,packetSize)) {
|
||||
|
||||
fnum = getFrameNumber(packet); //cout << "fn:"<<fn<<endl;
|
||||
pn = getPacketNumber(packet); //cout << "pn:"<<pn<<endl;
|
||||
|
||||
memcpy(((char*)data)+dataoffset,packet+DATA_PACKET_HEADER_SIZE,onepacketdataSize);
|
||||
dataoffset+=onepacketdataSize;
|
||||
if(pn == numberofPacketsPerFrame)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete [] packet;
|
||||
if(!dataoffset){
|
||||
delete [] data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
/*
|
||||
when u get packet form next frames
|
||||
//to remember the position to read next frame
|
||||
filebin.seekg (position, filebin.beg);
|
||||
position = filebin.tellg();
|
||||
|
||||
*/
|
||||
|
||||
int *readNextFramewithMissingPackets(ifstream &filebin, int& fnum) {
|
||||
|
||||
int* data = new int[(numberofPacketsPerFrame * onepacketdataSize)/(sizeof(int))];
|
||||
char *packet=new char[packetSize];
|
||||
fnum = -1;
|
||||
int pnum = 0;
|
||||
int fn = -1;
|
||||
int pn =-1;
|
||||
int dataoffset = 0;
|
||||
int missingpackets;
|
||||
|
||||
|
||||
if (filebin.is_open()) {
|
||||
|
||||
while (filebin.read(packet,packetSize)) {
|
||||
|
||||
fn = getFrameNumber(packet); //cout << "fn:"<<fn<<endl;
|
||||
pn = getPacketNumber(packet); //cout << "pn:"<<pn<<endl;
|
||||
|
||||
//first packet
|
||||
if(fnum == -1){
|
||||
fnum = fn;
|
||||
}
|
||||
//next frame packet
|
||||
else if (fnum != fn){
|
||||
//set file reading to the last frame's packet in file
|
||||
filebin.seekg(-packetSize, ios::cur);//filebin.beg
|
||||
break;
|
||||
}
|
||||
|
||||
//missing packets
|
||||
missingpackets = pn - pnum - 1;
|
||||
if(missingpackets){
|
||||
memset(((char*)data)+dataoffset,0xFF,missingpackets*onepacketdataSize);
|
||||
dataoffset+=(missingpackets*onepacketdataSize);
|
||||
pnum+=missingpackets;
|
||||
}
|
||||
|
||||
memcpy(((char*)data)+dataoffset,packet+DATA_PACKET_HEADER_SIZE,onepacketdataSize);
|
||||
dataoffset+=onepacketdataSize;
|
||||
pnum++;
|
||||
if(pnum == numberofPacketsPerFrame)
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
delete [] packet;
|
||||
if(!pnum){
|
||||
delete [] data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//missing packets (added here to also catch end of file)
|
||||
missingpackets = numberofPacketsPerFrame - pnum;
|
||||
if(missingpackets){
|
||||
memset(((char*)data)+dataoffset,0xFF,missingpackets*onepacketdataSize);
|
||||
dataoffset+=(missingpackets*onepacketdataSize);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
/** Missing Packet identifier value */
|
||||
const static uint16_t deactivatedPacketValue = 0xFEFE;
|
||||
|
||||
double xtalk; /**<output buffer crosstalk correction parameter */
|
||||
|
||||
const static int xpixels = 1024;
|
||||
const static int ypixels = 256;
|
||||
const int bufferSize;
|
||||
const int actualDataSize;
|
||||
const static int DATA_PACKET_HEADER_SIZE = 8;
|
||||
const bool top;
|
||||
const bool left;
|
||||
const int dynamicRange;
|
||||
const int numberOfPackets;
|
||||
bool top;
|
||||
bool tenGiga;
|
||||
static const int TEN_GIGA_PACKET_SIZE = 4096;
|
||||
const bool tenGiga;
|
||||
const int packetSize;
|
||||
const int onepacketdataSize;
|
||||
const int numberofPacketsPerFrame;
|
||||
double xtalk; /**<output buffer crosstalk correction parameter */
|
||||
|
||||
|
||||
/** structure of an eiger packet*/
|
||||
|
@ -214,6 +214,7 @@ public:
|
||||
} else {
|
||||
// cout << "." << endl;;
|
||||
np++;
|
||||
//cout<<"np:"<<np<<endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -221,7 +222,10 @@ public:
|
||||
return NULL;
|
||||
};
|
||||
|
||||
|
||||
virtual int* readNextFramewithMissingPackets(ifstream &filebin, int& fnum) {return NULL;}
|
||||
virtual void getChannelArray(double* data, char* buffer){};
|
||||
virtual int* readNextFrameOnlyData(ifstream &filebin, int& fnum) {return NULL;};
|
||||
virtual int* decodeData(int* datain) {return NULL;};
|
||||
|
||||
private:
|
||||
const int nPackets; /**<number of UDP packets constituting one frame */
|
||||
|
130
slsDetectorGui/CMakeLists.txt
Normal file
130
slsDetectorGui/CMakeLists.txt
Normal file
@ -0,0 +1,130 @@
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
set(SOURCES
|
||||
slsDetectorPlotting/src/SlsQt1DPlot.cxx
|
||||
slsDetectorPlotting/src/SlsQt1DZoomer.cxx
|
||||
slsDetectorPlotting/src/SlsQt2DHist.cxx
|
||||
slsDetectorPlotting/src/SlsQt2DPlot.cxx
|
||||
slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx
|
||||
slsDetectorPlotting/src/SlsQtNumberEntry.cxx
|
||||
src/qDetectorMain.cpp
|
||||
src/qDrawPlot.cpp
|
||||
src/qCloneWidget.cpp
|
||||
src/qTabMeasurement.cpp
|
||||
src/qTabDataOutput.cpp
|
||||
src/qTabPlot.cpp
|
||||
src/qTabActions.cpp
|
||||
src/qActionsWidget.cpp
|
||||
src/qScanWidget.cpp
|
||||
src/qTabAdvanced.cpp
|
||||
src/qTabSettings.cpp
|
||||
src/qTabDebugging.cpp
|
||||
src/qTabDeveloper.cpp
|
||||
src/qTabMessages.cpp
|
||||
src/qServer.cpp
|
||||
)
|
||||
|
||||
set(FORMS
|
||||
forms/form_detectormain.ui
|
||||
forms/form_tab_measurement.ui
|
||||
forms/form_tab_dataoutput.ui
|
||||
forms/form_tab_plot.ui
|
||||
forms/form_tab_advanced.ui
|
||||
forms/form_tab_settings.ui
|
||||
forms/form_tab_debugging.ui
|
||||
forms/form_action.ui
|
||||
forms/form_scan.ui
|
||||
)
|
||||
|
||||
qt4_wrap_ui(FORMS_H ${FORMS})
|
||||
|
||||
set(HEADERS
|
||||
slsDetectorPlotting/include/SlsQt1DPlot.h
|
||||
slsDetectorPlotting/include/SlsQt1DZoomer.h
|
||||
slsDetectorPlotting/include/SlsQt2DHist.h
|
||||
slsDetectorPlotting/include/SlsQt2DPlot.h
|
||||
slsDetectorPlotting/include/SlsQt2DPlotLayout.h
|
||||
slsDetectorPlotting/include/SlsQt2DZoomer.h
|
||||
slsDetectorPlotting/include/SlsQtValidators.h
|
||||
slsDetectorPlotting/include/SlsQtNumberEntry.h
|
||||
include/qDefs.h
|
||||
include/qDebugStream.h
|
||||
include/qDetectorMain.h
|
||||
include/qDrawPlot.h
|
||||
include/qCloneWidget.h
|
||||
include/qTabMeasurement.h
|
||||
include/qTabDataOutput.h
|
||||
include/qTabPlot.h
|
||||
include/qTabActions.h
|
||||
include/qActionsWidget.h
|
||||
include/qScanWidget.h
|
||||
include/qTabAdvanced.h
|
||||
include/qTabSettings.h
|
||||
include/qTabDebugging.h
|
||||
include/qTabDeveloper.h
|
||||
include/qTabMessages.h
|
||||
include/gitInfoGui.h
|
||||
include/qServer.h
|
||||
)
|
||||
set(RESOURCES
|
||||
include/icons.qrc
|
||||
)
|
||||
qt4_add_resources(RESOURCES_SRCS ${RESOURCES})
|
||||
|
||||
include_directories(
|
||||
include
|
||||
slsDetectorPlotting/include
|
||||
../slsDetectorSoftware/commonFiles
|
||||
../slsDetectorSoftware/slsReceiverInterface
|
||||
../slsDetectorSoftware/slsDetector
|
||||
../slsDetectorSoftware/slsDetectorAnalysis
|
||||
../slsDetectorSoftware/multiSlsDetector
|
||||
../slsDetectorSoftware/usersFunctions
|
||||
../slsReceiverSoftware/include
|
||||
${QT_INCLUDE_DIR}
|
||||
${QT_QTCORE_INCLUDE_DIR}
|
||||
${QT_QTGUI_INCLUDE_DIR}
|
||||
${QWT_INCLUDE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
-DDACS_INT -DVERBOSE -DPRINT_LOG
|
||||
)
|
||||
|
||||
add_executable(slsDetectorGui
|
||||
${SOURCES}
|
||||
${HEADERS}
|
||||
${FORMS_H}
|
||||
${RESOURCES_SRCS}
|
||||
)
|
||||
|
||||
set_target_properties(slsDetectorGui PROPERTIES
|
||||
LINKER_LANGUAGE CXX
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
add_library(zmq STATIC IMPORTED )
|
||||
|
||||
set_target_properties(zmq PROPERTIES
|
||||
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../slsReceiverSoftware/include/libzmq.a
|
||||
)
|
||||
|
||||
target_link_libraries(slsDetectorGui
|
||||
slsDetectorShared
|
||||
${QT_QTCORE_LIBRARIES}
|
||||
${QT_QTGUI_LIBRARIES}
|
||||
${QWT_LIBRARIES}
|
||||
pthread
|
||||
zmq
|
||||
rt
|
||||
)
|
||||
|
||||
add_executable(gui_client
|
||||
client/qClient.h
|
||||
client/qClient.cpp
|
||||
)
|
||||
set_target_properties(gui_client PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
@ -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: 2ad70c5041e2e2f6cdfa949639bb6250083eebec
|
||||
Revision: 336
|
||||
Branch: developer
|
||||
Repsitory UUID: bddd126e382c1b2e8082419ff393f6e1fb17526a
|
||||
Revision: 381
|
||||
Branch: 2.3.1
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 336
|
||||
Last Changed Date: 2016-08-24 17:10:07 +0200
|
||||
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 "2ad70c5041e2e2f6cdfa949639bb6250083eebec"
|
||||
//#define SVNREV 0x336
|
||||
#define SVNREPUUID "bddd126e382c1b2e8082419ff393f6e1fb17526a"
|
||||
//#define SVNREV 0x381
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "Dhanya_Maliakal"
|
||||
#define SVNREV 0x336
|
||||
#define SVNDATE 0x20160824
|
||||
#define SVNREV 0x381
|
||||
#define SVNDATE 0x20170407
|
||||
//
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef QDEFS_H
|
||||
#define QDEFS_H
|
||||
|
||||
#include "ansi.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "slsDetector.h"
|
||||
#include "multiSlsDetector.h"
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
/** Get minimum Plot timer - between plots */
|
||||
double GetMinimumPlotTimer(){return PLOT_TIMER_MS;};
|
||||
/** Set Plot timer - between plots in ms*/
|
||||
void SetPlotTimer(double time){timerValue = time;};
|
||||
void SetPlotTimer(double time);
|
||||
/** Set Plot frame factor - between plots, also for receiver if exists */
|
||||
void SetFrameFactor(int frame);
|
||||
|
||||
@ -293,9 +293,6 @@ private slots:
|
||||
/** To update plot
|
||||
* */
|
||||
void UpdatePlot();
|
||||
/** To stop updating plot
|
||||
* */
|
||||
void StopUpdatePlot();
|
||||
/** To start or stop acquisition
|
||||
* @param start is 1 to start and 0 to stop acquisition
|
||||
* */
|
||||
@ -322,6 +319,8 @@ private:
|
||||
/** The sls detector object */
|
||||
multiSlsDetector *myDet;
|
||||
|
||||
/** detectot type */
|
||||
slsDetectorDefs::detectorType detType;
|
||||
|
||||
|
||||
/** Widgets needed to plot the clone */
|
||||
@ -423,7 +422,6 @@ double pixelWidth;
|
||||
|
||||
/** Current Image Number */
|
||||
unsigned int lastImageNumber;
|
||||
int last_plot_number;
|
||||
|
||||
/** Number of graphs in 1D */
|
||||
unsigned int nHists;
|
||||
@ -481,11 +479,8 @@ double XYRangeValues[4];
|
||||
bool IsXYRange[4];
|
||||
|
||||
/** Default timer between plots*/
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
|
||||
static constexpr double PLOT_TIMER_MS = 200;
|
||||
#else
|
||||
static const double PLOT_TIMER_MS = 200;
|
||||
#endif
|
||||
static const double PLOT_TIMER_MS;
|
||||
|
||||
/** Specific timer value between plots */
|
||||
double timerValue;
|
||||
/** every nth frame when to plot */
|
||||
@ -573,7 +568,8 @@ QwtPlotHistogram *plotHistogram;
|
||||
QVector<QwtIntervalSample> histogramSamples;
|
||||
|
||||
|
||||
bool firstPlot;
|
||||
bool plotRequired;
|
||||
|
||||
|
||||
signals:
|
||||
void UpdatingPlotFinished();
|
||||
@ -586,6 +582,7 @@ void ResetZMinZMaxSignal(bool,bool,double,double);
|
||||
void SetCurrentMeasurementSignal(int);
|
||||
void saveErrorSignal(QString);
|
||||
void AcquisitionErrorSignal(QString);
|
||||
void UpdatePlotSignal();
|
||||
};
|
||||
|
||||
|
||||
|
@ -13,11 +13,10 @@
|
||||
#ifndef SLSQT1DPLOT_H
|
||||
#define SLSQT1DPLOT_H
|
||||
|
||||
#ifndef IAN
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
#endif
|
||||
#include "ansi.h"
|
||||
|
||||
|
||||
#include <qwt_plot.h>
|
||||
|
@ -27,7 +27,11 @@ class SlsQt1DZoomer:public QwtPlotZoomer{
|
||||
bool xIsLog,yIsLog;
|
||||
|
||||
public:
|
||||
#if QWT_VERSION < 0x060100
|
||||
SlsQt1DZoomer(QwtPlotCanvas *canvas):QwtPlotZoomer(canvas){
|
||||
#else
|
||||
SlsQt1DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
|
||||
#endif
|
||||
setTrackerMode(AlwaysOn);
|
||||
xIsLog=yIsLog=0;
|
||||
}
|
||||
|
@ -30,7 +30,11 @@ class SlsQt2DZoomer:public QwtPlotZoomer{
|
||||
SlsQt2DHist* hist;
|
||||
|
||||
public:
|
||||
#if QWT_VERSION < 0x060100
|
||||
SlsQt2DZoomer(QwtPlotCanvas *canvas):QwtPlotZoomer(canvas){
|
||||
#else
|
||||
SlsQt2DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
|
||||
#endif
|
||||
setTrackerMode(AlwaysOn);
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,10 @@
|
||||
#include <qwt_math.h>
|
||||
#include "SlsQt1DPlot.h"
|
||||
|
||||
#if QWT_VERSION >= 0x060100
|
||||
#define QwtLog10ScaleEngine QwtLogScaleEngine
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
SlsQtH1D::SlsQtH1D(QString title,int n, double min, double max, double* data):QwtPlotCurve(title){
|
||||
@ -417,7 +421,7 @@ void SlsQt1DPlot::SetupZoom(){
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::RightButton);
|
||||
|
||||
panner = new QwtPlotPanner(canvas());
|
||||
panner = new QwtPlotPanner((QwtPlotCanvas*)canvas());
|
||||
panner->setAxisEnabled(QwtPlot::yRight, false);
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
|
||||
@ -440,8 +444,8 @@ void SlsQt1DPlot::alignScales(){
|
||||
// the canvas frame, but is also a good example demonstrating
|
||||
// why the spreaded API needs polishing.
|
||||
|
||||
canvas()->setFrameStyle(QFrame::Box | QFrame::Plain );
|
||||
canvas()->setLineWidth(1);
|
||||
((QwtPlotCanvas*)canvas())->setFrameStyle(QFrame::Box | QFrame::Plain );
|
||||
((QwtPlotCanvas*)canvas())->setLineWidth(1);
|
||||
|
||||
for(int i = 0; i < QwtPlot::axisCnt; i++ ){
|
||||
QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i);
|
||||
@ -460,7 +464,7 @@ void SlsQt1DPlot::UnknownStuff(){
|
||||
canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
|
||||
#else
|
||||
// We don't need the cache here
|
||||
canvas()->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
|
||||
((QwtPlotCanvas*)canvas())->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -38,9 +38,12 @@ void SlsQt1DZoomer::SetZoomBase(double xmin,double ymin,double x_width, double y
|
||||
#if QWT_VERSION < 0x50200
|
||||
float xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->lBound();
|
||||
float xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->hBound();
|
||||
#else
|
||||
#elif QWT_VERSION < 0x060100
|
||||
float xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->lowerBound();
|
||||
float xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->upperBound();
|
||||
#else
|
||||
float xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom).lowerBound();
|
||||
float xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom).upperBound();
|
||||
#endif
|
||||
if(xmin_curr<xmin) xmin_curr=xmin;
|
||||
if(xmax_curr>xmin+x_width) xmax_curr=xmin+x_width;
|
||||
@ -50,9 +53,12 @@ void SlsQt1DZoomer::SetZoomBase(double xmin,double ymin,double x_width, double y
|
||||
#if QWT_VERSION < 0x50200
|
||||
float ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->lBound();
|
||||
float ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->hBound();
|
||||
#else
|
||||
#elif QWT_VERSION < 0x060100
|
||||
float ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->lowerBound();
|
||||
float ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->upperBound();
|
||||
#else
|
||||
float ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound();
|
||||
float ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft).upperBound();
|
||||
#endif
|
||||
if(ymin_curr<ymin) ymin_curr=ymin;
|
||||
if(ymax_curr>ymin+y_width) ymax_curr=ymin+y_width;
|
||||
|
@ -13,13 +13,14 @@ using std::cout;
|
||||
using std::endl;
|
||||
|
||||
SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double* d,double zmin,double zmax):QwtRasterData(){
|
||||
x_min=0;x_max=0;y_min=0;y_max=0;
|
||||
interp=0;
|
||||
nx_array=ny_array=0;data=0;
|
||||
SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d,zmin,zmax);
|
||||
}
|
||||
|
||||
|
||||
SlsQt2DHist::~SlsQt2DHist(){if(data) delete data;}
|
||||
SlsQt2DHist::~SlsQt2DHist(){if(data) delete [] data;}
|
||||
|
||||
int SlsQt2DHist::GetBinIndex(int bx, int by){
|
||||
int b = bx*ny+by;
|
||||
@ -72,7 +73,7 @@ void SlsQt2DHist::SetData(int nbinsx, double xmin, double xmax, int nbinsy,doubl
|
||||
}
|
||||
|
||||
if(nbinsx*nbinsy>nx_array*ny_array){
|
||||
if(data) delete data;
|
||||
if(data) delete [] data;
|
||||
data = new double [nbinsx*nbinsy+1]; //one for under/overflow bin
|
||||
nx_array = nbinsx;
|
||||
ny_array = nbinsy;
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <qprinter.h>
|
||||
#include <qtoolbutton.h>
|
||||
@ -23,6 +24,10 @@
|
||||
#include <qwt_scale_engine.h>
|
||||
|
||||
#include "SlsQt2DPlot.h"
|
||||
|
||||
#if QWT_VERSION >= 0x060100
|
||||
#define QwtLog10ScaleEngine QwtLogScaleEngine
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -680,6 +680,9 @@ void qDetectorMain::ExecuteHelp(QAction *action){
|
||||
|
||||
|
||||
void qDetectorMain::Refresh(int index){
|
||||
myDet->setOnline(slsDetectorDefs::ONLINE_FLAG);
|
||||
myDet->setReceiverOnline(slsDetectorDefs::ONLINE_FLAG);
|
||||
qDefs::checkErrorMessage(myDet,"qDetectorMain::Refresh");
|
||||
if(!tabs->isTabEnabled(index))
|
||||
tabs->setCurrentIndex((index++)<(tabs->count()-1)?index:Measurement);
|
||||
else{
|
||||
@ -756,9 +759,12 @@ void qDetectorMain::EnableTabs(){
|
||||
#ifdef VERBOSE
|
||||
cout << "Entering EnableTabs function" << endl;
|
||||
#endif
|
||||
|
||||
|
||||
bool enable;
|
||||
enable=!(tabs->isTabEnabled(DataOutput));
|
||||
|
||||
|
||||
// or use the Enable/Disable button
|
||||
// normal tabs
|
||||
tabs->setTabEnabled(DataOutput,enable);
|
||||
@ -790,6 +796,9 @@ void qDetectorMain::EnableTabs(){
|
||||
|
||||
//moved to here, so that its all in order, instead of signals and different threads
|
||||
if(!enable) {
|
||||
myDet->setOnline(slsDetectorDefs::ONLINE_FLAG);
|
||||
myDet->setReceiverOnline(slsDetectorDefs::ONLINE_FLAG);
|
||||
qDefs::checkErrorMessage(myDet,"qDetectorMain::EnableTabs");
|
||||
//refresh all the required tabs
|
||||
tab_actions->Refresh();// angular, positions,
|
||||
|
||||
|
@ -30,6 +30,7 @@ using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
const double qDrawPlot::PLOT_TIMER_MS = 200;
|
||||
|
||||
qDrawPlot::qDrawPlot(QWidget *parent,multiSlsDetector*& detector):
|
||||
QWidget(parent),myDet(detector),plot1D_hists(0){
|
||||
@ -63,7 +64,8 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
#endif
|
||||
|
||||
// Depending on whether the detector is 1d or 2d
|
||||
switch(myDet->getDetectorsType()){
|
||||
detType = myDet->getDetectorsType();
|
||||
switch(detType){
|
||||
case slsDetectorDefs::MYTHEN: originally2D = false; break;
|
||||
case slsDetectorDefs::EIGER: originally2D = true; break;
|
||||
case slsDetectorDefs::GOTTHARD: originally2D = false; break;
|
||||
@ -77,7 +79,7 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
|
||||
|
||||
//initialization
|
||||
data_pause_over = true;//to get the first image
|
||||
data_pause_over = true;
|
||||
|
||||
currentMeasurement = 0;
|
||||
currentFrame = 0;
|
||||
@ -120,7 +122,6 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
pixelWidth = 0;
|
||||
|
||||
lastImageNumber = 0;
|
||||
last_plot_number = 0;
|
||||
|
||||
nHists = 0;
|
||||
histNBins = 0;
|
||||
@ -215,7 +216,7 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
plotHistogram->setStyle(QwtPlotHistogram::Columns);//Options:Outline,Columns, Lines
|
||||
|
||||
|
||||
firstPlot = false;
|
||||
plotRequired = false;
|
||||
|
||||
//widget related initialization
|
||||
|
||||
@ -234,8 +235,6 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
boxPlot->setAlignment(Qt::AlignHCenter);
|
||||
boxPlot->setFont(QFont("Sans Serif",11,QFont::Normal));
|
||||
boxPlot->setTitle("Sample Plot");
|
||||
plot_update_timer = new QTimer(this);
|
||||
connect(plot_update_timer, SIGNAL(timeout()), this, SLOT(UpdatePlot()));
|
||||
data_pause_timer = new QTimer(this);
|
||||
connect(data_pause_timer, SIGNAL(timeout()), this, SLOT(UpdatePause()));
|
||||
|
||||
@ -333,6 +332,10 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
myDet->registerMeasurementFinishedCallback(&(GetMeasurementFinishedCallBack),this);
|
||||
//Setting the callback function to get progress from detector class(using receivers)
|
||||
myDet->registerProgressCallback(&(GetProgressCallBack),this);
|
||||
//stream data from receiver to the gui
|
||||
if(detType != slsDetectorDefs::MYTHEN)
|
||||
myDet->enableDataStreamingFromReceiver(1);
|
||||
|
||||
|
||||
qDefs::checkErrorMessage(myDet,"qDrawPlot::SetupWidgetWindow");
|
||||
}
|
||||
@ -342,6 +345,7 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
|
||||
|
||||
void qDrawPlot::Initialization(){
|
||||
connect(this, SIGNAL(UpdatePlotSignal()), this, SLOT(UpdatePlot()));
|
||||
connect(this, SIGNAL(InterpolateSignal(bool)),plot2D, SIGNAL(InterpolateSignal(bool)));
|
||||
connect(this, SIGNAL(ContourSignal(bool)), plot2D, SIGNAL(ContourSignal(bool)));
|
||||
connect(this, SIGNAL(LogzSignal(bool)), plot2D, SLOT(SetZScaleToLog(bool)));
|
||||
@ -371,7 +375,6 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
|
||||
// Reset Current Measurement
|
||||
currentMeasurement = 0;
|
||||
emit SetCurrentMeasurementSignal(currentMeasurement);
|
||||
//to get the first image
|
||||
data_pause_over = true;
|
||||
//in case of error message
|
||||
alreadyDisplayed = false;
|
||||
@ -438,13 +441,11 @@ void qDrawPlot::StartDaq(bool start){
|
||||
#endif
|
||||
ResetDaqForGui();
|
||||
StartDaqForGui();
|
||||
UpdatePlot();
|
||||
}else{
|
||||
#ifdef VERBOSE
|
||||
cout << "Start Daq(false) function" << endl;
|
||||
#endif
|
||||
StopDaqForGui();
|
||||
StopUpdatePlot();
|
||||
}
|
||||
}
|
||||
|
||||
@ -492,12 +493,12 @@ bool qDrawPlot::StartOrStopThread(bool start){
|
||||
plot2D->GetPlot()->SetZoom(-0.5,startPixel,nPixelsX,endPixel-startPixel);
|
||||
plot2D->GetPlot()->UnZoom();
|
||||
/*XYRangeChanged = true;*/
|
||||
boxPlot->setTitle("Old_Plot.raw");
|
||||
|
||||
cout << "Starting new acquisition thread ...." << endl;
|
||||
// Start acquiring data from server
|
||||
if(!firstTime) pthread_join(gui_acquisition_thread,NULL);//wait until he's finished, ie. exits
|
||||
pthread_create(&gui_acquisition_thread, NULL,DataStartAcquireThread, (void*) this);
|
||||
firstPlot = true;
|
||||
// This is set here and later reset to zero when all the plotting is done
|
||||
// This is manually done instead of keeping track of thread because
|
||||
// this thread returns immediately after executing the acquire command
|
||||
@ -637,6 +638,7 @@ void qDrawPlot::SetupMeasurement(){
|
||||
// Defaults
|
||||
if(!running)
|
||||
stop_signal = 0;
|
||||
plotRequired = 0;
|
||||
currentFrame = 0;
|
||||
//for 2d scans
|
||||
currentScanDivLevel = 0;
|
||||
@ -773,11 +775,11 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
|
||||
#endif
|
||||
// secondary title necessary to differentiate between frames when not saving data
|
||||
char temp_title[2000];
|
||||
//findex is used because in the receiver, you cannot know the frame index as many frames are in 1 file.
|
||||
//findex is the frame index given by receiver, cannot be derived from file name
|
||||
if(fIndex!=-1){
|
||||
currentFrameIndex=fIndex;
|
||||
sprintf(temp_title,"#%d",fIndex);
|
||||
if((myDet->getDetectorsType()==slsDetectorDefs::EIGER) && (subIndex != -1))
|
||||
if((detType==slsDetectorDefs::EIGER) && (subIndex != -1))
|
||||
sprintf(temp_title,"#%d %d",fIndex,subIndex);
|
||||
}else{
|
||||
if(fileSaveEnable) strcpy(temp_title,"#%d");
|
||||
@ -787,7 +789,9 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
|
||||
sprintf(temp_title,"#%d %d",fIndex,subIndex);
|
||||
|
||||
//Plot Disabled
|
||||
if(!plotEnable) return 0;
|
||||
if(!plotEnable)
|
||||
return 0;
|
||||
|
||||
|
||||
//angle plotting
|
||||
if(anglePlot){
|
||||
@ -825,16 +829,16 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
|
||||
}
|
||||
}
|
||||
if (k>0) {
|
||||
cout << "*** ERROR: value at " << k << " places have infinity values!" << endl;
|
||||
double m1,m2,s1;
|
||||
GetStatistics(m1,m2,s1,data->angles,nAnglePixelsX);
|
||||
cout << "angle min:" << m1 << endl;
|
||||
cout << "angle max:" << m2 << endl;
|
||||
cout << "angle sum:" << s1 << endl;
|
||||
GetStatistics(m1,m2,s1,data->values,nAnglePixelsX);
|
||||
cout << "value min:" << m1 << endl;
|
||||
cout << "value max:" << m2 << endl;
|
||||
cout << "value sum:" << s1 << endl;
|
||||
cout << "*** ERROR: value at " << k << " places have infinity values!" << endl;
|
||||
double m1,m2,s1;
|
||||
GetStatistics(m1,m2,s1,data->angles,nAnglePixelsX);
|
||||
cout << "angle min:" << m1 << endl;
|
||||
cout << "angle max:" << m2 << endl;
|
||||
cout << "angle sum:" << s1 << endl;
|
||||
GetStatistics(m1,m2,s1,data->values,nAnglePixelsX);
|
||||
cout << "value min:" << m1 << endl;
|
||||
cout << "value max:" << m2 << endl;
|
||||
cout << "value sum:" << s1 << endl;
|
||||
}
|
||||
#endif
|
||||
memcpy(histXAngleAxis,data->angles,nAnglePixelsX*sizeof(double));
|
||||
@ -846,39 +850,39 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Exiting GetData Function " << endl;
|
||||
#endif
|
||||
emit UpdatePlotSignal();
|
||||
plotRequired = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//nth frame or delay decision (data copied later on)
|
||||
if (detType == slsDetectorDefs::MYTHEN){
|
||||
//Nth Frame
|
||||
if(frameFactor){
|
||||
//plots if numfactor becomes 0
|
||||
if(!numFactor) numFactor=frameFactor-1;
|
||||
//return if not
|
||||
else{
|
||||
numFactor--;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Nth Frame
|
||||
if(frameFactor){
|
||||
//plots if numfactor becomes 0
|
||||
if(!numFactor) numFactor=frameFactor-1;
|
||||
//return if not
|
||||
else{
|
||||
numFactor--;
|
||||
return 0;
|
||||
}
|
||||
//Not Nth Frame, to check time out(NOT for Scans and angle plots)
|
||||
else{
|
||||
if (scanArgument == qDefs::None) {
|
||||
//if the time is not over, RETURN
|
||||
if(!data_pause_over){
|
||||
return 0;
|
||||
}
|
||||
data_pause_over=false;
|
||||
data_pause_timer->start((int)(timerValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Not Nth Frame, to check time out(NOT for Scans and angle plots)
|
||||
else{
|
||||
if (scanArgument == qDefs::None) {
|
||||
//if the time is not over, RETURN
|
||||
if(!data_pause_over){
|
||||
return 0;
|
||||
}
|
||||
data_pause_over=false;
|
||||
data_pause_timer->start((int)(PLOT_TIMER_MS/2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//if scan
|
||||
//alframes
|
||||
if(scanArgument==qDefs::AllFrames){
|
||||
@ -894,6 +898,8 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
|
||||
UnlockLastImageArray();
|
||||
currentFrame++;
|
||||
currentScanDivLevel++;
|
||||
emit UpdatePlotSignal();
|
||||
plotRequired = true;
|
||||
return 0;
|
||||
}
|
||||
//file index
|
||||
@ -911,6 +917,8 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
|
||||
UnlockLastImageArray();
|
||||
currentFrame++;
|
||||
currentScanDivLevel++;
|
||||
emit UpdatePlotSignal();
|
||||
plotRequired = true;
|
||||
return 0;
|
||||
}
|
||||
//level0
|
||||
@ -934,6 +942,8 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
|
||||
for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px];
|
||||
UnlockLastImageArray();
|
||||
currentFrame++;
|
||||
emit UpdatePlotSignal();
|
||||
plotRequired = true;
|
||||
return 0;
|
||||
}
|
||||
//level1
|
||||
@ -957,174 +967,128 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
|
||||
for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px];
|
||||
UnlockLastImageArray();
|
||||
currentFrame++;
|
||||
emit UpdatePlotSignal();
|
||||
plotRequired = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//normal measurement or 1d scans
|
||||
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
|
||||
//set title
|
||||
plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1);
|
||||
// only if you got the lock, do u need to remember lastimagenumber to plot
|
||||
lastImageNumber= currentFrame+1;
|
||||
LockLastImageArray();
|
||||
/*if(!pthread_mutex_trylock(&(last_image_complete_mutex))){*/
|
||||
//set title
|
||||
plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1);
|
||||
// only if you got the lock, do u need to remember lastimagenumber to plot
|
||||
lastImageNumber= currentFrame+1;
|
||||
//cout<<"got last imagenumber:"<<lastImageNumber<<endl;
|
||||
//1d
|
||||
if(plot_in_scope==1){
|
||||
// Titles
|
||||
histTitle[0] = temp_title;
|
||||
|
||||
//1d
|
||||
if(plot_in_scope==1){
|
||||
// Titles
|
||||
histTitle[0] = temp_title;
|
||||
//histogram
|
||||
if(histogram){
|
||||
resetAccumulate = false;
|
||||
lastImageNumber= currentFrame+1;
|
||||
|
||||
//histogram
|
||||
if(histogram){
|
||||
resetAccumulate = false;
|
||||
lastImageNumber= currentFrame+1;
|
||||
int numValues = nPixelsX;
|
||||
if(originally2D)
|
||||
numValues = nPixelsX*nPixelsY;
|
||||
|
||||
int numValues = nPixelsX;
|
||||
if(originally2D)
|
||||
numValues = nPixelsX*nPixelsY;
|
||||
//clean up graph
|
||||
if(histogramArgument == qDefs::Intensity){
|
||||
for(int j=0;j<histogramSamples.size();j++){
|
||||
histogramSamples[j].value = 0;
|
||||
|
||||
//clean up graph
|
||||
}
|
||||
}
|
||||
|
||||
int val = 0 ;
|
||||
for(int i=0;i<numValues;i++){
|
||||
//frequency of intensity
|
||||
if(histogramArgument == qDefs::Intensity){
|
||||
for(int j=0;j<histogramSamples.size();j++){
|
||||
histogramSamples[j].value = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int val = 0 ;
|
||||
for(int i=0;i<numValues;i++){
|
||||
//frequency of intensity
|
||||
if(histogramArgument == qDefs::Intensity){
|
||||
//ignore outside limits
|
||||
if ((data->values[i] < histFrom) || (data->values[i] > histTo))
|
||||
continue;
|
||||
//check for intervals, increment if validates
|
||||
for(int j=0;j<histogramSamples.size();j++){
|
||||
if(histogramSamples[j].interval.contains(data->values[i]))
|
||||
histogramSamples[j].value += 1;
|
||||
|
||||
}
|
||||
}
|
||||
//get sum of data pixels
|
||||
else
|
||||
val += data->values[i];
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(histogramArgument != qDefs::Intensity){
|
||||
val /= numValues;
|
||||
|
||||
//find scan value
|
||||
int ci = 0, fi = 0; double cs0 = 0 , cs1 = 0;
|
||||
fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, cs0, cs1);
|
||||
|
||||
int scanval=-1;
|
||||
if(cs0 != -1)
|
||||
scanval = cs0;
|
||||
else scanval = cs1;
|
||||
|
||||
//ignore outside limits
|
||||
if ((scanval < histFrom) || (scanval > histTo) || (scanval == -1))
|
||||
scanval = -1;
|
||||
if ((data->values[i] < histFrom) || (data->values[i] > histTo))
|
||||
continue;
|
||||
//check for intervals, increment if validates
|
||||
for(int j=0;j<histogramSamples.size();j++){
|
||||
if(histogramSamples[j].interval.contains(scanval)){
|
||||
histogramSamples[j].value = val;
|
||||
cout << "j:"<<j<<" scanval:"<<scanval<<" val:"<<val<<endl;
|
||||
}
|
||||
if(histogramSamples[j].interval.contains(data->values[i]))
|
||||
histogramSamples[j].value += 1;
|
||||
|
||||
}
|
||||
}
|
||||
//get sum of data pixels
|
||||
else
|
||||
val += data->values[i];
|
||||
|
||||
}
|
||||
//not histogram
|
||||
else{
|
||||
// Persistency
|
||||
if(currentPersistency < persistency)currentPersistency++;
|
||||
else currentPersistency=persistency;
|
||||
nHists = currentPersistency+1;
|
||||
histNBins = nPixelsX;
|
||||
|
||||
// copy data
|
||||
for(int i=currentPersistency;i>0;i--)
|
||||
memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double));
|
||||
|
||||
//recalculating pedestal
|
||||
if(startPedestalCal){
|
||||
//start adding frames to get to the pedestal value
|
||||
if(pedestalCount<NUM_PEDESTAL_FRAMES){
|
||||
for(unsigned int px=0;px<nPixelsX;px++)
|
||||
tempPedestalVals[px] += data->values[px];
|
||||
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
|
||||
pedestalCount++;
|
||||
}
|
||||
//calculate the pedestal value
|
||||
if(pedestalCount==NUM_PEDESTAL_FRAMES){
|
||||
cout << "Pedestal Calculated" << endl;
|
||||
for(unsigned int px=0;px<nPixelsX;px++)
|
||||
tempPedestalVals[px] = tempPedestalVals[px]/(double)NUM_PEDESTAL_FRAMES;
|
||||
memcpy(pedestalVals,tempPedestalVals,nPixelsX*sizeof(double));
|
||||
startPedestalCal = 0;
|
||||
if(histogramArgument != qDefs::Intensity){
|
||||
val /= numValues;
|
||||
|
||||
//find scan value
|
||||
int ci = 0, fi = 0; double cs0 = 0 , cs1 = 0;
|
||||
fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, cs0, cs1);
|
||||
|
||||
int scanval=-1;
|
||||
if(cs0 != -1)
|
||||
scanval = cs0;
|
||||
else scanval = cs1;
|
||||
|
||||
//ignore outside limits
|
||||
if ((scanval < histFrom) || (scanval > histTo) || (scanval == -1))
|
||||
scanval = -1;
|
||||
//check for intervals, increment if validates
|
||||
for(int j=0;j<histogramSamples.size();j++){
|
||||
if(histogramSamples[j].interval.contains(scanval)){
|
||||
histogramSamples[j].value = val;
|
||||
cout << "j:"<<j<<" scanval:"<<scanval<<" val:"<<val<<endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//normal data
|
||||
if(((!pedestal)&(!accumulate)&(!binary)) || (resetAccumulate)){
|
||||
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
|
||||
resetAccumulate = false;
|
||||
}
|
||||
//pedestal or accumulate
|
||||
else{
|
||||
double temp;//cannot overwrite cuz of accumulate
|
||||
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++){
|
||||
temp = data->values[px];
|
||||
if(pedestal)
|
||||
temp = data->values[px] - (pedestalVals[px]);
|
||||
if(binary) {
|
||||
if ((temp >= binaryFrom) && (temp <= binaryTo))
|
||||
temp = 1;
|
||||
else
|
||||
temp = 0;
|
||||
}
|
||||
if(accumulate)
|
||||
temp += histYAxis[0][px];
|
||||
//after all processing
|
||||
histYAxis[0][px] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//2d
|
||||
//not histogram
|
||||
else{
|
||||
// Titles
|
||||
imageTitle = temp_title;
|
||||
// Persistency
|
||||
if(currentPersistency < persistency)currentPersistency++;
|
||||
else currentPersistency=persistency;
|
||||
nHists = currentPersistency+1;
|
||||
histNBins = nPixelsX;
|
||||
|
||||
// copy data
|
||||
for(int i=currentPersistency;i>0;i--)
|
||||
memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double));
|
||||
|
||||
//recalculating pedestal
|
||||
if(startPedestalCal){
|
||||
//start adding frames to get to the pedestal value
|
||||
if(pedestalCount<NUM_PEDESTAL_FRAMES){
|
||||
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
|
||||
for(unsigned int px=0;px<nPixelsX;px++)
|
||||
tempPedestalVals[px] += data->values[px];
|
||||
memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
|
||||
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
|
||||
pedestalCount++;
|
||||
}
|
||||
//calculate the pedestal value
|
||||
if(pedestalCount==NUM_PEDESTAL_FRAMES){
|
||||
cout << "Pedestal Calculated" << endl;
|
||||
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
|
||||
for(unsigned int px=0;px<nPixelsX;px++)
|
||||
tempPedestalVals[px] = tempPedestalVals[px]/(double)NUM_PEDESTAL_FRAMES;
|
||||
memcpy(pedestalVals,tempPedestalVals,nPixelsX*nPixelsY*sizeof(double));
|
||||
memcpy(pedestalVals,tempPedestalVals,nPixelsX*sizeof(double));
|
||||
startPedestalCal = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//normal data
|
||||
if(((!pedestal)&(!accumulate)&(!binary)) || (resetAccumulate)){
|
||||
memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
|
||||
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
|
||||
resetAccumulate = false;
|
||||
}
|
||||
//pedestal or accumulate or binary
|
||||
//pedestal or accumulate
|
||||
else{
|
||||
double temp;
|
||||
double temp;//cannot overwrite cuz of accumulate
|
||||
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++){
|
||||
temp = data->values[px];
|
||||
if(pedestal)
|
||||
@ -1136,20 +1100,75 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
|
||||
temp = 0;
|
||||
}
|
||||
if(accumulate)
|
||||
temp += lastImageArray[px];
|
||||
temp += histYAxis[0][px];
|
||||
//after all processing
|
||||
lastImageArray[px] = temp;
|
||||
histYAxis[0][px] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
pthread_mutex_unlock(&(last_image_complete_mutex));
|
||||
}
|
||||
//2d
|
||||
else{
|
||||
// Titles
|
||||
imageTitle = temp_title;
|
||||
//recalculating pedestal
|
||||
if(startPedestalCal){
|
||||
//start adding frames to get to the pedestal value
|
||||
if(pedestalCount<NUM_PEDESTAL_FRAMES){
|
||||
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
|
||||
tempPedestalVals[px] += data->values[px];
|
||||
memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
|
||||
pedestalCount++;
|
||||
}
|
||||
//calculate the pedestal value
|
||||
if(pedestalCount==NUM_PEDESTAL_FRAMES){
|
||||
cout << "Pedestal Calculated" << endl;
|
||||
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
|
||||
tempPedestalVals[px] = tempPedestalVals[px]/(double)NUM_PEDESTAL_FRAMES;
|
||||
memcpy(pedestalVals,tempPedestalVals,nPixelsX*nPixelsY*sizeof(double));
|
||||
startPedestalCal = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//normal data
|
||||
if(((!pedestal)&(!accumulate)&(!binary)) || (resetAccumulate)){
|
||||
memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
|
||||
resetAccumulate = false;
|
||||
}
|
||||
//pedestal or accumulate or binary
|
||||
else{
|
||||
double temp;
|
||||
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++){
|
||||
temp = data->values[px];
|
||||
if(pedestal)
|
||||
temp = data->values[px] - (pedestalVals[px]);
|
||||
if(binary) {
|
||||
if ((temp >= binaryFrom) && (temp <= binaryTo))
|
||||
temp = 1;
|
||||
else
|
||||
temp = 0;
|
||||
}
|
||||
if(accumulate)
|
||||
temp += lastImageArray[px];
|
||||
//after all processing
|
||||
lastImageArray[px] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* pthread_mutex_unlock(&(last_image_complete_mutex));
|
||||
}*/
|
||||
UnlockLastImageArray();
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
cout<<"currentframe:"<<currentFrame<<"\tcurrentframeindex:"<<currentFrameIndex<<endl;
|
||||
cprintf(BLUE,"currentframe:%d \tcurrentframeindex:%d\n",currentFrame,currentFrameIndex);
|
||||
#endif
|
||||
emit UpdatePlotSignal();
|
||||
plotRequired = true;
|
||||
currentFrame++;
|
||||
}
|
||||
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Exiting GetData function" << endl;
|
||||
#endif
|
||||
@ -1162,7 +1181,9 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
|
||||
|
||||
int qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress,int detectorStatus, void *this_pointer){
|
||||
((qDrawPlot*)this_pointer)->AcquisitionFinished(currentProgress,detectorStatus);
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "acquisition finished callback worked ok" << endl;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1253,9 +1274,11 @@ int qDrawPlot::MeasurementFinished(int currentMeasurementIndex, int fileIndex){
|
||||
#ifdef VERBOSE
|
||||
cout << "Entering Measurement Finished with currentMeasurement " << currentMeasurementIndex << " and fileIndex " << fileIndex << endl;
|
||||
#endif
|
||||
//to make sure it plots the last frame before setting lastimagearray all to 0
|
||||
//if(plot_in_scope==2)
|
||||
usleep(500000);
|
||||
|
||||
//to make sure it plots the last frame
|
||||
while(plotRequired){
|
||||
usleep(2000);
|
||||
}
|
||||
|
||||
currentMeasurement = currentMeasurementIndex+1;
|
||||
currentFileIndex = fileIndex;
|
||||
@ -1264,8 +1287,8 @@ int qDrawPlot::MeasurementFinished(int currentMeasurementIndex, int fileIndex){
|
||||
#endif
|
||||
emit SetCurrentMeasurementSignal(currentMeasurement);
|
||||
SetupMeasurement();
|
||||
if((myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) && (myDet->getFramesCaughtByReceiver() == 0))
|
||||
boxPlot->setTitle("OLD_plot.raw");
|
||||
/*if((myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) && (myDet->getFramesCaughtByReceiver() == 0))
|
||||
boxPlot->setTitle("OLD_plot.raw");*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1320,16 +1343,16 @@ void qDrawPlot::UpdatePlot(){
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Entering UpdatePlot function" << endl;
|
||||
#endif
|
||||
plot_update_timer->stop();
|
||||
|
||||
// only if no plot isnt enabled
|
||||
if(plotEnable){
|
||||
if(plotEnable && plotRequired){
|
||||
LockLastImageArray();
|
||||
//so that it doesnt plot every single thing
|
||||
if(lastImageNumber!=last_plot_number){
|
||||
#ifdef VERYVERBOSE
|
||||
cprintf(GREEN,"Updating Plot\n");
|
||||
#endif
|
||||
//so as to not plot it again and to let measurment finished know its done plotting it
|
||||
//1-d plot stuff
|
||||
if(plot_in_scope==1){
|
||||
if(lastImageNumber){
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Last Image Number:" << lastImageNumber << endl;
|
||||
#endif
|
||||
@ -1346,9 +1369,11 @@ void qDrawPlot::UpdatePlot(){
|
||||
histFrameIndexTitle->setText(GetHistTitle(0));
|
||||
plotHistogram->attach(plot1D);
|
||||
//refixing all the zooming
|
||||
|
||||
plot1D->SetXMinMax(startPixel,endPixel);
|
||||
plot1D->SetYMinMax(0,plotHistogram->boundingRect().height());
|
||||
plot1D->SetZoomBase(startPixel,0,endPixel-startPixel,plotHistogram->boundingRect().height());
|
||||
|
||||
}
|
||||
//not histogram
|
||||
else{
|
||||
@ -1372,50 +1397,50 @@ void qDrawPlot::UpdatePlot(){
|
||||
//h->setTitle(GetHistTitle(hist_num));
|
||||
h->Attach(plot1D);
|
||||
//refixing all the zooming
|
||||
if((firstPlot) || (anglePlot)){
|
||||
//if((firstPlot) || (anglePlot)){
|
||||
/*plot1D->SetXMinMax(h->minXValue(),h->maxXValue());
|
||||
plot1D->SetYMinMax(h->minYValue(),h->maxYValue());
|
||||
plot1D->SetZoomBase(h->minXValue(),h->minYValue(),
|
||||
h->maxXValue()-h->minXValue(),h->maxYValue()-h->minYValue());*/
|
||||
firstPlot = false;
|
||||
}
|
||||
// firstPlot = false;
|
||||
//}
|
||||
}
|
||||
|
||||
/**moved from below (had applied to histograms as well) to here, */
|
||||
// update range if required
|
||||
if(XYRangeChanged){
|
||||
if(!IsXYRange[qDefs::XMINIMUM]) XYRangeValues[qDefs::XMINIMUM]= plot1D->GetXMinimum();
|
||||
if(!IsXYRange[qDefs::XMAXIMUM]) XYRangeValues[qDefs::XMAXIMUM]= plot1D->GetXMaximum();
|
||||
if(!IsXYRange[qDefs::YMINIMUM]) XYRangeValues[qDefs::YMINIMUM]= plot1D->GetYMinimum();
|
||||
if(!IsXYRange[qDefs::YMAXIMUM]) XYRangeValues[qDefs::YMAXIMUM]= plot1D->GetYMaximum();
|
||||
plot1D->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]);
|
||||
plot1D->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
|
||||
//Should not be reset for histogram,
|
||||
//that is the only way to zoom in (new plots are zoomed out as its different each time)
|
||||
if(!histogram)
|
||||
XYRangeChanged = false;
|
||||
}
|
||||
/**moved from below (had applied to histograms as well) to here, */
|
||||
//Display Statistics
|
||||
if(displayStatistics){
|
||||
double min=0,max=0,sum=0;
|
||||
if(anglePlot)
|
||||
GetStatistics(min,max,sum,histYAngleAxis,histNBins);
|
||||
else
|
||||
GetStatistics(min,max,sum,histYAxis[0],histNBins);
|
||||
lblMinDisp->setText(QString("%1").arg(min));
|
||||
lblMaxDisp->setText(QString("%1").arg(max));
|
||||
lblSumDisp->setText(QString("%1").arg(sum));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// update range if required
|
||||
if(XYRangeChanged){
|
||||
if(!IsXYRange[qDefs::XMINIMUM]) XYRangeValues[qDefs::XMINIMUM]= plot1D->GetXMinimum();
|
||||
if(!IsXYRange[qDefs::XMAXIMUM]) XYRangeValues[qDefs::XMAXIMUM]= plot1D->GetXMaximum();
|
||||
if(!IsXYRange[qDefs::YMINIMUM]) XYRangeValues[qDefs::YMINIMUM]= plot1D->GetYMinimum();
|
||||
if(!IsXYRange[qDefs::YMAXIMUM]) XYRangeValues[qDefs::YMAXIMUM]= plot1D->GetYMaximum();
|
||||
plot1D->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]);
|
||||
plot1D->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
|
||||
//Should not be reset for histogram,
|
||||
//that is the only way to zoom in (new plots are zoomed out as its different each time)
|
||||
if(!histogram)
|
||||
XYRangeChanged = false;
|
||||
}
|
||||
//Display Statistics
|
||||
if(displayStatistics){
|
||||
double min=0,max=0,sum=0;
|
||||
if(anglePlot)
|
||||
GetStatistics(min,max,sum,histYAngleAxis,histNBins);
|
||||
else
|
||||
GetStatistics(min,max,sum,histYAxis[0],histNBins);
|
||||
lblMinDisp->setText(QString("%1").arg(min));
|
||||
lblMaxDisp->setText(QString("%1").arg(max));
|
||||
lblSumDisp->setText(QString("%1").arg(sum));
|
||||
}
|
||||
if(saveAll) SavePlotAutomatic();
|
||||
|
||||
}
|
||||
}
|
||||
}//2-d plot stuff
|
||||
else{
|
||||
if(lastImageArray){
|
||||
if(lastImageNumber&&last_plot_number!=(int)lastImageNumber && //there is a new plot
|
||||
nPixelsX>0&&nPixelsY>0){
|
||||
if(nPixelsX>0&&nPixelsY>0){
|
||||
plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,lastImageArray);
|
||||
plot2D->setTitle(GetImageTitle());
|
||||
plot2D->SetXTitle(imageXAxisTitle);
|
||||
@ -1445,20 +1470,13 @@ void qDrawPlot::UpdatePlot(){
|
||||
if(saveAll) SavePlotAutomatic();
|
||||
}
|
||||
}
|
||||
last_plot_number=lastImageNumber;
|
||||
//set plot title
|
||||
boxPlot->setTitle(plotTitle);
|
||||
}
|
||||
//to notify the measurement finished when its done
|
||||
plotRequired = false;
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
//if acq stopped before this line, it continues from here, shouldnt restart plotting timer
|
||||
if(!stop_signal){
|
||||
if(!frameFactor)
|
||||
plot_update_timer->start((int)timerValue);
|
||||
else
|
||||
plot_update_timer->start((int)PLOT_TIMER_MS);
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Exiting UpdatePlot function" << endl;
|
||||
#endif
|
||||
@ -1468,17 +1486,6 @@ void qDrawPlot::UpdatePlot(){
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qDrawPlot::StopUpdatePlot(){
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Entering StopUpdatePlot()" << endl;
|
||||
#endif
|
||||
plot_update_timer->stop();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qDrawPlot::ClonePlot(){
|
||||
int i;
|
||||
|
||||
@ -1724,7 +1731,6 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){
|
||||
|
||||
LockLastImageArray();
|
||||
|
||||
slsDetectorDefs::detectorType detType = myDet->getDetectorsType();
|
||||
if(detType == slsDetectorDefs::MYTHEN){
|
||||
|
||||
//get trimbits
|
||||
@ -1942,11 +1948,25 @@ void qDrawPlot::ResetAccumulate(){
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qDrawPlot::SetPlotTimer(double time){
|
||||
timerValue = time;
|
||||
if(myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG){
|
||||
time = myDet->setReceiverReadTimer(timerValue);
|
||||
#ifdef VERBOSE
|
||||
cout << "Receiver read timer set to : " << time << endl;
|
||||
#endif
|
||||
qDefs::checkErrorMessage(myDet,"qDrawPlot::SetPlotTimer");
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qDrawPlot::SetFrameFactor(int frame){
|
||||
frameFactor = frame;
|
||||
if(myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG){
|
||||
frame = myDet->setReadReceiverFrequency(1,frame);
|
||||
if(frame > 0) frameFactor = 1;
|
||||
/*if(frame > 0) frameFactor = 1;*//**what is this*/
|
||||
#ifdef VERBOSE
|
||||
cout << "Receiver read frequency set to : " << frame << endl;
|
||||
#endif
|
||||
|
@ -529,6 +529,7 @@ void qTabActions::Refresh(){
|
||||
#ifdef VERBOSE
|
||||
cout << "**Updated all action widgets: " << endl << endl;
|
||||
#endif
|
||||
|
||||
qDefs::checkErrorMessage(myDet,"qTabActions::Refresh");
|
||||
}
|
||||
|
||||
|
@ -391,6 +391,7 @@ void qTabMeasurement::SetCurrentMeasurement(int val){
|
||||
void qTabMeasurement::UpdateProgress(){
|
||||
progressBar->setValue((int)myPlot->GetProgress());
|
||||
lblProgressIndex->setText(QString::number(myPlot->GetFrameIndex()));
|
||||
qDefs::checkErrorMessage(myDet,"qTabMeasurement::UpdateProgress");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1007,7 +1007,7 @@ void qTabPlot::SetScanArgument(){
|
||||
|
||||
}
|
||||
|
||||
cout <<"min:"<<min<<" max:"<<max<<" size:"<<size<<endl;
|
||||
//cout <<"min:"<<min<<" max:"<<max<<" size:"<<size<<endl;
|
||||
myPlot->SetHistogram(radioHistogram->isChecked(),histArg,min,max,size);
|
||||
|
||||
|
||||
|
76
slsDetectorSoftware/CMakeLists.txt
Normal file
76
slsDetectorSoftware/CMakeLists.txt
Normal file
@ -0,0 +1,76 @@
|
||||
set(SOURCES
|
||||
multiSlsDetector/multiSlsDetector.cpp
|
||||
slsDetector/slsDetectorUsers.cpp
|
||||
slsDetector/slsDetectorUtils.cpp
|
||||
slsDetector/slsDetectorCommand.cpp
|
||||
slsDetector/slsDetectorActions.cpp
|
||||
slsDetector/slsDetector.cpp
|
||||
slsDetectorAnalysis/angularConversion.cpp
|
||||
slsDetectorAnalysis/angularConversionStatic.cpp
|
||||
slsDetectorAnalysis/energyConversion.cpp
|
||||
slsDetectorAnalysis/fileIO.cpp
|
||||
slsDetectorAnalysis/postProcessing.cpp
|
||||
slsDetectorAnalysis/postProcessingFuncs.cpp
|
||||
slsReceiverInterface/receiverInterface.cpp
|
||||
threadFiles/CondVar.cpp
|
||||
threadFiles/Mutex.cpp
|
||||
threadFiles/ThreadPool.cpp
|
||||
usersFunctions/usersFunctions.cpp
|
||||
)
|
||||
|
||||
set(HEADERS
|
||||
)
|
||||
|
||||
include_directories(
|
||||
commonFiles
|
||||
multiSlsDetector
|
||||
slsDetector
|
||||
slsDetectorUtils
|
||||
slsDetectorCommand
|
||||
slsDetectorAnalysis
|
||||
slsReceiverInterface
|
||||
threadFiles
|
||||
usersFunctions
|
||||
../slsReceiverSoftware/include
|
||||
../slsReceiverSoftware/MySocketTCP
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
-DDACS_INT
|
||||
)
|
||||
|
||||
add_library(zmq STATIC IMPORTED )
|
||||
|
||||
set_target_properties(zmq PROPERTIES
|
||||
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../slsReceiverSoftware/include/libzmq.a
|
||||
)
|
||||
|
||||
add_library(slsDetectorStatic STATIC
|
||||
${SOURCES}
|
||||
${HEADERS}
|
||||
)
|
||||
set_target_properties(slsDetectorStatic PROPERTIES
|
||||
ARCHIVE_OUTPUT_NAME SlsDetector
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
add_library(slsDetectorShared SHARED
|
||||
${SOURCES}
|
||||
${HEADERS}
|
||||
)
|
||||
set_target_properties(slsDetectorShared PROPERTIES
|
||||
LIBRARY_OUTPUT_NAME SlsDetector
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
add_subdirectory(slsDetectorClient)
|
||||
|
||||
if(DOXYGEN_FOUND)
|
||||
add_custom_target(doc
|
||||
${DOXYGEN_EXECUTABLE}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/slsDetectorUsers.doxy
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
@ -18,6 +18,9 @@ INCLUDES?= -IcommonFiles -IslsDetector -I../slsReceiverSoftware/MySocketTCP -Ius
|
||||
SRC_CLNT=slsDetectorAnalysis/fileIO.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp slsDetector/slsDetectorUsers.cpp threadFiles/CondVar.cpp threadFiles/Mutex.cpp threadFiles/ThreadPool.cpp #../slsReceiverSoftware/MySocketTCP/MySocketTCP.cpp
|
||||
|
||||
|
||||
LIBZMQDIR = ../slsReceiverSoftware/include
|
||||
LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq
|
||||
|
||||
$(info )
|
||||
$(info #######################################)
|
||||
$(info # Compiling slsDetectorSoftware #)
|
||||
@ -66,14 +69,14 @@ gotthardVirtualServer: $(SRC_MYTHEN_SVC)
|
||||
|
||||
|
||||
%.o : %.cpp %.h Makefile
|
||||
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -lpthread #$(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
|
||||
$(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)
|
||||
|
||||
|
@ -137,7 +137,7 @@ int acceptConnection(int socketDescriptor) {
|
||||
|
||||
|
||||
//socklen_t address_length;
|
||||
size_t address_length=sizeof(struct sockaddr_in);
|
||||
socklen_t address_length=sizeof(struct sockaddr_in);
|
||||
|
||||
if (socketDescriptor<0)
|
||||
return -1;
|
||||
@ -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) {
|
||||
|
@ -8,61 +8,75 @@
|
||||
#ifndef ERROR_DEFS_H_
|
||||
#define ERROR_DEFS_H_
|
||||
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "ansi.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
/** Error flags */
|
||||
#define CRITICAL_ERROR_MASK 0xFFFFFFFF
|
||||
/*Assumption: Only upto 63 detectors */
|
||||
|
||||
#define CANNOT_CONNECT_TO_DETECTOR 0x8000000000000000ULL
|
||||
#define CANNOT_CONNECT_TO_RECEIVER 0x4000000000000000ULL
|
||||
#define COULDNOT_SET_CONTROL_PORT 0x2000000000000000ULL
|
||||
#define COULDNOT_SET_STOP_PORT 0x1000000000000000ULL
|
||||
#define COULDNOT_SET_DATA_PORT 0x0800000000000000ULL
|
||||
#define FILE_PATH_DOES_NOT_EXIST 0x0400000000000000ULL
|
||||
#define COULDNOT_CREATE_UDP_SOCKET 0x0200000000000000ULL
|
||||
#define COULDNOT_CREATE_FILE 0x0100000000000000ULL
|
||||
#define COULDNOT_ENABLE_COMPRESSION 0x0080000000000000ULL
|
||||
#define RECEIVER_DET_HOSTNAME_NOT_SET 0x0040000000000000ULL
|
||||
#define RECEIVER_DET_HOSTTYPE_NOT_SET 0x0020000000000000ULL
|
||||
#define DETECTOR_TEN_GIGA 0x0010000000000000ULL
|
||||
#define DETECTOR_ACTIVATE 0x0008000000000000ULL
|
||||
#define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL
|
||||
|
||||
#define CRITICAL_ERROR_MASK 0xFFFFFFFF
|
||||
|
||||
// 0xFFFFFFFF00000000ULL
|
||||
|
||||
#define COULD_NOT_CONFIGURE_MAC 0x0000000000000001ULL
|
||||
#define COULDNOT_SET_NETWORK_PARAMETER 0x0000000000000002ULL
|
||||
#define COULDNOT_SET_ROI 0x0000000000000004ULL
|
||||
#define RECEIVER_READ_FREQUENCY 0x0000000000000008ULL
|
||||
#define SETTINGS_NOT_SET 0x0000000000000010ULL
|
||||
#define SETTINGS_FILE_NOT_OPEN 0x0000000000000020ULL
|
||||
#define COULDNOT_START_RECEIVER 0x0000000000000040ULL // default error like starting threads
|
||||
#define COULDNOT_STOP_RECEIVER 0x0000000000000080ULL
|
||||
#define DETECTOR_TIMER_VALUE_NOT_SET 0x0000000000000100ULL
|
||||
#define RECEIVER_ACQ_PERIOD_NOT_SET 0x0000000000000200ULL
|
||||
#define RECEIVER_FRAME_NUM_NOT_SET 0x0000000000000400ULL
|
||||
#define RECEIVER_DYNAMIC_RANGE 0x0000000000000800ULL
|
||||
#define RECEIVER_TEN_GIGA 0x0000000000001000ULL
|
||||
#define ALLTIMBITS_NOT_SET 0x0000000000002000ULL
|
||||
#define COULD_NOT_SET_SPEED_PARAMETERS 0x0000000000004000ULL
|
||||
#define COULD_NOT_SET_READOUT_FLAGS 0x0000000000008000ULL
|
||||
#define COULD_NOT_SET_FIFO_DEPTH 0x0000000000010000ULL
|
||||
#define COULD_NOT_SET_COUNTER_BIT 0x0000000000020000ULL
|
||||
#define COULD_NOT_PULSE_PIXEL 0x0000000000040000ULL
|
||||
#define COULD_NOT_PULSE_PIXEL_NMOVE 0x0000000000080000ULL
|
||||
#define COULD_NOT_PULSE_CHIP 0x0000000000100000ULL
|
||||
#define COULD_NOT_SET_RATE_CORRECTION 0x0000000000200000ULL
|
||||
#define DETECTOR_NETWORK_PARAMETER 0x0000000000400000ULL
|
||||
#define RATE_CORRECTION_NOT_32BIT 0x0000000000800000ULL
|
||||
#define RATE_CORRECTION_NO_TAU_PROVIDED 0x0000000001000000ULL
|
||||
#define CANNOT_CONNECT_TO_DETECTOR 0x4000000000000000ULL
|
||||
#define CANNOT_CONNECT_TO_RECEIVER 0x2000000000000000ULL
|
||||
#define COULDNOT_SET_CONTROL_PORT 0x1000000000000000ULL
|
||||
#define COULDNOT_SET_STOP_PORT 0x0800000000000000ULL
|
||||
#define COULDNOT_SET_DATA_PORT 0x0400000000000000ULL
|
||||
#define FILE_PATH_DOES_NOT_EXIST 0x0200000000000000ULL
|
||||
#define COULDNOT_CREATE_UDP_SOCKET 0x0100000000000000ULL
|
||||
#define COULDNOT_CREATE_FILE 0x0080000000000000ULL
|
||||
#define COULDNOT_ENABLE_COMPRESSION 0x0040000000000000ULL
|
||||
#define RECEIVER_DET_HOSTNAME_NOT_SET 0x0020000000000000ULL
|
||||
#define RECEIVER_DET_HOSTTYPE_NOT_SET 0x0010000000000000ULL
|
||||
#define DETECTOR_TEN_GIGA 0x0008000000000000ULL
|
||||
#define DETECTOR_ACTIVATE 0x0004000000000000ULL
|
||||
#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
|
||||
#define SETTINGS_NOT_SET 0x0000000000000008ULL
|
||||
#define SETTINGS_FILE_NOT_OPEN 0x0000000000000010ULL
|
||||
#define DETECTOR_TIMER_VALUE_NOT_SET 0x0000000000000020ULL
|
||||
#define RECEIVER_ACQ_PERIOD_NOT_SET 0x0000000000000040ULL
|
||||
#define RECEIVER_FRAME_NUM_NOT_SET 0x0000000000000080ULL
|
||||
#define RECEIVER_DYNAMIC_RANGE 0x0000000000000100ULL
|
||||
#define RECEIVER_TEN_GIGA 0x0000000000000200ULL
|
||||
#define ALLTIMBITS_NOT_SET 0x0000000000000400ULL
|
||||
#define COULD_NOT_SET_SPEED_PARAMETERS 0x0000000000000800ULL
|
||||
#define COULD_NOT_SET_READOUT_FLAGS 0x0000000000001000ULL
|
||||
#define COULD_NOT_SET_FIFO_DEPTH 0x0000000000002000ULL
|
||||
#define COULD_NOT_SET_COUNTER_BIT 0x0000000000004000ULL
|
||||
#define COULD_NOT_PULSE_PIXEL 0x0000000000008000ULL
|
||||
#define COULD_NOT_PULSE_PIXEL_NMOVE 0x0000000000010000ULL
|
||||
#define COULD_NOT_PULSE_CHIP 0x0000000000020000ULL
|
||||
#define COULD_NOT_SET_RATE_CORRECTION 0x0000000000040000ULL
|
||||
#define DETECTOR_NETWORK_PARAMETER 0x0000000000080000ULL
|
||||
#define RATE_CORRECTION_NOT_32or16BIT 0x0000000000100000ULL
|
||||
#define RATE_CORRECTION_NO_TAU_PROVIDED 0x0000000000200000ULL
|
||||
#define PROGRAMMING_ERROR 0x0000000000400000ULL
|
||||
#define RECEIVER_ACTIVATE 0x0000000000800000ULL
|
||||
#define DATA_STREAMING 0x0000000001000000ULL
|
||||
#define RESET_ERROR 0x0000000002000000ULL
|
||||
#define POWER_CHIP 0x0000000004000000ULL
|
||||
#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 {
|
||||
|
||||
@ -70,7 +84,9 @@ class errorDefs {
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
errorDefs():errorMask(0){};
|
||||
errorDefs():errorMask(0){
|
||||
strcpy(notAddedList,"");
|
||||
};
|
||||
|
||||
/** Gets the error message
|
||||
* param errorMask error mask
|
||||
@ -192,15 +208,35 @@ public:
|
||||
if(slsErrorMask&DETECTOR_NETWORK_PARAMETER)
|
||||
retval.append("Could not set/get detector network parameter\n");
|
||||
|
||||
if(slsErrorMask&RATE_CORRECTION_NOT_32BIT)
|
||||
retval.append("Rate correction Deactivated, must be in 32 bit mode\n");
|
||||
if(slsErrorMask&RATE_CORRECTION_NOT_32or16BIT)
|
||||
retval.append("Rate correction Deactivated, must be in 32 or 16 bit mode\n");
|
||||
|
||||
if(slsErrorMask&RATE_CORRECTION_NO_TAU_PROVIDED)
|
||||
retval.append("Rate correction Deactivated. No default tau provided in file\n");
|
||||
|
||||
if(slsErrorMask&PROGRAMMING_ERROR)
|
||||
retval.append("Could not program FPGA\n");
|
||||
|
||||
if(slsErrorMask&RECEIVER_ACTIVATE)
|
||||
retval.append("Could not activate/deactivate receiver\n");
|
||||
|
||||
if(slsErrorMask&DATA_STREAMING)
|
||||
retval.append("Could not set/reset Data Streaming\n");
|
||||
|
||||
if(slsErrorMask&RESET_ERROR)
|
||||
retval.append("Could not reset the FPGA\n");
|
||||
|
||||
if(slsErrorMask&POWER_CHIP)
|
||||
retval.append("Could not power on/off/get the chip\n");
|
||||
|
||||
if(slsErrorMask&RECEIVER_READ_TIMER)
|
||||
retval.append("Could not set receiver read timer\n");
|
||||
|
||||
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
|
||||
|
||||
@ -224,12 +260,31 @@ public:
|
||||
*/
|
||||
int64_t clearErrorMask(){errorMask=0;return errorMask;};
|
||||
|
||||
/** Gets the not added detector list
|
||||
/returns list
|
||||
*/
|
||||
char* getNotAddedList(){return notAddedList;};
|
||||
|
||||
/** Append the detector to not added detector list
|
||||
* @param name append to the list
|
||||
/returns list
|
||||
*/
|
||||
void appendNotAddedList(const char* name){strcat(notAddedList,name);strcat(notAddedList,"+");};
|
||||
|
||||
/** Clears not added detector list
|
||||
/returns error mask
|
||||
*/
|
||||
void clearNotAddedList(){strcpy(notAddedList,"");};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/** Error Mask */
|
||||
int64_t errorMask;
|
||||
|
||||
/** Detectors Not added List */
|
||||
char notAddedList[MAX_STR_LENGTH];
|
||||
|
||||
};
|
||||
|
||||
#endif /* ERROR_DEFS_H_ */
|
||||
|
@ -25,6 +25,9 @@
|
||||
/** maximum rois */
|
||||
#define MAX_ROIS 100
|
||||
|
||||
/** maximum unit size of program sent to detector */
|
||||
#define MAX_FPGAPROGRAMSIZE (2 * 1024 *1024)
|
||||
|
||||
|
||||
typedef char mystring[MAX_STR_LENGTH];
|
||||
typedef double mysteps[MAX_SCAN_STEPS];
|
||||
@ -123,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 */
|
||||
|
@ -103,8 +103,12 @@ enum {
|
||||
F_SET_RATE_CORRECT, /** < set/reset rate correction tau */
|
||||
F_GET_RATE_CORRECT, /** < get rate correction tau */
|
||||
|
||||
F_SET_NETWORK_PARAMETER /**< set network parameters such as transmission delay, flow control */
|
||||
|
||||
F_SET_NETWORK_PARAMETER, /**< set network parameters such as transmission delay, flow control */
|
||||
|
||||
F_PROGRAM_FPGA, /**< program FPGA */
|
||||
F_RESET_FPGA, /**< reset FPGA */
|
||||
F_POWER_CHIP /**< power chip */
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
};
|
||||
|
187
slsDetectorSoftware/eigerDetectorServer/9mhvserial_bf.c
Normal file
187
slsDetectorSoftware/eigerDetectorServer/9mhvserial_bf.c
Normal file
@ -0,0 +1,187 @@
|
||||
#include "ansi.h"
|
||||
|
||||
#include <termios.h> /* POSIX terminal control definitions */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> // atoi
|
||||
#include <fcntl.h> // File control definitions
|
||||
#include <sys/ioctl.h> // ioctl
|
||||
#include <unistd.h> // read, close
|
||||
#include <string.h> // memset
|
||||
#include <linux/i2c-dev.h> // I2C_SLAVE, __u8 reg
|
||||
|
||||
#define PORTNAME "/dev/ttyBF1"
|
||||
#define GOODBYE 200
|
||||
#define BUFFERSIZE 16
|
||||
#define I2C_DEVICE_FILE "/dev/i2c-0"
|
||||
#define I2C_DEVICE_ADDRESS 0x4C
|
||||
//#define I2C_DEVICE_ADDRESS 0x48
|
||||
#define I2C_REGISTER_ADDRESS 0x40
|
||||
|
||||
|
||||
|
||||
int i2c_open(const char* file,unsigned int addr){
|
||||
|
||||
//device file
|
||||
int fd = open( file, O_RDWR );
|
||||
if (fd < 0) {
|
||||
cprintf(RED,"Warning: Unable to open file %s\n",file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//device address
|
||||
if( ioctl( fd, I2C_SLAVE, addr&0x7F ) < 0 ) {
|
||||
cprintf(RED,"Warning: Unable to set slave address:0x%x \n",addr);
|
||||
return -2;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
int i2c_read(){
|
||||
|
||||
int fd = i2c_open(I2C_DEVICE_FILE, I2C_DEVICE_ADDRESS);
|
||||
__u8 reg = I2C_REGISTER_ADDRESS & 0xff;
|
||||
|
||||
unsigned char buf = reg;
|
||||
if (write(fd, &buf, 1)!= 1){
|
||||
cprintf(RED,"Warning: Unable to write read request to register %d\n", reg);
|
||||
return -1;
|
||||
}
|
||||
//read and update value (but old value read out)
|
||||
if(read(fd, &buf, 1) != 1){
|
||||
cprintf(RED,"Warning: Unable to read register %d\n", reg);
|
||||
return -2;
|
||||
}
|
||||
//read again to read the updated value
|
||||
if(read(fd, &buf, 1) != 1){
|
||||
cprintf(RED,"Warning: Unable to read register %d\n", reg);
|
||||
return -2;
|
||||
}
|
||||
close(fd);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
int i2c_write(unsigned int value){
|
||||
|
||||
__u8 val = value & 0xff;
|
||||
|
||||
int fd = i2c_open(I2C_DEVICE_FILE, I2C_DEVICE_ADDRESS);
|
||||
if(fd < 0)
|
||||
return fd;
|
||||
|
||||
__u8 reg = I2C_REGISTER_ADDRESS & 0xff;
|
||||
char buf[3];
|
||||
buf[0] = reg;
|
||||
buf[1] = val;
|
||||
if (write(fd, buf, 2) != 2) {
|
||||
cprintf(RED,"Warning: Unable to write %d to register %d\n",val, reg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
int fd = open(PORTNAME, O_RDWR | O_NOCTTY);
|
||||
if(fd < 0){
|
||||
cprintf(RED,"Warning: Unable to open port %s\n", PORTNAME);
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct termios serial_conf;
|
||||
// Get the current options for the port
|
||||
tcgetattr(fd, &serial_conf);
|
||||
// reset structure
|
||||
memset(&serial_conf,0,sizeof(serial_conf));
|
||||
// control options
|
||||
serial_conf.c_cflag = B2400 | CS8 | CREAD | CLOCAL;
|
||||
// input options
|
||||
serial_conf.c_iflag = IGNPAR;
|
||||
// output options
|
||||
serial_conf.c_oflag = 0;
|
||||
// line options
|
||||
serial_conf.c_lflag = ICANON;
|
||||
// flush input
|
||||
tcflush(fd, TCIFLUSH);
|
||||
// set new options for the port, TCSANOW:changes occur immediately without waiting for data to complete
|
||||
tcsetattr(fd, TCSANOW, &serial_conf);
|
||||
|
||||
|
||||
|
||||
|
||||
int ret = 0;
|
||||
int n = 0;
|
||||
int ival= 0;
|
||||
char buffer[BUFFERSIZE];
|
||||
buffer[BUFFERSIZE-2] = '\0';
|
||||
buffer[BUFFERSIZE-1] = '\n';
|
||||
cprintf(GREEN,"Ready...\n");
|
||||
|
||||
while(ret != GOODBYE){
|
||||
n = read(fd,buffer,BUFFERSIZE);
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||
#endif
|
||||
cprintf(BLUE,"Got message: %s\n",buffer);
|
||||
|
||||
switch(buffer[0]){
|
||||
case 'p':
|
||||
if (!sscanf(&buffer[1],"%d",&ival)){
|
||||
cprintf(RED,"Warning: cannot scan voltage value\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(i2c_write(ival)<0)
|
||||
strcpy(buffer,"fail ");
|
||||
else
|
||||
strcpy(buffer,"success ");
|
||||
cprintf(GREEN,"%s\n",buffer);
|
||||
n = write(fd, buffer, BUFFERSIZE);
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
ival = i2c_read();
|
||||
//ok/ fail
|
||||
if(ival < 0)
|
||||
strcpy(buffer,"fail ");
|
||||
else
|
||||
strcpy(buffer,"success ");
|
||||
n = write(fd, buffer, BUFFERSIZE);
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||
#endif
|
||||
//value
|
||||
if(ival >= 0){
|
||||
cprintf(GREEN,"%d\n",ival);
|
||||
sprintf(buffer,"%d ",ival);
|
||||
n = write(fd, buffer, BUFFERSIZE);
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||
#endif
|
||||
}else cprintf(GREEN,"%s\n",buffer);
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
printf("Exiting Program\n");
|
||||
ret = GOODBYE;
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Command. buffer:%s\n",buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
printf("Goodbye Serial Communication for HV(9M)\n");
|
||||
return 0;
|
||||
}
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "Beb.h"
|
||||
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
|
||||
struct BebInfo beb_infos[10];
|
||||
@ -46,6 +47,8 @@
|
||||
short Beb_bit_mode;
|
||||
int BEB_MMAP_SIZE = 0x1000;
|
||||
|
||||
int Beb_activated = 1;
|
||||
|
||||
|
||||
|
||||
void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num){
|
||||
@ -146,7 +149,7 @@ void Beb_Beb(){
|
||||
|
||||
|
||||
|
||||
void Beb_GetModuleCopnfiguration(int* master, int* top){
|
||||
void Beb_GetModuleConfiguration(int* master, int* top, int* normal){
|
||||
*top = 0;
|
||||
*master = 0;
|
||||
//mapping new memory to read master top module configuration
|
||||
@ -165,13 +168,144 @@ void Beb_GetModuleCopnfiguration(int* master, int* top){
|
||||
*top = 1;
|
||||
if(ret&MASTER_BIT_MASK)
|
||||
*master = 1;
|
||||
if(ret&NORMAL_MODULE_BIT_MASK)
|
||||
*normal = 1;
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Beb_EndofDataSend(int tengiga){
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
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_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_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_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_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;
|
||||
}
|
||||
|
||||
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_COUNTER_BASEADDR);
|
||||
if(fd < 0){
|
||||
cprintf(BG_RED,"Delay read counter fail\n");
|
||||
return;
|
||||
}else{
|
||||
//read data first time
|
||||
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_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"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n"
|
||||
"\nRight\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n\n",
|
||||
l_framepktLsbcounter,l_framepktMsbcounter,l_txndelaycounter,l_framedelaycounter,
|
||||
r_framepktLsbcounter,r_framepktMsbcounter,r_txndelaycounter,r_framedelaycounter);
|
||||
//#endif
|
||||
|
||||
//keep comparing with previous values
|
||||
int maxtimer;
|
||||
while(1){
|
||||
maxtimer = MAX(MAX(l_txndelaycounter,l_framedelaycounter),MAX(r_txndelaycounter,r_framedelaycounter));
|
||||
maxtimer /= 100;
|
||||
printf("Will wait for %d us\n",maxtimer);
|
||||
usleep(maxtimer);
|
||||
|
||||
//read new values
|
||||
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_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"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n"
|
||||
"\nRight\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n\n",
|
||||
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_framepktLsbcounter == l_framepktLsbcounter_new) &&
|
||||
(l_framepktMsbcounter == l_framepktMsbcounter_new) &&
|
||||
(r_framepktLsbcounter == r_framepktLsbcounter_new) &&
|
||||
(r_framepktMsbcounter == r_framepktMsbcounter_new))
|
||||
break;
|
||||
|
||||
//update old values
|
||||
l_framepktLsbcounter = l_framepktLsbcounter_new;
|
||||
l_framepktMsbcounter = l_framepktMsbcounter_new;
|
||||
l_txndelaycounter = l_txndelaycounter_new;
|
||||
l_framedelaycounter = l_framedelaycounter_new;
|
||||
r_framepktLsbcounter = r_framepktLsbcounter_new;
|
||||
r_framepktMsbcounter = r_framepktMsbcounter_new;
|
||||
r_txndelaycounter = r_txndelaycounter_new;
|
||||
r_framedelaycounter = r_framedelaycounter_new;
|
||||
|
||||
}
|
||||
|
||||
printf("Detector has send all data\n");
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* do not work at the moment */
|
||||
int Beb_SetMasterViaSoftware(){
|
||||
|
||||
if(!Beb_activated)
|
||||
return 0;
|
||||
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
u_int32_t value = 0, ret = 1;
|
||||
@ -200,6 +334,10 @@ int Beb_SetMasterViaSoftware(){
|
||||
|
||||
/* do not work at the moment */
|
||||
int Beb_SetSlaveViaSoftware(){
|
||||
|
||||
if(!Beb_activated)
|
||||
return 0;
|
||||
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
u_int32_t value = 0, ret = 1;
|
||||
@ -268,11 +406,18 @@ int Beb_Activate(int enable){
|
||||
if(fd > 0)
|
||||
Beb_close(fd,csp0base);
|
||||
|
||||
Beb_activated = ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int Beb_SetNetworkParameter(enum detNetworkParameter mode, int val){
|
||||
|
||||
if(!Beb_activated)
|
||||
return val;
|
||||
|
||||
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
u_int32_t valueread = 0;
|
||||
@ -325,6 +470,10 @@ int Beb_SetNetworkParameter(enum detNetworkParameter mode, int val){
|
||||
|
||||
|
||||
int Beb_ResetToHardwareSettings(){
|
||||
|
||||
if(!Beb_activated)
|
||||
return 1;
|
||||
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
u_int32_t value = 0, ret = 1;
|
||||
@ -396,6 +545,10 @@ u_int32_t Beb_GetFirmwareSoftwareAPIVersion(){
|
||||
}
|
||||
|
||||
void Beb_ResetFrameNumber(){
|
||||
|
||||
if(!Beb_activated)
|
||||
return;
|
||||
|
||||
//mapping new memory to read master top module configuration
|
||||
u_int32_t* csp0base=0;
|
||||
//open file pointer
|
||||
@ -446,7 +599,6 @@ int Beb_InitBebInfos(){//file name at some point
|
||||
bebInfoSize++;
|
||||
|
||||
|
||||
//if(!Beb_ReadSetUpFromFile("/home/root/executables/setup_beb.txt")) return 0;
|
||||
/*
|
||||
//loop through file to fill vector.
|
||||
BebInfo* b = new BebInfo(26);
|
||||
@ -477,52 +629,6 @@ int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac
|
||||
}
|
||||
|
||||
|
||||
int Beb_ReadSetUpFromFile(char* file_name){
|
||||
char line[100];
|
||||
char str[100];
|
||||
|
||||
int i0,i1;
|
||||
char mac0[50],mac1[50],ip0[50],ip1[0];
|
||||
FILE* fp = fopen(file_name, "r");
|
||||
if( fp == NULL ){
|
||||
perror("Error while opening the beb setup file.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Setting up beb side of detector:\n");
|
||||
while ( fgets (line , 255 , fp) != NULL ){
|
||||
if(strlen(line)<=1)
|
||||
continue;
|
||||
sscanf (line, "%s", str);
|
||||
if (str[0]=='#')
|
||||
continue;
|
||||
|
||||
if(!strcmp(str,"add_beb")){
|
||||
if( sscanf (line,"%s %d %d %s %s %s %s",str,&i0,&i1,mac0,ip0,mac1,ip1) < 7){
|
||||
printf("Error adding beb from %s.\n",file_name);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf ("Read: %s %d %d %s %s %s %s\n", str,i0,i1,mac0,ip0,mac1,ip1);
|
||||
|
||||
if(Beb_GetBebInfoIndex(i0)){
|
||||
printf("Error adding beb from %s, beb number %d already added.\n",file_name,i0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
struct BebInfo b0;
|
||||
BebInfo_BebInfo(&b0,i0);
|
||||
BebInfo_SetSerialAddress(&b0,i1);
|
||||
BebInfo_SetHeaderInfo(&b0,0,mac0,ip0,42000+i0);
|
||||
BebInfo_SetHeaderInfo(&b0,1,mac1,ip1,52000+i0);
|
||||
beb_infos[bebInfoSize] = b0;
|
||||
bebInfoSize++;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Beb_CheckSourceStuffBebInfo(){
|
||||
@ -552,6 +658,10 @@ unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb){
|
||||
|
||||
|
||||
int Beb_WriteTo(unsigned int index){
|
||||
|
||||
if(!Beb_activated)
|
||||
return 1;
|
||||
|
||||
if(index>=bebInfoSize){
|
||||
printf("WriteTo index error.\n");
|
||||
return 0;
|
||||
@ -575,35 +685,15 @@ void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d){
|
||||
|
||||
|
||||
int Beb_SetByteOrder(){
|
||||
/*
|
||||
Beb_send_data_raw[0] = 0x8fff0000;
|
||||
if(Local_Write(ll_beb,4,Beb_send_data_raw)!=4) return 0;
|
||||
|
||||
while((Local_Read(ll_beb,Beb_recv_buffer_size*4,Beb_recv_data_raw)/4)>0) printf("\t) Cleanning buffer ...\n");
|
||||
|
||||
if(bebInfoSize<2) return 0;
|
||||
|
||||
Beb_send_ndata = 3;
|
||||
Beb_send_data[0] = 0x000c0000;
|
||||
Beb_send_data[1] = 0;
|
||||
Beb_send_data[2] = 0;
|
||||
Beb_WriteTo(0);
|
||||
|
||||
//using little endian for data, big endian not fully tested, swap on 16 bit boundary.
|
||||
Beb_send_ndata = 3;
|
||||
Beb_send_data[0] = 0x000c0000;
|
||||
Beb_send_data[1] = 1;
|
||||
Beb_send_data[2] = 0;
|
||||
Beb_SwapDataFun(0,2,&(Beb_send_data[1]));
|
||||
Beb_WriteTo(0);
|
||||
|
||||
printf("\tSetting Byte Order .............. ok\n");
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, char* dst_mac, char* dst_ip, unsigned int dst_port){
|
||||
|
||||
if(!Beb_activated)
|
||||
return 1;
|
||||
|
||||
u_int32_t bram_phy_addr;
|
||||
u_int32_t* csp0base=0;
|
||||
/*u_int32_t* bram_ptr = NULL;*/
|
||||
@ -809,7 +899,9 @@ int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, i
|
||||
cprintf(GREEN, "Beb_send_data[1] Swapped:%X\n",Beb_send_data[1]);
|
||||
#endif
|
||||
|
||||
if(!Beb_WriteTo(i)) return 0;
|
||||
if(Beb_activated){
|
||||
if(!Beb_WriteTo(i)) return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -828,6 +920,9 @@ int Beb_SetUpTransferParameters(short the_bit_mode){
|
||||
|
||||
int Beb_StopAcquisition()
|
||||
{
|
||||
if(!Beb_activated)
|
||||
return 1;
|
||||
|
||||
u_int32_t* csp0base=0;
|
||||
volatile u_int32_t valuel,valuer;
|
||||
//open file pointer
|
||||
@ -854,6 +949,10 @@ int Beb_StopAcquisition()
|
||||
}
|
||||
|
||||
int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait){
|
||||
|
||||
if(!Beb_activated)
|
||||
return 1;
|
||||
|
||||
if(dst_number>64) return 0;
|
||||
|
||||
unsigned int header_size = 4; //4*64 bits
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -41,12 +41,13 @@ struct BebInfo{
|
||||
|
||||
void Beb_ClearBebInfos();
|
||||
int Beb_InitBebInfos();
|
||||
int Beb_ReadSetUpFromFile(char* file_name);
|
||||
int Beb_CheckSourceStuffBebInfo();
|
||||
unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb);
|
||||
|
||||
|
||||
void Beb_GetModuleCopnfiguration(int* master, int* top);
|
||||
void Beb_GetModuleConfiguration(int* master, int* top, int* normal);
|
||||
void Beb_EndofDataSend(int tengiga);
|
||||
|
||||
int Beb_SetMasterViaSoftware();
|
||||
int Beb_SetSlaveViaSoftware();
|
||||
int Beb_Activate(int enable);
|
||||
|
@ -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;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -64,6 +64,7 @@ int Module_GetBottomDACValue(struct Module* mod,unsigned int i);
|
||||
|
||||
|
||||
|
||||
void Feb_Control_activate(int activate);
|
||||
|
||||
int Feb_Control_IsBottomModule();
|
||||
int Feb_Control_GetModuleNumber();
|
||||
@ -83,7 +84,6 @@ int Feb_Control_GetModuleNumber();
|
||||
int Feb_Control_VoltageToDAC(float value, unsigned int* digital, unsigned int nsteps, float vmin, float vmax);
|
||||
float Feb_Control_DACToVoltage(unsigned int digital,unsigned int nsteps,float vmin,float vmax);
|
||||
|
||||
int Feb_Control_SendHighVoltage(unsigned int module_index, float* value);
|
||||
|
||||
int Feb_Control_SendIDelays(unsigned int dst_num, int chip_lr, unsigned int channels, unsigned int ndelay_units);
|
||||
|
||||
@ -111,17 +111,19 @@ int Feb_Control_GetModuleNumber();
|
||||
|
||||
|
||||
void Feb_Control_FebControl();
|
||||
int Feb_Control_Init(int master, int top, int module_num);
|
||||
int Feb_Control_ReadSetUpFileToAddModules(char* file_name);
|
||||
int Feb_Control_ReadSetUpFile(unsigned int module_num, char* file_name);
|
||||
int Feb_Control_Init(int master, int top, int normal, int module_num);
|
||||
int Feb_Control_OpenSerialCommunication();
|
||||
void Feb_Control_CloseSerialCommunication();
|
||||
int Feb_Control_CheckSetup();
|
||||
|
||||
unsigned int Feb_Control_GetNModules();
|
||||
unsigned int Feb_Control_GetNHalfModules();
|
||||
|
||||
int Feb_Control_SetHighVoltage(float value);
|
||||
int Feb_Control_SetHighVoltage1(unsigned int module_num,float value);
|
||||
int Feb_Control_SetHighVoltage(int value);
|
||||
int Feb_Control_GetHighVoltage(int* value);
|
||||
|
||||
int Feb_Control_SendHighVoltage(int dacvalue);
|
||||
int Feb_Control_ReceiveHighVoltage(unsigned int* value);
|
||||
|
||||
int Feb_Control_SetIDelays(unsigned int module_num, unsigned int ndelay_units);
|
||||
int Feb_Control_SetIDelays1(unsigned int module_num, unsigned int chip_pos, unsigned int ndelay_units);
|
||||
@ -159,6 +161,7 @@ int Feb_Control_GetModuleNumber();
|
||||
unsigned int Feb_Control_GetNExposures();
|
||||
int Feb_Control_SetExposureTime(double the_exposure_time_in_sec);
|
||||
double Feb_Control_GetExposureTime();
|
||||
int64_t Feb_Control_GetExposureTime_in_nsec();
|
||||
int Feb_Control_SetSubFrameExposureTime(int64_t the_subframe_exposure_time_in_10nsec);
|
||||
int64_t Feb_Control_GetSubFrameExposureTime();
|
||||
int Feb_Control_SetExposurePeriod(double the_exposure_period_in_sec);
|
||||
@ -185,7 +188,7 @@ int Feb_Control_GetModuleNumber();
|
||||
int Feb_Control_PulseChip(int npulses);
|
||||
|
||||
int64_t Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
int64_t Feb_Control_Get_RateTable_Subexptime_in_nsec();
|
||||
int64_t Feb_Control_Get_RateTable_Period_in_nsec();
|
||||
int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec);
|
||||
int Feb_Control_SetRateCorrectionTable(unsigned int *table);
|
||||
int Feb_Control_GetRateCorrectionVariable();
|
||||
@ -195,4 +198,4 @@ int Feb_Control_GetModuleNumber();
|
||||
int Feb_Control_GetLeftFPGATemp();
|
||||
int Feb_Control_GetRightFPGATemp();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,6 +95,7 @@
|
||||
#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
|
||||
@ -114,6 +115,8 @@
|
||||
//module configuration
|
||||
#define TOP_BIT_MASK 0x00f
|
||||
#define MASTER_BIT_MASK 0x200
|
||||
#define NORMAL_MODULE_BIT_MASK 0x400
|
||||
|
||||
// Master Slave Top Bottom Definition
|
||||
#define MODULE_CONFIGURATION_MASK 0x84
|
||||
//Software Configuration
|
||||
@ -151,3 +154,47 @@
|
||||
|
||||
//temp so far
|
||||
#define FEB_REG_STATUS 0xa
|
||||
|
||||
//1g counters
|
||||
#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_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_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_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,6 +1,6 @@
|
||||
CC = powerpc-4xx-softfloat-gcc
|
||||
CCX = powerpc-4xx-softfloat-g++
|
||||
CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSE #-DVIRTUAL -DPCCOMPILE -DMARTIN
|
||||
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++
|
||||
|
||||
PROGS = eigerDetectorServer
|
||||
@ -9,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) #feb_debug beb_debug
|
||||
all: clean $(PROGS) #hv9m_blackfin_server
|
||||
|
||||
|
||||
boot: $(OBJS)
|
||||
@ -26,14 +23,12 @@ $(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)
|
||||
rm hv9m_blackfin_server.gdb
|
||||
|
||||
clean:
|
||||
rm -rf $(DESTDIR)/$(PROGS) *.o
|
||||
rm -rf $(DESTDIR)/$(PROGS) *.o $(DESTDIR)/hv9m_blackfin_server
|
||||
|
||||
|
@ -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.
BIN
slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv2.3.4.16.0
Executable file
BIN
slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv2.3.4.16.0
Executable file
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: 372aa91aaff8c6acd0fb70a257774ac56974a4b1
|
||||
Revision: 233
|
||||
Branch: 2.1-rc
|
||||
Repsitory UUID: 3618c87c5cd000fff7799ddd8cd07a4162d9fdec
|
||||
Revision: 276
|
||||
Branch: 2.3
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 22
|
||||
Last Changed Date: 2016-09-22 17:16:49 +0200
|
||||
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 "372aa91aaff8c6acd0fb70a257774ac56974a4b1"
|
||||
//#define SVNREV 0x22
|
||||
#define SVNREPUUID "3618c87c5cd000fff7799ddd8cd07a4162d9fdec"
|
||||
//#define SVNREV 0x1340
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "Dhanya_Maliakal"
|
||||
#define SVNREV 0x22
|
||||
#define SVNDATE 0x20160922
|
||||
#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;
|
||||
@ -78,6 +76,7 @@ int default_offset_values[3] = {3851000,3851000,3851000};
|
||||
enum masterFlags masterMode=IS_SLAVE;
|
||||
int top = 0;
|
||||
int master = 0;
|
||||
int normal = 0;
|
||||
|
||||
|
||||
#define TEN_GIGA_BUFFER_SIZE 4112
|
||||
@ -100,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;
|
||||
@ -124,25 +119,20 @@ 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();
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
Feb_Control_Init(master,top,getDetectorNumber());
|
||||
Feb_Control_Init(master,top,normal, getDetectorNumber());
|
||||
//master of 9M, check high voltage serial communication to blackfin
|
||||
if(master && !normal){
|
||||
if(Feb_Control_OpenSerialCommunication())
|
||||
;// Feb_Control_CloseSerialCommunication();
|
||||
}
|
||||
printf("FEB Initialization done\n");
|
||||
Beb_Beb();
|
||||
printf("BEB Initialization done\n");
|
||||
@ -161,7 +151,6 @@ int initDetector(){
|
||||
eiger_photonenergy = -1;
|
||||
setReadOutFlags(NONPARALLEL);
|
||||
setSpeed(0,1);//clk_devider,half speed
|
||||
setHighVoltage(0,0);
|
||||
setIODelay(650,0);
|
||||
setTiming(AUTO_TIMING);
|
||||
//SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
|
||||
@ -169,6 +158,7 @@ int initDetector(){
|
||||
int enable[2] = {0,1};
|
||||
setExternalGating(enable);//disable external gating
|
||||
Feb_Control_SetInTestModeVariable(0);
|
||||
setHighVoltage(0,0);
|
||||
Feb_Control_CheckSetup();
|
||||
|
||||
//print detector mac and ip
|
||||
@ -184,7 +174,7 @@ int initDetectorStop(){
|
||||
getModuleConfiguration();
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
Feb_Control_Init(master,top,getDetectorNumber());
|
||||
Feb_Control_Init(master,top,normal,getDetectorNumber());
|
||||
printf("FEB Initialization done\n");
|
||||
/* Beb_Beb(-1);
|
||||
printf("BEB constructor done\n");*/
|
||||
@ -198,15 +188,18 @@ int initDetectorStop(){
|
||||
void getModuleConfiguration(){
|
||||
int *m=&master;
|
||||
int *t=⊤
|
||||
int *n=&normal;
|
||||
/*if(getDetectorNumber() == 0xbeb015){
|
||||
master = 1;
|
||||
top = 1;
|
||||
}*/
|
||||
Beb_GetModuleCopnfiguration(m,t);
|
||||
Beb_GetModuleConfiguration(m,t,n);
|
||||
if(top) printf("*************** TOP ***************\n");
|
||||
else printf("*************** BOTTOM ***************\n");
|
||||
if(master) printf("*************** MASTER ***************\n");
|
||||
else printf("*************** SLAVE ***************\n");
|
||||
if(normal) printf("*************** NORMAL ***************\n");
|
||||
else printf("*************** SPECIAL ***************\n");
|
||||
}
|
||||
|
||||
|
||||
@ -428,13 +421,22 @@ void setDAC(enum detDacIndex ind, int val, int imod, int mV, int retval[]){
|
||||
}
|
||||
|
||||
|
||||
|
||||
int setHighVoltage(int val, int imod){
|
||||
if(val!=-1){
|
||||
printf(" Setting High Voltage: %d\n",val);
|
||||
if(!master)
|
||||
eiger_highvoltage = val;
|
||||
else if(Feb_Control_SetHighVoltage(val))
|
||||
eiger_highvoltage = val;
|
||||
eiger_highvoltage = val;
|
||||
if(master){
|
||||
int ret = Feb_Control_SetHighVoltage(val);
|
||||
if(!ret) //could not set
|
||||
return -2;
|
||||
else if (ret == -1) //outside range
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(master && !Feb_Control_GetHighVoltage(&eiger_highvoltage)){
|
||||
cprintf(RED,"Warning: Could not read high voltage\n");
|
||||
return -3;
|
||||
}
|
||||
return eiger_highvoltage;
|
||||
}
|
||||
@ -539,12 +541,29 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec){//in nanosec (will never b
|
||||
return 0;
|
||||
}
|
||||
|
||||
//when dynamic range changes, use old tau
|
||||
else if(custom_tau_in_nsec == -1)
|
||||
custom_tau_in_nsec = Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
|
||||
|
||||
int dr = Feb_Control_GetDynamicRange();
|
||||
//get period = subexptime if 32bit , else period = exptime if 16 bit
|
||||
int64_t actual_period = Feb_Control_GetSubFrameExposureTime(); //already in nsec
|
||||
if(dr == 16)
|
||||
actual_period = Feb_Control_GetExposureTime_in_nsec();
|
||||
|
||||
int64_t ratetable_period_in_nsec = Feb_Control_Get_RateTable_Period_in_nsec();
|
||||
int64_t tau_in_nsec = Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
int64_t subexp_in_nsec = Feb_Control_Get_RateTable_Subexptime_in_nsec();
|
||||
|
||||
|
||||
//same setting
|
||||
if((tau_in_nsec == custom_tau_in_nsec) && (subexp_in_nsec == Feb_Control_GetSubFrameExposureTime())){
|
||||
if((tau_in_nsec == custom_tau_in_nsec) && (ratetable_period_in_nsec == actual_period)){
|
||||
if(dr == 32)
|
||||
printf("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n",
|
||||
tau_in_nsec,subexp_in_nsec);
|
||||
tau_in_nsec,ratetable_period_in_nsec);
|
||||
else
|
||||
printf("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n",
|
||||
tau_in_nsec,ratetable_period_in_nsec);
|
||||
}
|
||||
//different setting, calculate table
|
||||
else{
|
||||
@ -582,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;
|
||||
|
||||
@ -592,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;
|
||||
}
|
||||
|
||||
@ -622,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();
|
||||
@ -701,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);
|
||||
}
|
||||
|
||||
@ -741,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;
|
||||
}
|
||||
|
||||
@ -841,25 +815,27 @@ enum runStatus getRunStatus(){
|
||||
|
||||
|
||||
|
||||
char *readFrame(int *ret, char *mess){
|
||||
//if(master){
|
||||
if(!Feb_Control_WaitForFinishedFlag(5000))
|
||||
cprintf(RED,"Error: Waiting for finished flag\n");
|
||||
cprintf(GREEN,"Acquisition finished***\n");
|
||||
void readFrame(int *ret, char *mess){
|
||||
if(!Feb_Control_WaitForFinishedFlag(5000))
|
||||
cprintf(RED,"Error: Waiting for finished flag\n");
|
||||
cprintf(GREEN,"Acquisition finished***\n");
|
||||
|
||||
if(eiger_storeinmem){
|
||||
printf("requesting images after storing in memory\n");
|
||||
if(startReadOut() == FAIL){
|
||||
cprintf(RED, "Could not read out images\n");
|
||||
*ret = (int)FAIL;
|
||||
return NULL;
|
||||
}
|
||||
if(eiger_storeinmem){
|
||||
printf("requesting images after storing in memory\n");
|
||||
if(startReadOut() == FAIL){
|
||||
strcpy(mess,"Could not execute read image requests\n");
|
||||
*ret = (int)FAIL;
|
||||
return;
|
||||
}
|
||||
//usleep(1000000);
|
||||
printf("*****Done Waiting...\n");
|
||||
//}
|
||||
*ret = (int)FINISHED;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//wait for detector to send
|
||||
Beb_EndofDataSend(send_to_ten_gig);
|
||||
|
||||
|
||||
printf("*****Done Waiting...\n");
|
||||
*ret = (int)FINISHED;
|
||||
strcpy(mess,"acquisition successfully finished\n");
|
||||
}
|
||||
|
||||
|
||||
@ -1093,6 +1069,8 @@ int configureMAC(int ipad, long long int macad, long long int detectormacadd, in
|
||||
int beb_num = BEB_NUM;//Feb_Control_GetModuleNumber();
|
||||
int header_number = 0;
|
||||
int dst_port = udpport;
|
||||
if(!top)
|
||||
dst_port = udpport2;
|
||||
|
||||
printf("dst_port:%d\n\n",dst_port);
|
||||
|
||||
@ -1106,6 +1084,8 @@ int configureMAC(int ipad, long long int macad, long long int detectormacadd, in
|
||||
|
||||
header_number = 32;
|
||||
dst_port = udpport2;
|
||||
if(!top)
|
||||
dst_port = udpport;
|
||||
printf("dst_port:%d\n\n",dst_port);
|
||||
|
||||
/*for(i=0;i<32;i++){*//** modified for Aldo*/
|
||||
@ -1151,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;
|
||||
}
|
||||
@ -1189,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);
|
||||
@ -1294,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
|
||||
@ -1305,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(){
|
||||
@ -1318,7 +1311,9 @@ int getBebFPGATemp(){
|
||||
|
||||
|
||||
int activate(int enable){
|
||||
return Beb_Activate(enable);
|
||||
int ret = Beb_Activate(enable);
|
||||
Feb_Control_activate(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#define FEB_PORT 43210
|
||||
#define BEB_PORT 43212
|
||||
|
||||
#define REQUIRED_FIRMWARE_VERSION 14
|
||||
#define REQUIRED_FIRMWARE_VERSION 16
|
||||
|
||||
#define FIRMWAREREV 0xcaba //temporary should be in firmware
|
||||
|
||||
@ -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
|
||||
@ -44,5 +44,11 @@ enum detAdcIndex{TEMP_FPGAEXT, TEMP_10GE, TEMP_DCDC, TEMP_SODL, TEMP_SODR, TEMP_
|
||||
|
||||
enum detNetworkParameter{TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};
|
||||
|
||||
#define NORMAL_HIGHVOLTAGE_INPUTPORT "/sys/class/hwmon/hwmon5/device/in0_input"
|
||||
#define NORMAL_HIGHVOLTAGE_OUTPUTPORT "/sys/class/hwmon/hwmon5/device/out0_output"
|
||||
#define SPECIAL9M_HIGHVOLTAGE_PORT "/dev/ttyS1"
|
||||
#define SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE 16
|
||||
|
||||
|
||||
|
||||
#endif /* SLSDETECTORSERVER_DEFS_H_ */
|
||||
|
@ -61,6 +61,12 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
|
||||
#define XPAR_PLB_GPIO_TEST_HIGHADDR 0xD101FFFF
|
||||
|
||||
|
||||
|
||||
/* Definitions for packet, frame and delay down counters */
|
||||
#define XPAR_COUNTER_BASEADDR 0xD1020000
|
||||
#define XPAR_COUNTER_HIGHADDR 0xD102FFFF
|
||||
|
||||
|
||||
/* Definitions for peripheral PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT */
|
||||
#define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR 0xC4100000
|
||||
#define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_HIGHADDR 0xC410FFFF
|
||||
|
@ -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: 372aa91aaff8c6acd0fb70a257774ac56974a4b1
|
||||
Revision: 1154
|
||||
Branch: 2.1-rc
|
||||
Repsitory UUID: 41acb4c1ab89fe85b049c329adb539c3ad5b107a
|
||||
Revision: 1350
|
||||
Branch: 2.3.2
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 1154
|
||||
Last Changed Date: 2016-09-22 17:16:49 +0200
|
||||
Last Changed Rev: 1350
|
||||
Last Changed Date: 2017-04-19 10:17:30 +0200
|
||||
|
@ -1212,6 +1212,7 @@ int64_t set64BitReg(int64_t value, int aLSB, int aMSB){
|
||||
v64=value>> 32;
|
||||
vMSB=v64&(0xffffffff);
|
||||
bus_w(aMSB,vMSB);
|
||||
printf("Wreg64(%x,%x) %08x %08x %016llx\n", aLSB>>11, aMSB>>11, vLSB, vMSB, value);
|
||||
}
|
||||
return get64BitReg(aLSB, aMSB);
|
||||
|
||||
@ -1295,6 +1296,7 @@ int64_t getDelay(){
|
||||
}
|
||||
|
||||
int64_t setTrains(int64_t value){
|
||||
printf("Set cycles %lld\n",value);
|
||||
return set64BitReg(value, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||
}
|
||||
|
||||
@ -2075,12 +2077,21 @@ u_int16_t* fifo_read_event(int ns)
|
||||
/* dma_memcpy(now_ptr,values ,dataBytes); */
|
||||
/* #else */
|
||||
|
||||
a = bus_r(LOOK_AT_ME_REG);
|
||||
a = bus_r(LOOK_AT_ME_REG);
|
||||
//#ifdef VERBOSE
|
||||
printf("%08x\n",a);
|
||||
// printf("%d %08x\n",ns,a);
|
||||
bus_w16(DUMMY_REG,1<<8); // read strobe to all fifos
|
||||
bus_w16(DUMMY_REG,0);
|
||||
// i=0;//
|
||||
|
||||
bus_w16(DUMMY_REG,0);
|
||||
|
||||
/* for (i=0; i<32; i++) { */
|
||||
/* bus_w16(DUMMY_REG,i); */
|
||||
/* printf("%04x ",bus_r16(FIFO_STATUS_REG)); */
|
||||
/* // a = bus_r(LOOK_AT_ME_REG); */
|
||||
/* // printf("%d %08x\n",i,a); */
|
||||
/* } */
|
||||
/* printf("\n"); */
|
||||
// i=0;//
|
||||
/* for (i=0; i<32; i++) { */
|
||||
|
||||
/* /\* while (((adcDisableMask&(3<<((i)*2)))>>((i)*2))==3) { *\/ */
|
||||
@ -2110,13 +2121,13 @@ u_int16_t* fifo_read_event(int ns)
|
||||
*((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);//*values;//bus_r(FIFO_DATA_REG);
|
||||
|
||||
|
||||
if (i!=0 || ns!=0) {
|
||||
if (i!=0 || ns!=0) {
|
||||
a=0;
|
||||
while (*((u_int16_t*)now_ptr)==*((u_int16_t*)(now_ptr)-1) && a++<10) {
|
||||
|
||||
// printf("******************** %d: fifo %d: new %08x old %08x\n ",ns, i, *((u_int32_t*)now_ptr),*((u_int32_t*)(now_ptr)-1));
|
||||
*((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);//*values;
|
||||
// printf("%d-",i);
|
||||
// printf("******************** %d: fifo %d: new %08x old %08x\n ",ns, i, *((u_int32_t*)now_ptr),*((u_int32_t*)(now_ptr)-1));
|
||||
*((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);//*values;
|
||||
// printf("%d-",i);
|
||||
|
||||
}
|
||||
}
|
||||
@ -2130,9 +2141,9 @@ u_int16_t* fifo_read_event(int ns)
|
||||
|
||||
bus_w16(DUMMY_REG,i+1);
|
||||
|
||||
a = bus_r(LOOK_AT_ME_REG);
|
||||
// a = bus_r(LOOK_AT_ME_REG);
|
||||
// printf("%d %08x\n",i,a);
|
||||
//#ifdef VERBOSE
|
||||
printf("%d %08x\n",i,a);
|
||||
// }
|
||||
// *(((u_int16_t*)(now_ptr))+i)=bus_r16(FIFO_DATA_REG);
|
||||
}
|
||||
@ -2449,6 +2460,95 @@ int writeADC(int addr, int val) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int prepareSlowADC() {
|
||||
|
||||
|
||||
|
||||
u_int16_t vv;
|
||||
u_int16_t codata;
|
||||
|
||||
u_int32_t valw;
|
||||
int i, j;
|
||||
|
||||
int cnv_bit=16, sdi_bit=17, sck_bit=18;
|
||||
|
||||
for (j=0; j<2; j++) {
|
||||
|
||||
|
||||
valw=(1<<cnv_bit) | (1<<sdi_bit);
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
|
||||
usleep(20);
|
||||
|
||||
valw=(1<<sdi_bit);
|
||||
bus_w(ADC_WRITE_REG,(valw));
|
||||
|
||||
|
||||
|
||||
|
||||
for (i=0;i<16;i++) {
|
||||
//cldwn
|
||||
valw=0;
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
// usleep(0);
|
||||
bus_w(ADC_WRITE_REG,valw|(1<<sck_bit));
|
||||
// usleep(0);
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int readSlowADC(int ichan) {
|
||||
|
||||
|
||||
u_int16_t vv=0x3c40;
|
||||
u_int16_t codata=vv | (ichan<<7);
|
||||
|
||||
u_int32_t valw;
|
||||
int i, obit;
|
||||
|
||||
int cnv_bit=16, sdi_bit=17, sck_bit=18;
|
||||
|
||||
|
||||
|
||||
|
||||
for (ichan=0; ichan<8; ichan++) {
|
||||
|
||||
//convert
|
||||
valw=(1<<cnv_bit);
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
|
||||
usleep(20);
|
||||
|
||||
valw=(1<<sdi_bit);
|
||||
bus_w(ADC_WRITE_REG,(valw));
|
||||
|
||||
|
||||
printf("Channel %d ",ichan);
|
||||
//read
|
||||
for (i=0;i<16;i++) {
|
||||
//cldwn
|
||||
valw=0;
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
// usleep(0);
|
||||
bus_w(ADC_WRITE_REG,valw|(1<<sck_bit));
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
|
||||
obit=bus_r16(SLOW_ADC_REG)&0x1;
|
||||
printf("%d",obit);
|
||||
//write data (i)
|
||||
// usleep(0);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int prepareADC(){
|
||||
@ -3401,8 +3501,8 @@ int setPower(int ind, int val) {
|
||||
|
||||
if (pwrindex>=0) {
|
||||
if (bus_r(POWER_ON_REG)&(1<<(16+pwrindex))){
|
||||
retval1=vmax-(retval*1900)/4095;
|
||||
vmax=2700-(getDacRegister(19)*1000)/4095-200;
|
||||
vmax=2700-(getDacRegister(19)*1000)/4095-200;
|
||||
retval1=vmax-(retval*(vmax-vmin))/4095;
|
||||
if (retval1>vmax)
|
||||
retval1=vmax;
|
||||
if (retval1<vmin)
|
||||
|
@ -156,6 +156,7 @@ int allocateRAM();
|
||||
|
||||
int writeADC(int addr, int val);
|
||||
int prepareADC();
|
||||
int prepareSlowADC();
|
||||
|
||||
|
||||
int clearRAM();
|
||||
|
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user