Compare commits

..

563 Commits

Author SHA1 Message Date
6c95bf171b Merge branch 'test' into developer 2020-06-05 09:07:42 +02:00
fd948f1a00 updated binaries 2020-06-05 09:06:49 +02:00
ff9811895f WIP 2020-06-05 09:04:32 +02:00
7f6d57d6ba WIP 2020-06-04 17:42:24 +02:00
099805ba8b WIP 2020-06-04 17:02:56 +02:00
1e2a3f2767 WIP 2020-06-04 15:21:53 +02:00
9a8300ca08 WIP 2020-06-04 12:12:40 +02:00
40257fc82d Adds the stripDetector daemon 2020-06-04 11:50:33 +02:00
3bdc8e95ce WIP 2020-06-03 16:10:47 +02:00
223e24f924 WIP 2020-06-03 14:56:24 +02:00
4053594c4d WIP 2020-06-03 14:40:51 +02:00
f07e722d26 read/write reg moved to stop server, tests 2020-06-02 11:56:50 +02:00
2ef8f2f046 WIP 2020-05-29 19:36:41 +02:00
0e514a470d gotthard2 config example 2020-05-29 17:04:54 +02:00
294612b03c WIP 2020-05-29 17:04:10 +02:00
f223415f94 fix for testing 2020-05-29 16:26:57 +02:00
c6ff50d753 merge vetoheader 2020-05-29 10:50:33 +02:00
f0a318777c mythen3 bnaries in 2020-05-28 13:11:32 +02:00
8aa7144252 mythen3: fix of external signals to not allow master output inversion, but can edge detect not configurable, and default dout pulse length 2020-05-28 13:09:09 +02:00
15eea51f12 gotthard2 new firmware veto header reduced to 16 (frames, bunchid) 2020-05-28 12:44:03 +02:00
e884836f5c Merge branch 'vetoheader' of github.com:slsdetectorgroup/slsDetectorPackage into vetoheader 2020-05-28 11:33:59 +02:00
104d91e8c6 more jf stuff 2020-05-28 11:33:52 +02:00
9ddebc4c09 binaries in 2020-05-28 10:36:17 +02:00
0525e374b2 settign veto also configures mac, sending veto data for 10gb only if veto and numinterfaces==2, changed veto entry offset 2020-05-28 10:35:48 +02:00
e727b97d75 gottahrd2 binary in 2020-05-28 09:46:12 +02:00
5ca987ecbb Merge branch 'vetoheader' of github.com:slsdetectorgroup/slsDetectorPackage into vetoheader 2020-05-28 09:44:32 +02:00
2a64a9f6e0 gotthard2: removed check for module attached when setting veto, for later 2020-05-28 09:44:25 +02:00
a708da5455 Merge branch 'vetoheader' of github.com:slsdetectorgroup/slsDetectorPackage into vetoheader 2020-05-28 09:29:02 +02:00
e2eb1598d3 jf stuff 2020-05-28 09:28:53 +02:00
d175ba0936 check for module attached only when enabling veto streaming, not disabling 2020-05-28 09:21:19 +02:00
6189fd157a gotthard2: cehck if module attached when setting veto to 1 2020-05-28 09:19:55 +02:00
6c753f3b50 veto 2020-05-28 08:48:11 +02:00
098d3e6d98 gotthard2: binaries in 2020-05-27 14:39:28 +02:00
4300e95a8e virtual, adding veto command 2020-05-27 14:37:52 +02:00
46daa7e2de merge from developer (mythen3 branch) 2020-05-27 14:19:33 +02:00
754536898a Merge pull request #100 from slsdetectorgroup/mythen3
Mythen3
2020-05-27 14:12:52 +02:00
20bfe92573 gatedelay 2020-05-27 14:02:33 +02:00
9493ae3da9 WIP 2020-05-27 11:30:47 +02:00
0fca9fba79 Merge branch 'mythen3' of github.com:slsdetectorgroup/slsDetectorPackage into mythen3 2020-05-27 11:30:23 +02:00
b543708d9d exptime 2020-05-27 11:30:11 +02:00
e0ea08332f gotthard2: fix in rxr for gotthard2 2020-05-26 17:44:31 +02:00
e229fee6ba gotthard2: hv soft max uptdated to 500v 2020-05-26 14:59:48 +02:00
44a88893ba mythen3: hv soft max uptdated to 500v 2020-05-26 14:58:41 +02:00
f4ba46c19b update function and enum generation 2020-05-26 11:26:24 +02:00
37cb0bb1c0 minor PR fixes 2020-05-26 08:57:48 +02:00
f293ba8c56 gui cmake fix 2020-05-26 08:50:09 +02:00
e9ca17f860 Merge branch 'vetoheader' of github.com:slsdetectorgroup/slsDetectorPackage into vetoheader 2020-05-25 14:23:45 +02:00
30391a2faf veto header size in server using sizeof 2020-05-25 14:23:10 +02:00
7ba877446c gotthard2 binary 2020-05-25 12:21:44 +02:00
6bdc506a34 veto header smaller size 2020-05-25 12:20:40 +02:00
9592d1760f gui fix 2020-05-25 11:09:26 +02:00
8ffb27c300 WIP 2020-05-25 11:05:51 +02:00
0a66605111 tests mainly and minor print 2020-05-22 15:23:56 +02:00
02d8b1fb5f mythen3 binary 2020-05-20 17:30:40 +02:00
457f31ed61 mythen3 server minor print fix 2020-05-20 17:30:07 +02:00
be3f095b56 gui minor fix 2020-05-20 17:27:22 +02:00
174bb32744 gui minor fix 2020-05-20 17:26:57 +02:00
07d90d127f gui fix 2020-05-20 17:25:39 +02:00
0debd6a457 mythen3: auto mode does not ignore #triggers 2020-05-20 17:12:45 +02:00
8f0ef68029 binaries in 2020-05-20 17:07:41 +02:00
d71e40729a external signals 2020-05-20 17:05:42 +02:00
9475e01062 gui done 2020-05-20 12:41:14 +02:00
dc8f67cd7b gui fix 2020-05-20 12:04:48 +02:00
3ebb1fca02 gui WIP 2020-05-20 11:51:18 +02:00
8973ef1aaa from timetest merge 2020-05-20 10:18:51 +02:00
5690914048 Merge branch 'mythen3' of github.com:slsdetectorgroup/slsDetectorPackage into mythen3 2020-05-20 10:15:04 +02:00
fa768e584e rxr 2020-05-20 10:14:57 +02:00
62e69b900b Merge pull request #99 from slsdetectorgroup/timetest
directly writing exptime
2020-05-20 09:56:34 +02:00
30fc346e22 directly writing exptime 2020-05-20 09:47:41 +02:00
761f93d753 exptime of gates 2020-05-20 09:36:43 +02:00
6d71d6cf9f fix with virtual server 2020-05-19 19:11:05 +02:00
e208d3ebe8 WIP 2020-05-19 18:59:07 +02:00
cd90f09a30 WIP 2020-05-19 18:24:32 +02:00
4570ffc8ad Merge branch 'mythen3' of github.com:slsdetectorgroup/slsDetectorPackage into mythen3 2020-05-18 14:36:17 +02:00
a7ce30391c register defs from pattern control to flow control 2020-05-18 14:35:59 +02:00
c33c479ada removed funcs from install 2020-05-18 14:18:12 +02:00
c8eda1a458 mythen binary up 2020-05-15 17:07:27 +02:00
ecc692ad9a start pattern without binaries 2020-05-15 17:06:08 +02:00
00c1211c56 unformatting regdefs 2020-05-15 16:14:57 +02:00
599625e6ed server binaries up 2020-05-15 15:49:59 +02:00
3514b14bc9 servers: removing notification file as this will be done by daemon 2020-05-15 15:48:52 +02:00
395b9f1b72 reordering one function, minor 2020-05-15 13:08:59 +02:00
26dfccf77e binaries compiling, removed inline for c 2020-05-15 13:03:50 +02:00
50d2d21018 fix for virtual servers for rhel7 2020-05-15 12:44:44 +02:00
2c83abcac7 merged detFuncs for c and c++ 2020-05-15 12:24:06 +02:00
ea7cc9db8c less public headers 2020-05-15 10:52:23 +02:00
0dd5a099c8 renamed FixedCap.. to StaticVector 2020-05-15 09:03:23 +02:00
e6deccc2c6 Merge pull request #98 from slsdetectorgroup/gotthard2
Gotthard2
2020-05-14 11:54:09 +02:00
ad42a61bae Merge branch 'developer' into gotthard2 2020-05-14 11:53:59 +02:00
cbc2856c1c rxr should print ip, mac, when set from structure 2020-05-13 18:35:46 +02:00
e34fbb4350 binaries in 2020-05-13 17:55:08 +02:00
eea67014b7 gotthard2 with veto data on second interface 2020-05-13 17:50:18 +02:00
3962714b48 format + exception.cpp 2020-05-13 14:48:52 +02:00
f0f97f265a removed non used slsDetectorUsers 2020-05-13 14:05:05 +02:00
e730c124e3 Merge pull request #97 from slsdetectorgroup/eiger26
Eiger26
2020-05-13 10:47:53 +02:00
f51c4e1d7c c99 2020-05-13 09:41:41 +02:00
a62b650e24 eiger binary in 2020-05-13 09:25:58 +02:00
af4b5bbf50 Pr fix 2020-05-13 09:22:40 +02:00
d8ca9bb6b5 eiger virtual server fix 2020-05-12 13:49:08 +02:00
9a1fdc4104 Merge branch 'developer' into eiger26 2020-05-12 13:43:36 +02:00
b3ebce378d Merge pull request #96 from slsdetectorgroup/rxthrow
More receiver functions throws
2020-05-12 13:42:43 +02:00
46afcfe694 removed logging 2020-05-12 11:49:49 +02:00
d7563fdd1a Merge branch 'developer' into eiger26 2020-05-12 11:39:29 +02:00
ccf1889113 formatting 2020-05-11 20:09:45 +02:00
88f801061f fix for reset 2020-05-11 20:09:09 +02:00
e3d3c88d74 update format 2020-05-11 19:53:50 +02:00
80f4f115f9 updated bianries 2020-05-11 19:53:00 +02:00
9a7d15bbf6 WIP 2020-05-11 19:36:12 +02:00
e148a584df formatting 2020-05-11 19:27:49 +02:00
5aaefc8e00 fix using real detectors, moving readconfig to end (due to initialization) 2020-05-11 19:26:22 +02:00
ed8d606eb2 WIP 2020-05-11 19:19:49 +02:00
eff664e790 cleanup 2020-05-11 18:28:06 +02:00
1ed1b5da86 migrate to return values 2020-05-11 12:15:16 +02:00
353b8d0057 migrate to return values 2020-05-11 11:48:18 +02:00
bbe9108fb9 migrate to return values 2020-05-11 11:39:11 +02:00
1998f9541e reorder read settings func 2020-05-11 10:30:55 +02:00
6620027439 reset to hardware evn if no file 2020-05-08 18:14:59 +02:00
30078d6c1f eiger: deactivate at startup, hostname activates, config file for top or master, if none, reset to hardware, no binaries 2020-05-08 18:11:15 +02:00
13c1f7c2d6 WIP 2020-05-08 16:31:26 +02:00
28bafb012a fixed test for new default values 2020-05-08 15:09:12 +02:00
9c7ff84b73 compiled all servers again 2020-05-08 13:57:23 +02:00
ab5cad4fde formatted servers 2020-05-08 13:56:47 +02:00
dac9998161 updated all servers 2020-05-08 13:42:07 +02:00
1dfac6ae6a Merge pull request #95 from slsdetectorgroup/trim
Trim
2020-05-08 13:39:42 +02:00
2e75f36fa0 pr fixes 2020-05-08 12:24:12 +02:00
c1902c713d mythne3 binary 2020-05-08 11:16:10 +02:00
61f5564bb7 Merge branch 'trim' of github.com:slsdetectorgroup/slsDetectorPackage into trim 2020-05-08 11:15:34 +02:00
ec2f7db729 mythen3: settings file of dac -1 fix 2020-05-08 11:15:27 +02:00
676055837f mythen3: binaries for 1 chip fix 2020-05-08 11:04:47 +02:00
cce028b825 Merge branch 'trim' of github.com:slsdetectorgroup/slsDetectorPackage into trim 2020-05-08 11:04:13 +02:00
d468641138 fix 2020-05-08 11:04:04 +02:00
01d1c86403 mythen3 trim one chip fix 2020-05-08 11:03:00 +02:00
2ac7451a99 eiger server 2020-05-08 10:53:34 +02:00
15b57b29fb all binaries except eiger 2020-05-08 10:18:54 +02:00
902616a09d Merge branch 'trim' of github.com:slsdetectorgroup/slsDetectorPackage into trim 2020-05-08 10:18:38 +02:00
eb3971fedc all binaries except eiger 2020-05-08 10:18:29 +02:00
64f0aa98ab Merge branch 'trim' of github.com:slsdetectorgroup/slsDetectorPackage into trim 2020-05-08 10:17:43 +02:00
61b86962bd no binaries yet, malloc need no casting 2020-05-08 10:17:36 +02:00
0e5a96e1ed binaries mythen3, gotthard2 2020-05-08 09:42:29 +02:00
2f11dbc2c9 nios, for variable delcaration in loop 2020-05-08 09:39:36 +02:00
9b21f44d94 binary 2020-05-07 17:41:56 +02:00
e56b431dc3 trim crash fix 2020-05-07 17:41:23 +02:00
1741c84406 binary 2020-05-07 17:22:43 +02:00
1623448086 minor 2020-05-07 17:14:51 +02:00
1a39f92f8f binary 2020-05-07 17:14:20 +02:00
4ea1f2c7e3 Merge branch 'trim' of github.com:slsdetectorgroup/slsDetectorPackage into trim 2020-05-07 17:07:56 +02:00
66d30cb2f1 remove printouts during trimming 2020-05-07 17:07:44 +02:00
8f021fe4ac binaries 2020-05-07 16:48:27 +02:00
7f42f5cadb trim change mythen3 2020-05-07 16:40:09 +02:00
999c548aa1 mythen3: trim: removing printout while tirmming 2020-05-07 16:36:09 +02:00
6872f24037 mythen3: binary 2020-05-07 16:07:24 +02:00
1a75170eed mythen3: set trimbits (not settings, threshold yet), set all trimbits 2020-05-07 16:04:30 +02:00
a12d47da36 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-05-06 12:02:54 +02:00
c16411ba00 new regex for version 2020-05-06 12:02:42 +02:00
379b9b53b4 fixed still one index in cluster finder 2020-05-06 12:02:22 +02:00
d76f43f5fd Fixed problem in cluster finder 2020-05-06 11:59:49 +02:00
7d94ad51ab format slsdetectorservers .c 2020-05-05 15:30:44 +02:00
671cf45fd7 format slsdetectorservers 2020-05-05 15:23:11 +02:00
31ec3c8cf7 check for clang-format version 2020-05-05 10:37:17 +02:00
8ff9b0cdac format GUI 2020-05-05 10:12:05 +02:00
ea4044e4b1 format support lib 2020-05-05 10:07:19 +02:00
e599bb7c24 format receiver 2020-05-05 10:04:52 +02:00
3618f6e5d3 removed obsolete tests 2020-05-05 09:20:05 +02:00
959fd562d3 clang-format 2020-05-04 16:30:00 +02:00
32662baef8 cleaning 2020-05-04 16:18:55 +02:00
4e4f06560c Adding support for clang-format (#94) 2020-05-04 16:16:23 +02:00
efcb6cf480 Merge branch 'static' into developer 2020-04-30 18:06:55 +02:00
9ae933b177 WIP 2020-04-30 18:04:30 +02:00
f87e8d3c19 WIP 2020-04-30 18:03:17 +02:00
903ebb2679 WIP 2020-04-30 17:58:31 +02:00
f41083842f WIP 2020-04-30 17:09:14 +02:00
9a87ba610a WIP 2020-04-30 15:26:50 +02:00
7224ad989a WIP 2020-04-30 14:04:50 +02:00
64f5c0f34b jungfrau virtual bug fix: sends multiple frames for both interfaces now 2020-04-29 18:07:59 +02:00
3238ecfc8d WIP 2020-04-29 18:02:57 +02:00
395d7ba98a Merge branch 'developer' into static 2020-04-29 14:20:12 +02:00
96ec3b2123 merge conflict resolved 2020-04-29 14:17:07 +02:00
b7805ae0d4 gotthard2, moench: remove leading spaces in config file on board detector server 2020-04-29 14:09:35 +02:00
1f6b0b5887 gotthard2: new default clk dividers 2020-04-29 12:51:05 +02:00
b1cdc79bd4 Merge branch 'developer' into static 2020-04-28 18:31:11 +02:00
f626db454e updated gotthard2, mythen3 binaries 2020-04-28 17:07:18 +02:00
86b39853a3 gotthard2, mythen3: making them clkdivider dependant and not clkfrequency, binaries not loaded yet 2020-04-28 17:04:57 +02:00
e3044689dd WIP 2020-04-28 14:26:59 +02:00
337e56d9bf cleaned up LTO detection 2020-04-23 08:23:36 +02:00
eb257154c6 added triggers 2020-04-22 09:15:31 +02:00
c1ae67ac46 Small refactor on ThreadObject and listener (#93)
* removed pointer, slight cleaning of loop

* removed semaphore, use getters

* removed redundant log msg

* removed comment

* added const

* removed comment

* changed header
2020-04-21 09:45:29 +02:00
68f76e5356 more like UdpRxSocket 2020-04-20 17:24:53 +02:00
8afa11ed33 removed pointer to server socket 2020-04-20 17:20:33 +02:00
bc389f4825 moved data members to top 2020-04-20 14:51:48 +02:00
095ced153c removed need for pointer 2020-04-20 14:31:10 +02:00
a1a5a20845 from thread sanitizer 2020-04-17 09:35:38 +02:00
c725a05ef8 fix RH7 2020-04-16 15:51:28 +02:00
815b6a37aa moved flag to base class 2020-04-16 13:22:51 +02:00
655a410d43 cleaned up UdpRxSocket 2020-04-16 09:45:44 +02:00
97ba81d923 fixed test 2020-04-14 16:58:37 +02:00
3d00eed0f0 Change SetTrimbits() and SaveAllTrimbits() to rely on top/bottom signal instead of TopAddressIsValid() for further cleanup. 2020-04-14 16:13:26 +02:00
a7f5300455 Merge pull request #92 from slsdetectorgroup/setrxhostname
Setrxhostname
2020-04-09 11:52:46 +02:00
2f33a1a479 updated binaries 2020-04-09 09:35:46 +02:00
39fa5e0185 client recieve rx parameters as a struct 2020-04-09 09:34:20 +02:00
ba4985ed4d Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-04-09 09:32:09 +02:00
f811c065d1 corrected a delete [] in multiThreadedAnalogDetector 2020-04-09 09:31:43 +02:00
3a1d87728c updated client api 2020-04-09 08:38:37 +02:00
0652ff6b5a updated binaries 2020-04-09 08:37:27 +02:00
373e177274 WIP 2020-04-09 08:35:30 +02:00
6dd6685e7d minor 2020-04-09 08:24:16 +02:00
38c31fdada WIP 2020-04-08 20:27:10 +02:00
b3fe0e79bc WIP 2020-04-08 16:43:28 +02:00
215e4a56fd Merge branch 'developer' into setrxhostname 2020-04-08 12:00:21 +02:00
71a68c2022 eiger transmitting fix in 10g mode (stop servers informed about 10g mode) 2020-04-08 11:58:59 +02:00
55f8497eac WIP 2020-04-08 11:05:06 +02:00
738f341265 eiger server compiled from previous commit 2020-04-08 08:41:39 +02:00
c4ae876ca7 Add Eiger server Init() modification also to initStopServer() 2020-04-07 17:45:53 +02:00
07cd71f0c7 removed update shared memory from detector, check if eiger firmware >=26: have same top and bottom addresses 2020-04-07 17:19:47 +02:00
9f3ad4e2f4 merge from 4.2.0 2020-04-07 15:14:27 +02:00
ab9fed45fb Merge pull request #91 from slsdetectorgroup/testing
Testing
2020-04-07 12:15:37 +02:00
a86ae0cb47 WIP 2020-04-07 12:14:22 +02:00
bdf0f9e2b9 fixed start stop tests 2020-04-07 10:39:50 +02:00
fad10273ed fix for server crashing when sending udp packets if no udp server present to listen to it (receiver): cannot use connect and write 2020-04-07 09:57:22 +02:00
83283b672a WIP 2020-04-06 19:38:35 +02:00
456b96446f WIP 2020-04-06 17:59:06 +02:00
80e55cd4da WIP 2020-04-06 17:28:05 +02:00
47b0e46f15 Merge branch 'developer' into testing 2020-04-06 10:55:41 +02:00
fdb6e3f3d4 Removeshm (#90)
* eiger: moved rate correction outside, fixed threshold energy bug in client (binaries not  updated yet)

* removed dr and deadtiem from shm

* help for rx_status and status to point them to rx_Start, rx_stop, start and stop

* moved progress to receiver

* removed currentsettings from eiger shm

* updated server binaries, and client api

* moench and ctb virtual servers compile fix

* gui: moved acquire to a concurrent qt thread so it doesnt block updateplot
2020-04-06 10:44:44 +02:00
eeed102bf3 somewhere between fork and pipes, crashes at sendingudppacket at print 2020-04-03 20:18:16 +02:00
7c7f7e8c70 testing WIP 2020-04-03 16:20:05 +02:00
262b4b0b16 more tests 2020-03-31 18:19:32 +02:00
83010de9f4 updated all binaries, previous ones may not work 2020-03-31 16:58:35 +02:00
f2dd146e56 updates on servers (mainly virtual): indices, dbit clock not allowed for moench anymore 2020-03-31 16:54:35 +02:00
03af145ee8 test delay fix 2020-03-31 13:38:11 +02:00
043e62f9fd delay test 2020-03-31 13:35:04 +02:00
6289163ac8 virtual servers checked 2020-03-31 10:40:42 +02:00
3ba9e5ec22 eiger, jungfrau, ctb, moench, gotthard virtual servers checked 2020-03-30 18:24:42 +02:00
719157f5c3 python funcs 2020-03-30 14:59:08 +02:00
d58eb1dc6e Gappixels (#89)
* WIP

* WIP virtual delays, imagetest for saturation

* WIP, vertical and horizontal

* WIP

* gap pixels work, fixed 32 bit data out (10gbe=0) for virtual servers

* quad works (also in virtual), handling gappixels and quad

* jungfrau gapppixels work

* jungfrau: done

* complete image or missing packets given in json header and gui

* eiger virtual 4 bit mode bug fix

* working version of zmq add json header, except printout

* printout bug

* fix for json para

* to map WIP

* map done

* map print , mapwith result left

* json result works, testing added

* updated server binaries

* compiling on rhels7, variable size char array iniitalization

* zmqsocket parsing didnt need Document

* const to map, json para is strings not map

* json add header: mapping cleaner without insert make_pair
2020-03-30 14:54:35 +02:00
6a6af528ef testing WIP 2020-03-30 13:25:39 +02:00
112d120a89 testing WIP 2020-03-27 18:54:46 +01:00
8dfb55d476 testing 2020-03-27 17:00:14 +01:00
d488f4bea8 updated all receiver testing 2020-03-27 16:59:16 +01:00
58ab3c4123 gold linker 2020-03-27 08:22:24 +01:00
02d7381788 compile manuals 2020-03-26 18:42:01 +01:00
fb051355b8 moved string conversion to .cpp 2020-03-26 15:06:23 +01:00
4d8a63eee1 ToString of Result<map> 2020-03-26 14:10:06 +01:00
d0c3e006fb printing of std::map 2020-03-26 12:39:56 +01:00
f22f23849d minor 2020-03-26 11:56:38 +01:00
94bddb9908 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-24 12:03:59 +01:00
ed20e17c3a fixed bug in pedestal cloning and changed cluster finder file format- tested only for 3x3 2020-03-24 12:03:29 +01:00
8fc1578a5e added support for MSG_PEEK 2020-03-24 09:20:38 +01:00
9753d075f0 added headers to install 2020-03-24 09:06:36 +01:00
865b4e50ad Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-19 17:12:44 +01:00
597c359ef8 added overload signatures in python binding 2020-03-19 17:12:35 +01:00
a108a4df4c fixed also the moench oofline cluster finder 2020-03-19 15:42:24 +01:00
0a6b04ee76 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-19 15:25:33 +01:00
78dd96357d fixed slsDeetctorcalibration - including interpolation for rectangular pixels 2020-03-19 15:25:00 +01:00
9230182e35 rxr: dont update index if fwrite 0 2020-03-19 15:21:21 +01:00
8f7adb130f conflict fix 2020-03-19 14:07:33 +01:00
16d5321885 rx_hostname can be added with port and also concatenated 2020-03-19 14:06:16 +01:00
9a6f521f6a other replacements for string 2020-03-19 12:39:42 +01:00
dee0aea378 replace stoi with StringTo<int> 2020-03-19 12:33:13 +01:00
0e3cd00579 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-19 11:56:49 +01:00
6091271f37 somenthing on calibration 2020-03-19 11:41:55 +01:00
272a8bfaf1 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-19 11:36:44 +01:00
75692c3539 zmq server address copy warning fix 2020-03-19 11:36:32 +01:00
46e9b450c0 assume dec unless 0x 2020-03-19 11:09:20 +01:00
40c5ccfe37 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-19 10:30:15 +01:00
bf1b1a2d9e string conversion for uint 2020-03-19 10:30:05 +01:00
b608ec6fbd zmqsocket: fname to string to remove warning in copying maxstr in maxstr in json header 2020-03-19 10:24:08 +01:00
4813b5567a Minimal shared memory for receiver 2020-03-19 07:01:32 +01:00
8ab742c2b7 docs 2020-03-18 17:53:57 +01:00
cb8403f1b0 zmq 2020-03-18 12:38:06 +01:00
b751238fc1 ZmqSocket 2020-03-18 12:12:01 +01:00
5479d3a198 fix 2020-03-18 11:11:00 +01:00
e1768905dd build interface 2020-03-18 11:06:37 +01:00
775d0842e9 build interface 2020-03-18 11:00:54 +01:00
e7e201bd2a export and include 2020-03-18 10:20:01 +01:00
ec9f8305e9 not export gui 2020-03-18 08:41:25 +01:00
3307bfab1b fix 2020-03-17 19:11:29 +01:00
ce2c62000d include cmake in build 2020-03-17 18:57:19 +01:00
cf817c4ec1 WIP 2020-03-17 18:29:51 +01:00
bd01a5f2d2 cmake pkg 2020-03-16 19:36:18 +01:00
b059ba7c90 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-16 15:43:55 +01:00
89d70097f6 WIP 2020-03-16 15:43:46 +01:00
41d115a394 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-13 19:36:38 +01:00
45c1d3a553 gotthard2: burst mode fix for all the registers 2020-03-13 19:36:23 +01:00
17227be4df gotthard2: burst mode fix 2020-03-13 17:39:16 +01:00
7f4f8e8f09 help bug emax 2020-03-13 09:56:11 +01:00
6809bd6567 removed header 2020-03-12 12:38:00 +01:00
711d40a56e added sendToReceiver 2020-03-12 11:45:12 +01:00
81911fae3c new version of send to detector 2020-03-11 19:18:26 +01:00
f940397e3a cleaning 2020-03-11 18:10:37 +01:00
dc53887a48 minor clean 2020-03-11 17:49:32 +01:00
5784ce8231 slsDetector -> Module 2020-03-11 16:16:15 +01:00
012c66bbbf minor 2020-03-11 15:57:10 +01:00
3dbd6a33f7 removed genericSocket 2020-03-11 13:39:40 +01:00
0de0d82a1a replaced old logger 2020-03-11 12:40:12 +01:00
4aeb8bf62e introducing new logger 2020-03-11 10:54:55 +01:00
2acf64b09c gui changes (#87) 2020-03-11 10:08:30 +01:00
dea8cba985 changes from 4.2.0-rc: eiger check for max trimbits; end of eigerserver: if detector ip, set activate; update both control and stop server for activate 2020-03-10 16:49:08 +01:00
9467b4c610 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-10 16:25:15 +01:00
2cb09a590a gotthard2, mythen3: firmware type check added, others: minor print 2020-03-10 16:25:07 +01:00
5900403f20 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-10 16:10:09 +01:00
53749c3b77 clean 2020-03-10 16:09:59 +01:00
1d2f4a8af0 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-10 15:59:35 +01:00
df2512fb1c all servers: eiger, jungfrau, gotthard, ctb, moench, mythen3, gotthard2 updated 2020-03-10 15:57:27 +01:00
e4942a5c8d virtual servers warnings fixed 2020-03-10 15:53:44 +01:00
ac1c40d6f9 virtual servers: redundant declarations fixed 2020-03-10 15:50:33 +01:00
8ba0ef093e cmap 2020-03-10 15:50:14 +01:00
cb268aa43f cmap 2020-03-10 15:49:54 +01:00
5192dae9c5 removed virtual server warnings 2020-03-10 15:15:09 +01:00
d818e2570f clang-tidy nullptr 2020-03-10 15:06:51 +01:00
ee799b540a removed redundant includes etc. 2020-03-10 11:12:00 +01:00
ae3189d836 changed cxx to cpp 2020-03-10 10:28:27 +01:00
9ede0629ef clang format on gui 2020-03-10 10:18:52 +01:00
bd6529a64c warnings for virtual servers 2020-03-10 09:27:23 +01:00
758afad02c ctb, moench, eiger, gotthard: get number of channels for moench and ctb, others removed unnecessary variables in shm, added moench virtual sever (#86) 2020-03-10 09:08:08 +01:00
013836bea5 Merge pull request #85 from slsdetectorgroup/qwtifdef
Version defs and checking pointer before delete
2020-03-09 18:06:25 +01:00
de6808b170 Update CMakeLists.txt
qwt minimum 6.1
2020-03-09 18:05:27 +01:00
4c4ee3ae25 Merge pull request #83 from slsdetectorgroup/logger
New logger
2020-03-09 17:46:18 +01:00
0e171f291d added std::flush 2020-03-09 13:57:50 +01:00
bd47c969dd WIP 2020-03-09 12:49:24 +01:00
e4a86e544a WIP 2020-03-09 12:42:57 +01:00
a4fa9ff480 gui: scroll area uniquie pointers to remove mem leak 2020-03-06 19:44:44 +01:00
908afc790d jungfrau: new firmware version 2020-03-06 18:08:08 +01:00
d6e174ea11 jungfrau: adc phase changed again 2020-03-06 17:54:38 +01:00
f255becffe jungfrau: adcphase values nad dbit values done for new boards 2020-03-06 17:49:22 +01:00
0a596c689b sanitizer on, gui:removed qfuture, client: not implemented made specific as to what is not 2020-03-06 15:41:15 +01:00
a2e019ff36 moench: updated adcpipeline from 14 to 15 2020-03-06 10:47:21 +01:00
959d62ed66 moench: default clocks and phase are same as ctb at startup 2020-03-05 18:03:53 +01:00
1d2a46cdbe moench:dsamples=0 at startup 2020-03-05 17:13:58 +01:00
aeb9ddfe62 moench:dbit clock updated to 40 2020-03-05 17:10:37 +01:00
4a802bd2e4 gotthard2: switching between continuous to burst mode (burstperiod got reset: fixed) 2020-03-05 16:35:52 +01:00
c2639854fa ctb gui works with moench detector 2020-03-05 14:53:24 +01:00
dec4d00fbf ctb: gui call back fix 2020-03-05 11:31:36 +01:00
e3f9ef0b25 moench and eiger updated as well 2020-03-05 10:24:59 +01:00
9ca86c2edb ctb, gotthard, gotthard2, jungfrau, mythen updated 2020-03-05 10:21:24 +01:00
c64b09ee79 Jungfraufix (#84)
* jungfrau: added dbitphase, different pll clkindex 0 with different wr bit
2020-03-04 17:06:18 +01:00
c6ddd19c0f WIP 2020-03-04 15:38:21 +01:00
661adaf4ed WIP 2020-03-04 15:25:49 +01:00
4e2f685b76 gotthard2: gain plot fix with clones 2020-03-04 14:39:44 +01:00
6e4a3353a3 moench: removed commented out settings 2020-03-04 13:53:28 +01:00
042e5715e6 conflict fix 2020-03-04 13:51:58 +01:00
e143204ce1 Corrected settings and patter for moench detector 2020-03-04 13:33:42 +01:00
ff9c37701b WIP 2020-03-04 12:35:41 +01:00
5f3af794ce moench bug fix: power chip enable 2020-03-04 12:34:32 +01:00
e7df925d6b moench sample config file in examples 2020-03-04 11:32:11 +01:00
7859cf78e9 moench: allow power chip 2020-03-04 10:41:10 +01:00
1b996d1703 revised gain plot; updated version api 2020-03-04 10:25:38 +01:00
2fcb41426a Merge pull request #82 from slsdetectorgroup/moenchUpdated
Moench updated
2020-03-04 10:22:09 +01:00
032475fc14 gainplot clone revised 2020-03-04 10:17:51 +01:00
5430288ce8 merge fix 2020-03-03 17:57:55 +01:00
a61c5e0206 Merge pull request #81 from slsdetectorgroup/readme
Updated readme
2020-03-03 17:56:05 +01:00
582a3c6878 Update README.md 2020-03-03 17:55:16 +01:00
134611c638 gotthard2: switching between period and burst period (not delay and burst period), internal frequency depending on timing source (for all except actualtime and measurement time) 2020-03-03 17:49:28 +01:00
3431752649 WIP 2020-03-03 17:01:45 +01:00
06bd6dfd53 Merge branch 'developer' into moenchUpdated 2020-03-03 16:37:31 +01:00
fca7d51cb4 moench: removed hardcoding ny in call back for gui 2020-03-03 16:30:28 +01:00
85aca0ffad moench: insignficant dac naming fix 2020-03-03 16:21:45 +01:00
fac95516cf moench: insignficant naming fix 2020-03-03 16:07:37 +01:00
8abc32e7f1 moench: default pattern file in server, settings, tests 2020-03-03 16:00:01 +01:00
1efacc9475 cleaning up headers 2020-03-03 11:33:28 +01:00
b2d88b441a removed comments 2020-03-03 11:17:26 +01:00
75e083ae46 find tests and commands 2020-03-03 11:04:05 +01:00
9699e064d3 WIP 2020-03-03 10:12:26 +01:00
c6c3a68520 WIP 2020-03-03 10:08:20 +01:00
5e92c5b67e WIP 2020-03-03 09:38:05 +01:00
0947cefe08 WIP 2020-03-03 09:29:25 +01:00
6bbcf6173d moench: first version 2020-03-02 18:34:10 +01:00
ecc3b36204 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-02 14:50:48 +01:00
3e88beb8a5 O3 as default and option for mtune 2020-03-02 13:50:16 +01:00
cce659d98c deploy only on tags 2020-03-02 13:12:46 +01:00
95d56ad545 lookup 2020-03-02 11:57:35 +01:00
84cd4d8436 generated python funcs 2020-03-02 11:34:30 +01:00
d7319968a7 gui: always show gain plots, include intensity ticks(2d), channels number and gain ticks(1d) 2020-02-28 17:28:44 +01:00
a769f7515c gotthard2 bug fix: fixed pll freq was incorrect when 0 in front 2020-02-28 16:03:15 +01:00
11e7737a2f gotthard2: timingsource and currentsource features, (timing source external yet to be implemented in fpga to test (#80) 2020-02-28 12:45:02 +01:00
913df8ecae Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-28 12:26:48 +01:00
c10e04c4eb explicitly setting rx zmq datastream int the ctb Gui 2020-02-28 12:25:48 +01:00
2e2e91b219 ctb adc: get in uV and print in client in mV to get decimals 2020-02-27 15:43:42 +01:00
10ba16a9dc updating versions 2020-02-27 14:26:18 +01:00
8c8032dc69 ctb bug fix: slow adcs incorrect mv read out, needed clk down and usleep before reading 2020-02-27 09:16:22 +01:00
90acd51389 server api changes: for mythen3, jungfrau, eiger as well 2020-02-26 17:52:35 +01:00
f38ed8706f removing gui warnings from qwt section 2020-02-26 16:56:41 +01:00
300b0c8105 Merge pull request #79 from slsdetectorgroup/bursts
Bursts
2020-02-26 11:29:05 +01:00
d9cfc59df6 code refactor in slsdet: prevval for setnumtriggers 2020-02-26 11:27:24 +01:00
80304c2eaf multi progress calculated in one function rather getting all of them from shm 2020-02-26 11:17:49 +01:00
fe3a7b0faf gotthard2: removed unnecessary casting 2020-02-26 11:02:28 +01:00
e66d42a43d old form fix 2020-02-26 10:28:45 +01:00
ec76590f28 Merge branch 'developer' into bursts 2020-02-26 09:29:18 +01:00
2fcb2bff75 dac tests 2020-02-26 09:29:06 +01:00
2310b5e55d Merge branch 'developer' into bursts 2020-02-25 20:03:18 +01:00
dca2d098a9 gui: hide gain legend 2020-02-25 20:03:09 +01:00
462bc2e70c Merge branch 'developer' into bursts 2020-02-25 18:22:58 +01:00
2da3d179ee gotthard2 gain plot in gui 2020-02-25 18:22:18 +01:00
5e6a3b7e3d merge resolved 2020-02-25 15:48:41 +01:00
6a0a931e3e gotthard2: bursts and burst period, written to same register as triggers and delay (kept in server as variables) and set if conditions meet. bursts and burst period only in auto timing and burst mode. Also updating theses registers when switching between timing modes or burst modes 2020-02-25 15:45:40 +01:00
2bec476b4f fixed failed tests 2020-02-25 09:26:57 +01:00
f902bb06ad gui bug fix: trigger timing mode was disconnected 2020-02-24 17:40:00 +01:00
c03bc4a6b4 gotthard2: copy #frames and period when switching between continuous and burst mode 2020-02-24 17:20:51 +01:00
6118567959 gotthard2 gui bug fix: gainbit not masked out 2020-02-24 17:04:37 +01:00
02b367ffe8 mythen3 and gotthard2: updated clocks 2020-02-24 16:50:47 +01:00
87d48fd943 bugfix rxr numpacketscaught if stopped 2020-02-24 15:02:01 +01:00
21a1b872bf bugfix:mythen3 date change 2020-02-24 11:00:16 +01:00
3a74ca8fc2 bugfix: mythen3 git date incorrect 2020-02-24 10:53:06 +01:00
f4b922165f bugfix from earlier commit: dr in readfromreceiver commented out 2020-02-24 10:36:52 +01:00
247d40f5a6 added Zmq image structures 2020-02-21 11:56:44 +01:00
8953235268 reverted to UdpRxSocket.h version of revision fc27cfd (with gcc problem fixed) 2020-02-21 11:07:24 +01:00
3b84684415 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-18 18:26:19 +01:00
d0da5d3fcd update manual 2020-02-18 18:26:11 +01:00
52a89cbcc5 fix for older gcc 2020-02-18 17:54:28 +01:00
d8c9748850 update manual to 4.1.1 2020-02-18 15:49:00 +01:00
f42e87e37f format 2020-02-18 15:03:02 +01:00
53a3656d5e removed copy, fixed receive to external buffer 2020-02-18 15:02:40 +01:00
fc27cfd663 merging problem 2020-02-18 10:55:41 +01:00
6b0bf02a85 Some fixes to use moench 2020-02-18 10:45:53 +01:00
f1bce15a57 replaced udp socket 2020-02-17 17:43:14 +01:00
3ea9b86bf5 date fix 2020-02-13 14:50:23 +01:00
4cce0aee62 Fixed ctbGui to work also with moench03 2020-02-06 14:28:20 +01:00
dfb1b9ad69 Revert "gotthard2: burst mode check"
This reverts commit 4d6996bd55.
2020-02-04 15:29:43 +01:00
4d6996bd55 gotthard2: burst mode check 2020-02-04 15:28:24 +01:00
0ac28c0208 gotthard2: burst mode check for #frames 2020-02-04 15:27:18 +01:00
37c3048c2a gotthard2: bug fix from previosu commit 2020-02-04 12:32:37 +01:00
d3dc9a7690 gotthard2: disentangled burst mode #frames, exptime, period from start of acquisition, order dependent now for debugging 2020-02-04 12:23:58 +01:00
c4559fadb3 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-04 12:00:15 +01:00
806a2736c1 gotthard2: longer wait for startup, period 0 2020-02-04 12:00:07 +01:00
94fcf52e64 Merge pull request #76 from slsdetectorgroup/exec
Buffern in exec
2020-02-04 10:59:48 +01:00
64214f22f9 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-04 10:50:14 +01:00
36bd91daa3 gotthard2: sleep before configuring on chip dacs, default exptime 0 and default period to 1ms 2020-02-04 10:50:01 +01:00
40bfca588b minor from clang-tidy 2020-02-04 10:36:03 +01:00
b9446f40d1 fmt and minor 2020-02-04 10:11:27 +01:00
ec66079f65 renamed ServerInterface 2020-02-04 08:57:35 +01:00
e6340456f6 minor 2020-02-04 08:47:22 +01:00
f42d591845 sizeof 2020-02-03 16:51:57 +01:00
e9029ba8f2 removed unused functions 2020-02-03 16:44:14 +01:00
121747352d buffer 2020-02-03 16:35:30 +01:00
4cfea36b93 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-03 16:00:32 +01:00
a829e69313 minor 2020-02-03 16:00:24 +01:00
42124ca97c eiger rxr: setting exptime now also sets subperiod in rxr master file 2020-02-03 15:54:41 +01:00
972f21258a renamed multiSlsDetector 2020-02-03 14:57:37 +01:00
6bb1188c37 renamed exes 2020-02-03 14:43:40 +01:00
a57c677105 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-03 14:38:31 +01:00
254e8f85d8 moved non public headers 2020-02-03 14:38:24 +01:00
56484daf18 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-03 12:25:40 +01:00
6cc13f9dc1 naming 2020-02-03 12:05:52 +01:00
93ab8d05d7 eiger: change speed to full speed for dr of 4, 8, 16 2020-02-03 11:37:43 +01:00
88c65c506f Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-03 11:34:14 +01:00
074636a7d6 minor cleaning 2020-02-03 11:34:07 +01:00
e432e6f90d 4.1.1 changes: software trigger via stop server, disentangling rxr streamin from register call back 2020-02-03 11:25:19 +01:00
a3c686d271 renamed 2020-02-03 11:04:49 +01:00
9f79f132b7 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-03 10:34:51 +01:00
4a7424d749 renamed circularFifo 2020-02-03 10:34:43 +01:00
e4f2072067 Merge pull request #75 from slsdetectorgroup/nohardexit
initialchecks can be bypassed (version compatibility and oher tests a…
2020-02-03 09:13:38 +01:00
8bae1059db Merge branch 'developer' into nohardexit 2020-01-31 17:36:22 +01:00
4b39ca6e5f gotthard2 gui 2020-01-31 17:35:56 +01:00
f0cccf9de8 initialchecks can be bypassed (version compatibility and oher tests at server start up) 2020-01-31 16:46:33 +01:00
89c774dbf7 nios programming: check file size first 2020-01-31 11:24:48 +01:00
5ca3a1b685 gotthard2 and mythen3: programming fpga, reboot; jungfrau, ctb: modified programming (#74) 2020-01-30 19:52:35 -08:00
7d7302a90c mnior 2020-01-29 14:38:19 +01:00
ac3230c656 gotthard2 testing 2020-01-29 14:34:23 +01:00
5761642da0 Merge branch 'developer' into gotthard2testing 2020-01-29 11:37:59 +01:00
70ffdf9709 fixes for IpAddr and MacAddr in Gui 2020-01-28 15:00:05 +01:00
af2f2708ad rxr: remove file buffering 2020-01-28 13:55:44 +01:00
c42b4b8c0e incorrect printout to MB 2020-01-28 10:43:06 +01:00
d9b88ea7d2 performance optimization in fifodepth, ensure memory is allocated by writing something in the beginning 2020-01-27 20:10:49 +01:00
9f22c80081 Revert "performance optimization in fifodepth, ensure memory is allocated by writing something in the beginning"
This reverts commit ab6f448e1f.
2020-01-27 19:59:18 +01:00
ab6f448e1f performance optimization in fifodepth, ensure memory is allocated by writing something in the beginning 2020-01-27 18:34:10 +01:00
53e5a097ab rxr: semaphore instead of keeprunning variable at startup 2020-01-27 18:03:03 +01:00
e527aad6ab bugfix: high fifo depth more than 32 bit 2020-01-27 15:25:41 +01:00
a0208778c1 bugfix: high fifo depth more than 32 bit 2020-01-27 15:21:19 +01:00
69897d4c78 WIP testing 2020-01-27 13:56:44 +01:00
41035808e9 merge from mythen3 and gotthard2 2020-01-24 15:08:58 +01:00
2314fdabd1 merge from mythen3, and jungfrau fix 2020-01-23 16:44:01 +01:00
abe63acc79 jungfrau fix: wait for acquisition to be done before sending stop receiver 2020-01-23 16:41:09 +01:00
688e4e84d9 Merge pull request #73 from slsdetectorgroup/mythen3
mythen3: virtual server, connected timing mode, row and col in header…
2020-01-23 12:35:43 +01:00
0210b7358c autogen python bindings 2020-01-23 12:13:23 +01:00
dd84337ef3 autogen enums 2020-01-23 11:45:33 +01:00
a9e375ed34 gotthard2: bursttype to burstmode 2020-01-23 11:03:14 +01:00
f881133795 get/set timing, generate data for gotthard2, vref_rstore instead of restore for gotthard2 2020-01-22 18:18:56 +01:00
8cbf3c62a9 merge from developer 2020-01-22 17:30:13 +01:00
ffc09ed19c Gotthard2 (#72)
* rearranging

* gotthard2: updated register map; powerchip checking detector type; internal and external period, frames, exptime; set/get delay, get actualtime, measurement, framesfromstart enabled; which detector comment updated in cmdproxy, detector and slsdetector

* gotthard2: first edit

* gotthard2 bug fix: no module attached

* gotthard2: works

* updated client doc for gotthard2: the timers that are used in continuous mode only

* gotthard2 virtual server sends data

* gotthard2: gain updated
2020-01-22 14:03:59 +01:00
3ea2520615 PR minor changes 2020-01-22 13:55:10 +01:00
1dea112742 adding gotthard2 tests 2020-01-22 11:35:29 +01:00
d8fccdcefa Merge branch 'developer' into gotthard2 2020-01-21 18:18:57 +01:00
981b13494c mythen3: virtual server, connected timing mode, row and col in header, included pattern bit and mask 2020-01-21 18:16:27 +01:00
7131f77a3a eiger: vcal set to 0 2020-01-21 16:10:15 +01:00
f08d430d16 eiger: vcal set to 0 2020-01-21 16:09:39 +01:00
9c89f6a63d Merge branch 'developer' into gotthard2 2020-01-21 16:05:04 +01:00
e746256653 gotthard2: gain updated 2020-01-21 16:01:38 +01:00
2e78484b61 gotthard2 virtual server sends data 2020-01-21 14:50:31 +01:00
1908a82627 ctb 2020-01-21 10:44:43 +01:00
bdf3a010c3 updated client doc for gotthard2: the timers that are used in continuous mode only 2020-01-21 10:26:11 +01:00
6bd0256172 pattern stuff 2020-01-21 10:22:26 +01:00
5667353f47 WIP 2020-01-21 09:07:27 +01:00
c4137dc309 gotthard2: works 2020-01-20 17:03:11 +01:00
4b7edf2e62 ctb 2020-01-20 16:46:38 +01:00
0194d7ba1c ctb 2020-01-20 16:37:18 +01:00
23dffa47df gotthard2 bug fix: no module attached 2020-01-20 14:42:06 +01:00
5c35a33e02 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-01-20 14:27:30 +01:00
a0c222b3c6 constructor 2020-01-20 14:23:28 +01:00
65d95480bd mythen3 bug fix: rxr needs to update dr 2020-01-20 13:50:50 +01:00
6cfd0f8962 gotthard2: first edit 2020-01-20 12:13:23 +01:00
6e47f0b7f7 merge resolved 2020-01-20 11:36:35 +01:00
3c891495db mythen3: bug fix detector type 2020-01-20 11:32:02 +01:00
66b837eb59 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-01-16 16:57:12 +01:00
6170c42618 explicit also in MacAddr 2020-01-16 16:57:04 +01:00
95030bc55f Merge branch 'developer' into gotthard2 2020-01-16 16:52:08 +01:00
69dd5f3b5e Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-01-16 16:37:44 +01:00
c1fac7cdb7 fixed conversion for IpAddr 2020-01-16 16:31:11 +01:00
de57146e1b Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-01-16 16:14:11 +01:00
fb75986c55 mythne3: counters fixed 2020-01-16 16:13:40 +01:00
e8bdf5a505 gotthard2: updated register map; powerchip checking detector type; internal and external period, frames, exptime; set/get delay, get actualtime, measurement, framesfromstart enabled; which detector comment updated in cmdproxy, detector and slsdetector 2020-01-16 15:33:35 +01:00
f3598c1f39 nullptr 2020-01-16 14:17:57 +01:00
9ac08ad5c9 clang-tidy header include order 2020-01-16 14:00:43 +01:00
bcb4942793 cleaning 2020-01-16 12:26:22 +01:00
4b69ac5cfc const string& in exceptions constructor 2020-01-16 11:44:01 +01:00
7a00732fa8 various minor things from clang-tidy 2020-01-16 11:39:35 +01:00
30a4a1740f added Mythen3 2020-01-15 17:56:08 +01:00
39ec29c0e6 added counters to python 2020-01-15 17:26:07 +01:00
b6d9015ed0 rearranging 2020-01-15 15:08:01 +01:00
de53747ddd Counters (#71)
* mythen3: adding counters mask, firmware still takes only number of counters for now

* mythen3: checking if module attached before powering on chip

* bug fix: loop inital declaration not allowed in c

* fix scope eiger test

* mythen3: renamed setCounters to setCounterMask and getCounterMask in API

* mythen3 replacing counting bits with popcount

Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com>
2020-01-14 17:40:46 +01:00
70c54f4315 added jungfrau again 2020-01-13 18:26:24 +01:00
a709384fbb renamed python detector 2020-01-13 16:33:02 +01:00
a1abd7587c Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-01-13 16:13:52 +01:00
8c8d213b56 python funcs 2020-01-13 16:13:47 +01:00
7b31fbc002 eiger virtual server bug fix: increasing subdeadtime 2020-01-13 14:18:43 +01:00
db9aa7589a tests fix 2020-01-13 12:07:30 +01:00
28f8a76dcc updated binaries 2020-01-10 09:05:26 +01:00
dac5ecd123 dbit 2020-01-08 16:44:42 +01:00
71b0ed271e CTB 2020-01-08 15:33:28 +01:00
c223f00511 Eiger 2020-01-08 14:55:16 +01:00
639ed52d65 pybind 2.4 2020-01-07 16:30:59 +01:00
6943763e3d Updated pybind11 to 2.4.3 2020-01-07 16:30:12 +01:00
4b3b518401 asamples dsamples 2020-01-07 16:18:36 +01:00
7379b1e2ef added python3.8 2020-01-07 15:48:38 +01:00
ed2a69744b Auto generating Python bindings (#70)
Auto generating python bindings
2020-01-07 15:47:38 +01:00
086cbacd84 mythen3: connected busy signal insttead of timer 2019-12-10 11:03:27 +01:00
af9b25fd67 eiger: validate trimval range 2019-12-10 10:32:28 +01:00
504fc2d095 ctb: validate asampes and dsamples > 0 for romode; client: exception caught in acquire to stop receiver and clear busy flag 2019-12-10 10:25:14 +01:00
5cf1502287 ctb bug fix: 10g adc enable mask 2019-12-09 11:30:54 +01:00
8881542156 ctb bug fix: clkioctrl not taken in hex 2019-12-05 17:15:31 +01:00
d9ae9a8cc6 eiger test 2019-12-05 11:00:55 +01:00
6765eb0c94 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2019-12-04 10:25:25 +01:00
be3d82b7b4 format 2019-12-04 10:25:17 +01:00
4e0d1fa711 ctb rxr for pawel: updated packetsize to 8192 (datasize to 8144) 2019-12-03 17:25:39 +01:00
619106e05f eiger tests 2019-12-03 11:47:49 +01:00
9bc60518d8 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2019-12-03 10:12:58 +01:00
12d168a6ef const strref 2019-12-03 10:12:47 +01:00
1a8337540a rxr: switched to threads for threadObject (from pthread), moved priorities to threadObject, mutex 2019-11-29 16:19:02 +01:00
16bec25b0c rxr: pthread to thread and created and destroyed tcp thread in constructor and destructor 2019-11-29 15:17:41 +01:00
f178b0da39 Merge branch 'rxr' into developer 2019-11-29 11:10:05 +01:00
2ece6b945e rxr: warnings shouldnt throw exception 2019-11-29 11:09:41 +01:00
1d6be74ee5 rxr: removed return ok or fail and replaced with exceptions 2019-11-29 10:29:36 +01:00
07455bb11e Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2019-11-27 18:42:27 +01:00
f4cdd759b0 clang-tidy 2019-11-27 18:42:16 +01:00
796890d1c8 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2019-11-27 18:25:14 +01:00
3486137de3 bfin warnings fixed 2019-11-27 18:22:33 +01:00
d53082c615 clang-tidy empty() 2019-11-27 18:15:55 +01:00
c94f6a2bf2 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2019-11-27 17:56:02 +01:00
2364364697 minor 2019-11-27 17:55:50 +01:00
ad0fb44573 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2019-11-27 17:29:26 +01:00
9455a5fba1 ctb: adcenable10g included, 10g readout enables included 2019-11-27 17:28:57 +01:00
a28fa66e54 renamed CmdLineParser to CmdParser 2019-11-27 13:56:14 +01:00
e996068328 more tests 2019-11-27 13:39:06 +01:00
1bbd77536c Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2019-11-27 11:35:16 +01:00
ace105a268 more tests 2019-11-27 11:35:00 +01:00
409 changed files with 67477 additions and 54539 deletions

View File

@ -3,4 +3,5 @@ IndentWidth: 4
UseTab: Never
ColumnLimit: 80
AlignConsecutiveAssignments: false
AlignConsecutiveAssignments: false
AlignConsecutiveMacros: true

View File

@ -16,7 +16,9 @@ Checks: '*,
-hicpp-braces-around-statements,
-google-runtime-references,
-google-readability-todo,
-google-readability-braces-around-statements'
-google-readability-braces-around-statements,
-modernize-use-trailing-return-type,
-readability-isolate-declaration'
HeaderFilterRegex: \.h
AnalyzeTemporaryDtors: false

1
.gitignore vendored
View File

@ -7,6 +7,7 @@ bin/
*.out
*.toc
*.o
*.so
.*
build
RELEASE.txt

View File

@ -4,38 +4,25 @@ language: cpp
os: linux
env:
matrix:
- CONDA_PY=3.6
- CONDA_PY=3.7
dist: trusty
dist: bionic
install:
- sudo apt-get update
- ldd --version
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- source "$HOME/miniconda/etc/profile.d/conda.sh"
- rm -f miniconda.sh
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda config --add channels conda-forge
- conda config --add channels slsdetectorgroup
- conda update conda
- conda update --all
- conda install conda-build=3.17
- conda install anaconda-client
- conda install conda-verify
# Useful for debugging any issues with conda
- conda update -q conda
- conda info -a
# Replace dep1 dep2 ... with your dependencies
- conda create -q -n test-environment python=$CONDA_PY
- source activate test-environment
# Useful for debugging any issues with conda
- conda create -q -n testenv conda-build anaconda-client conda-verify
- conda activate testenv
- conda-build .
script:
@ -44,7 +31,8 @@ script:
deploy:
provider: script
script: find $HOME/miniconda/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \;
script: find $HOME/miniconda/envs/testenv/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \;
on:
branch: developer
tags: true

View File

@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.12)
project(slsDetectorPackage)
set(PROJECT_VERSION 5.0.0)
include(CheckIPOSupported)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
cmake_policy(SET CMP0074 NEW)
include(cmake/project_version.cmake)
@ -45,6 +44,35 @@ option(SLS_USE_PYTHON "Python bindings" OFF)
option(SLS_USE_CTBGUI "ctb GUI" OFF)
option(SLS_BUILD_DOCS "docs" OFF)
option(SLS_BUILD_EXAMPLES "examples" OFF)
option(SLS_TUNE_LOCAL "tune to local machine" OFF)
option(SLS_DEVEL_HEADERS "install headers for devel" OFF)
# set(ClangFormat_BIN_NAME clang-format)
set(ClangFormat_EXCLUDE_PATTERNS "build/"
"libs/"
"slsDetectorCalibration/"
"ctbGui/"
"manual/"
"python/"
"sample/"
${CMAKE_BINARY_DIR})
find_package(ClangFormat)
#Enable LTO if available
check_ipo_supported(RESULT SLS_LTO_AVAILABLE)
# Use ld.gold if it is available and isn't disabled explicitly
option(SLS_USE_LD_GOLD "Use GNU gold linker" ON)
if (SLS_USE_LD_GOLD)
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if ("${LD_VERSION}" MATCHES "GNU gold")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
else ()
message(WARNING "GNU gold linker isn't available, using the default system linker.")
endif ()
endif ()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@ -106,12 +134,17 @@ endif()
if(SLS_USE_SANITIZER)
# target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer)
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined)
target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread)
target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer)
target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined)
# target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread)
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
endif()
if(SLS_TUNE_LOCAL)
target_compile_options(slsProjectOptions INTERFACE -mtune=native -march=native)
endif()
#rapidjson
add_library(rapidjson INTERFACE)
target_include_directories(rapidjson INTERFACE
@ -127,7 +160,7 @@ install(TARGETS slsProjectOptions slsProjectWarnings rapidjson
)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_INSTALL_RPATH "$ORIGIN")
set(CMAKE_INSTALL_RPATH $ORIGIN)
# set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
@ -160,7 +193,7 @@ endif (SLS_USE_RECEIVER)
if (SLS_USE_GUI)
find_package(Qt4 REQUIRED)
find_package(Qwt 6 REQUIRED)
find_package(Qwt 6.1 REQUIRED)
if (QT4_FOUND AND QWT_FOUND)
add_subdirectory(slsDetectorGui)
endif()
@ -175,6 +208,7 @@ if (SLS_USE_INTEGRATION_TESTS)
endif (SLS_USE_INTEGRATION_TESTS)
if (SLS_USE_PYTHON)
set(PYBIND11_CPP_STANDARD -std=c++11)
add_subdirectory(libs/pybind11)
add_subdirectory(python)
endif(SLS_USE_PYTHON)
@ -195,11 +229,9 @@ if(SLS_BUILD_DOCS)
add_subdirectory(docs)
endif(SLS_BUILD_DOCS)
if(SLS_MASTER_PROJECT)
# Set install dir CMake packages
set(CMAKE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/cmake/sls)
set(CMAKE_INSTALL_DIR "share/cmake/${PROJECT_NAME}")
# Set the list of exported targets
set(PROJECT_LIBRARIES slsSupportLib slsDetectorShared slsReceiverShared)
# Generate and install package config file and version

113
README.md
View File

@ -2,90 +2,67 @@
Detailed documentation can be found on the [official site.](https://www.psi.ch/detectors/users-support)
### Binaries
Documentation to obtain the binaries via the conda package is available for [lib](https://github.com/slsdetectorgroup/sls_detector_lib) and [gui](https://github.com/slsdetectorgroup/sls_detector_gui)
Binaries for the slsDetectorPackage are available through conda.
```
#Add conda channels
conda config --add channels conda-forge
conda config --add channels slsdetectorgroup
conda install slsdetlib #only shared lib and command line
conda install slsdet #python bindings (includes slsdetlib)
conda install slsdetgui #gui (includes qt4)
#Install specific version
conda install slsdet=2020.03.02.dev0 #developer version from 3 March 2020
```
### Source code
One can also obtain the source code from this repository and compile while realizing the setup dependencies as required.
One can also obtain the source code from this repository and compile.
```
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git
```
#### Setup dependencies
* Gui Client <br>
Requirements: Qt 4.8 and Qwt 6.0
```
export QTDIR=/usr/local/Trolltech/
export QWTDIR=/usr/local/qwt-6.0.1/
```
If either of them does not exist, the GUI client will not be built.
#### Dependencies
* Lib: c++11 compiler (gcc=>4.8), ZeroMQ 4
* Gui: Qt 4.8 and Qwt 6.0
* Calibration wizards and ctbGUI: ROOT
* Optional: HDF5
* Advanced user Calibration wizards<br>
Requirements: ROOT
```
export ROOTSYS=/usr/local/root-5.34
```
#### Compilation
Compiling can be done in two ways.
Compiling can be done in two ways. Either with the convenience script
cmk.sh or directly with cmake for more control.
**1. Compile using script cmk.sh**<br>
After compiling, the libraries and executables will be found in `slsDetectorPackage/build/bin` directory<br>
Usage: [-c] [-b] [-h] [-d HDF5 directory] [-j]<br>
* -[no option]: only make<br>
* -c: Clean<br>
* -b: Builds/Rebuilds CMake files normal mode<br>
* -h: Builds/Rebuilds Cmake files with HDF5 package<br>
* -d: HDF5 Custom Directory<br>
* -t: Build/Rebuilds only text client<br>
* -r: Build/Rebuilds only receiver<br>
* -g: Build/Rebuilds only gui<br>
* -j: Number of threads to compile through<br>
* -e: Debug mode
Basic Option:
./cmk.sh -b
For only make:
./cmk.sh
For make clean;make:
./cmk.sh -c
For using hdf5 without custom dir /blabla:
./cmk.sh -h -d /blabla
For rebuilding cmake without hdf5
./cmk.sh -b
For using multiple cores to compile faster:
./cmk.sh -j9<br>
For rebuilding only certain sections<br>
./cmk.sh -tg #only text client and gui<br>
./cmk.sh -r #only receiver<br>
Usage: [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [-h] [-d <HDF5 directory>] [-j] <Number of threads>
-[no option]: only make
-c: Clean
-b: Builds/Rebuilds CMake files normal mode
-p: Builds/Rebuilds Python API
-h: Builds/Rebuilds Cmake files with HDF5 package
-d: HDF5 Custom Directory
-t: Build/Rebuilds only text client
-r: Build/Rebuilds only receiver
-g: Build/Rebuilds only gui
-s: Simulator
-u: Chip Test Gui
-j: Number of threads to compile through
-e: Debug mode
-i: Builds tests
eg. Rebuild when you switch to a new build and compile in parallel:
./cmk.sh -bj5
**2. Compile without script**<br>
Use cmake to create out-of-source builds, by creating a build folder parallel to source directory.
Use cmake to create out-of-source builds, by creating a build folder parallel to source directory. This would create a debug build with address sanitizers.
```
$ cd ..
$ mkdir slsDetectorPackage-build
$ cd slsDetectorPackage-build
$ cmake ../slsDetectorPackage -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_HDF5=OFF
$ make
```
Use the following as an example to compile statically and using specific hdf5 folder
```
$ HDF5_ROOT=/opt/hdf5v1.10.0 cmake ../slsDetectorPackage -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_HDF5=ON
```
After compiling, the libraries and executables will be found at `bin` directory
```
$ ls bin/
gui_client libSlsDetector.a libSlsDetector.so libSlsReceiver.a libSlsReceiver.so
sls_detector_acquire sls_detector_get slsDetectorGui sls_detector_help sls_detector_put slsReceiver slsMultiReceiver
$ mkdir build
$ cd build
$ cmake ../slsDetectorPackage -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_SANITIZER=ON
$ make -j12 #or whatever number of threads wanted
```

View File

@ -0,0 +1,2 @@
Draft
- dr 4, 8, 16 in eiger -> speed 0, 32 stays same (speed 1)

View File

@ -0,0 +1,39 @@
# Find Clang format
if(NOT ClangFormat_BIN_NAME)
set(ClangFormat_BIN_NAME clang-format)
endif()
# if custom path check there first
if(ClangFormat_ROOT_DIR)
find_program(ClangFormat_BIN
NAMES
${ClangFormat_BIN_NAME}
PATHS
"${ClangFormat_ROOT_DIR}"
NO_DEFAULT_PATH)
endif()
find_program(ClangFormat_BIN NAMES ${ClangFormat_BIN_NAME})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
ClangFormat
DEFAULT_MSG
ClangFormat_BIN)
mark_as_advanced(
ClangFormat_BIN)
if(ClangFormat_FOUND)
exec_program(${ClangFormat_BIN} ${CMAKE_CURRENT_SOURCE_DIR} ARGS --version OUTPUT_VARIABLE CLANG_VERSION_TEXT)
string(REGEX MATCH "([0-9]+)\\.[0-9]+\\.[0-9]+" CLANG_VERSION ${CLANG_VERSION_TEXT})
if((${CLANG_VERSION} GREATER "9") OR (${CLANG_VERSION} EQUAL "9"))
# A CMake script to find all source files and setup clang-format targets for them
message(STATUS "found clang-format \"${CLANG_VERSION}\" adding formatting targets")
include(clang-format)
else()
message(STATUS "clang-format version \"${CLANG_VERSION}\" found but need at least 9. Not setting up format targets")
endif()
else()
message(STATUS "clang-format not found. Not setting up format targets")
endif()

47
cmake/clang-format.cmake Normal file
View File

@ -0,0 +1,47 @@
# A CMake script to find all source files and setup clang-format targets for them
# Find all source files
set(ClangFormat_CXX_FILE_EXTENSIONS ${ClangFormat_CXX_FILE_EXTENSIONS} *.cpp *.h *.cxx *.hxx *.hpp *.cc *.ipp *.c)
file(GLOB_RECURSE ALL_SOURCE_FILES ${ClangFormat_CXX_FILE_EXTENSIONS})
# Don't include some common build folders
set(ClangFormat_EXCLUDE_PATTERNS ${ClangFormat_EXCLUDE_PATTERNS} "/CMakeFiles/" "cmake")
# get all project files file
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
foreach (EXCLUDE_PATTERN ${ClangFormat_EXCLUDE_PATTERNS})
string(FIND ${SOURCE_FILE} ${EXCLUDE_PATTERN} EXCLUDE_FOUND)
if (NOT ${EXCLUDE_FOUND} EQUAL -1)
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
endif ()
endforeach ()
endforeach ()
#target for formatting soruce files
add_custom_target(format
COMMENT "Running clang-format to change files"
COMMAND ${ClangFormat_BIN}
-style=file
-i
${ALL_SOURCE_FILES}
)
#target to check format on source files
add_custom_target(format-check
COMMENT "Checking clang-format changes"
# Use ! to negate the result for correct output
COMMAND !
${ClangFormat_BIN}
-style=file
-output-replacements-xml
${ALL_SOURCE_FILES}
| grep -q "replacement offset"
)
# debug to check which file will be formatted
add_custom_target(
listformatfiles
COMMAND
echo ${ALL_SOURCE_FILES}
)

View File

@ -15,17 +15,20 @@ configure_package_config_file(
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
COMPATIBILITY SameMajorVersion
)
install(FILES
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config-version.cmake"
COMPONENT devel
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME_LOWER})
DESTINATION ${CMAKE_INSTALL_DIR}
)
if (PROJECT_LIBRARIES OR PROJECT_STATIC_LIBRARIES)
install(
EXPORT "${TARGETS_EXPORT_NAME}"
FILE ${PROJECT_NAME_LOWER}-targets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME_LOWER})
DESTINATION ${CMAKE_INSTALL_DIR}
)
endif ()

23
cmk.sh
View File

@ -11,6 +11,7 @@ PYTHON=0
TESTS=0
SIMULATOR=0
CTBGUI=0
MANUALS=0
CLEAN=0
@ -19,7 +20,7 @@ CMAKE_PRE=""
CMAKE_POST=""
usage() { echo -e "
Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [-h] [-d <HDF5 directory>] [-j] <Number of threads>
Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [m] [-h] [-d <HDF5 directory>] [-j] <Number of threads>
-[no option]: only make
-c: Clean
-b: Builds/Rebuilds CMake files normal mode
@ -34,6 +35,7 @@ Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [-h] [-d <HDF5 directory>]
-j: Number of threads to compile through
-e: Debug mode
-i: Builds tests
-m: Manuals
Rebuild when you switch to a new build and compile in parallel:
./cmk.sh -bj5
@ -69,7 +71,7 @@ For rebuilding only certain sections
" ; exit 1; }
while getopts ":bpchd:j:trgeisu" opt ; do
while getopts ":bpchd:j:trgeisum" opt ; do
case $opt in
b)
echo "Building of CMake files Required"
@ -124,6 +126,10 @@ while getopts ":bpchd:j:trgeisu" opt ; do
echo "Compiling Options: Simulator"
SIMULATOR=1
;;
m)
echo "Compiling Manuals"
MANUALS=1
;;
u)
echo "Compiling Options: Chip Test Gui"
CTBGUI=1
@ -187,8 +193,8 @@ fi
#Debug
if [ $DEBUG -eq 1 ]; then
CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug "
# CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_SANITIZER=ON "
# CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug "
CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_SANITIZER=ON "
echo "Debug Option enabled"
fi
@ -198,6 +204,12 @@ if [ $SIMULATOR -eq 1 ]; then
echo "Simulator Option enabled"
fi
#Manuals
if [ $MANUALS -eq 1 ]; then
CMAKE_POST+=" -DSLS_BUILD_DOCS=ON "
echo "Manuals Option enabled"
fi
#Chip Test Gui
if [ $CTBGUI -eq 1 ]; then
CMAKE_POST+=" -DSLS_USE_CTBGUI=ON "
@ -251,6 +263,9 @@ else
make
fi
if [ $MANUALS -eq 1 ]; then
make docs
fi

View File

@ -1,3 +1,4 @@
mkdir build
mkdir install
cd build
@ -6,7 +7,7 @@ cmake .. \
-DCMAKE_INSTALL_PREFIX=install \
-DSLS_USE_TEXTCLIENT=ON \
-DSLS_USE_RECEIVER=ON \
-DSLS_USE_GUI=OFF \
-DSLS_USE_GUI=ON \
-DSLS_USE_TESTS=ON \
-DSLS_USE_PYTHON=OFF \
-DCMAKE_BUILD_TYPE=Release \

View File

@ -1,14 +1,4 @@
# mkdir $PREFIX/lib
# mkdir $PREFIX/include
# #Shared and static libraries
# cp build/bin/_sls_detector* $PREFIX/lib/.
# #Binaries
# cp -r build/bin/sls_detector $PREFIX/lib/.
echo "|<-------- starting python build"
cd python
${PYTHON} setup.py install
${PYTHON} setup.py install

View File

@ -0,0 +1,7 @@
python:
- 3.6
- 3.7
- 3.8
numpy:
- 1.17

View File

@ -0,0 +1,9 @@
mkdir $PREFIX/lib
mkdir $PREFIX/bin
mkdir $PREFIX/include
cp build/bin/ctbGui $PREFIX/bin/.
cp build/bin/libctbRootLib.so $PREFIX/lib/.

View File

@ -1,15 +1,3 @@
mkdir $PREFIX/lib
#Copy the GUI
mkdir $PREFIX/bin
mkdir $PREFIX/include
#No libs for gui?
#Binaries
cp build/bin/gui_client $PREFIX/bin/.
cp build/bin/slsDetectorGui $PREFIX/bin/.
#Which headers do we need for development??
# cp include/some_lib.h $PREFIX/include/.

View File

@ -5,18 +5,20 @@ mkdir $PREFIX/include
mkdir $PREFIX/include/slsDetectorPackage
#Shared and static libraries
cp build/bin/libSlsDetector.so $PREFIX/lib/.
cp build/bin/libSlsReceiver.so $PREFIX/lib/.
cp build/bin/libSlsSupport.so $PREFIX/lib/.
# cp build/bin/libSlsDetector.so $PREFIX/lib/.
# cp build/bin/libSlsReceiver.so $PREFIX/lib/.
# cp build/bin/libSlsSupport.so $PREFIX/lib/.
cp build/install/lib/* $PREFIX/lib/
#Binaries
cp build/bin/sls_detector_acquire $PREFIX/bin/.
cp build/bin/sls_detector_get $PREFIX/bin/.
cp build/bin/sls_detector_put $PREFIX/bin/.
cp build/bin/sls_detector_help $PREFIX/bin/.
cp build/bin/slsReceiver $PREFIX/bin/.
cp build/bin/slsMultiReceiver $PREFIX/bin/.
cp build/install/bin/sls_detector_acquire $PREFIX/bin/.
cp build/install/bin/sls_detector_get $PREFIX/bin/.
cp build/install/bin/sls_detector_put $PREFIX/bin/.
cp build/install/bin/sls_detector_help $PREFIX/bin/.
cp build/install/bin/slsReceiver $PREFIX/bin/.
cp build/install/bin/slsMultiReceiver $PREFIX/bin/.
#Which headers do we need for development??
cp build/install/include/* $PREFIX/include/slsDetectorPackage/
# cp include/some_lib.h $PREFIX/include/.
cp build/install/include/* $PREFIX/include/
cp -r build/install/share/ $PREFIX/share

View File

@ -1,13 +1,14 @@
package:
name: sls_detector_software
version: "developer"
version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
source:
- path: ..
build:
number: 1
number: 0
binary_relocation: True
rpaths:
- lib/
@ -16,10 +17,9 @@ requirements:
- {{ compiler('c') }}
- {{compiler('cxx')}}
- cmake
# - qwt 6.* #require qt5 investigate befor activating gui
# - qt=4.8.7=7
- zeromq=4.2.5=hfc679d8_5
- pyzmq
- qwt 6.*
- qt 4.8.*
- zeromq
- xorg-libx11
- xorg-libice
- xorg-libxext
@ -37,6 +37,7 @@ requirements:
host:
- libstdcxx-ng
- libgcc-ng
- zeromq
- xorg-libx11
- xorg-libice
- xorg-libxext
@ -46,75 +47,52 @@ requirements:
- xorg-libxfixes
run:
- zeromq
- libstdcxx-ng
- libgcc-ng
outputs:
- name: sls_detector_lib
- name: slsdetlib
script: copy_lib.sh
- name: sls_detector
requirements:
run:
- libstdcxx-ng
- libgcc-ng
- zeromq
- name: slsdet
script: build_pylib.sh
requirements:
build:
- python
- {{ compiler('c') }}
- {{compiler('cxx')}}
- python {{ python }}
- {{ pin_subpackage('slsdetlib', exact=True) }}
- setuptools
- sls_detector_lib
- pyzmq
- pybind11 2.2
host:
- python
- pybind11 2.2
- pyzmq
- sls_detector_lib
run:
- libstdcxx-ng
- libgcc-ng
run:
- python
- numpy
- sls_detector_lib=developer
- pyzmq
- libstdcxx-ng
- libgcc-ng
- {{ pin_subpackage('slsdetlib', exact=True) }}
test:
imports:
- sls_detector
- slsdet
# requirements:
# build:
# - {{ compiler('c') }}
# - {{compiler('cxx')}}
# - name: sls_detector_gui
# version: "refactor"
# script: copy_gui.sh
# requirements:
# build:
# - {{ compiler('c') }}
# - {{compiler('cxx')}}
# - cmake
# - qwt 6.*
# - qt=4.8.7=7
# - zeromq=4.2.5=hfc679d8_5
# - pyzmq
# - xorg-libx11
# - xorg-libice
# - xorg-libxext
# - xorg-libsm
# - xorg-libxau
# - xorg-libxrender
# - xorg-libxfixes
# - {{ cdt('mesa-libgl-devel') }} # [linux]
# - {{ cdt('mesa-libegl-devel') }} # [linux]
# - {{ cdt('mesa-dri-drivers') }} # [linux]
# - {{ cdt('libselinux') }} # [linux]
# - {{ cdt('libxdamage') }} # [linux]
# - {{ cdt('libxxf86vm') }} # [linux]
# run:
# - sls_detector_lib=refactor
# - qwt 6.*
# - qt=4.8.7=7
- name: slsdetgui
script: copy_gui.sh
requirements:
run:
- {{ pin_subpackage('slsdetlib', exact=True) }}
- qwt 6.*
- qt 4.8.*

View File

@ -71,6 +71,11 @@ target_link_libraries(ctbRootLib PUBLIC
${ROOT_EXE_LINKER_FLAGS}
)
set_target_properties(
ctbRootLib PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
target_link_libraries(ctbGui PUBLIC
slsDetectorShared
slsSupportLib
@ -80,4 +85,5 @@ target_link_libraries(ctbGui PUBLIC
set_target_properties(ctbGui PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)

View File

@ -29,9 +29,10 @@
#include "sls_detector_defs.h"
#include "ctbMain.h"
#include "moench03CtbData.h"
#include "moench03TCtbData.h"
#include "moench03T1CtbData.h"
//#include "moench03TCtbData.h"
//#include "moench03T1CtbData.h"
#include "moench03CommonMode.h"
#include "moench03T1ZmqDataNew.h"
#include "moench02CtbData.h"
//#include "jungfrau10ModuleData.h"
#include "moenchCommonMode.h"
@ -43,6 +44,9 @@
#include "moench04CtbZmq10GbData.h"
#include "deserializer.h"
#include "detectorData.h"
#include "imageZmq16bit.h"
#include "imageZmq32bit.h"
using namespace std;
@ -232,7 +236,10 @@ hframe=new TGHorizontalFrame(this, 800,50);
cbDetType->AddEntry("MOENCH02", MOENCH02);
cbDetType->AddEntry("MOENCH04", MOENCH04);
// cbDetType->AddEntry("JUNGFRAU1.0", 2);
//cbDetType->AddEntry("MOENCH03 T", iiii++);
cbDetType->AddEntry("MOENCH03",MOENCH03);
cbDetType->AddEntry("IMAGE32BIT",IMAGE32B);
cbDetType->AddEntry("IMAGE16BIT",IMAGE16B);
//cbDetType->AddEntry("MOENCH03", iiii++);
// cbDetType->AddEntry("MYTHEN3 0.1", MYTHEN301);
// cbDetType->AddEntry("ADCSAR2", ADCSAR2);
@ -271,7 +278,7 @@ hframe=new TGHorizontalFrame(this, 800,50);
cout << "off "<< endl;
// cout << "off "<< endl;
hframe=new TGHorizontalFrame(this, 800,50);
@ -290,8 +297,8 @@ hframe=new TGHorizontalFrame(this, 800,50);
TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax,0,16535);
hframe->AddFrame(eSerOff,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
eSerOff->MapWindow();;
eSerOff->SetNumber(5);
eSerOff->MapWindow();
eSerOff->SetNumber(0);
e= eSerOff->TGNumberEntry::GetNumberEntry();
eSerOff->Connect("ValueSet(Long_t)","ctbAcquisition",this,"ChangeSerialOffset(Long_t)");
e->Connect("ReturnPressed()","ctbAcquisition",this,"ChangeSerialOffset()");
@ -337,6 +344,53 @@ hframe=new TGHorizontalFrame(this, 800,50);
hframe=new TGHorizontalFrame(this, 800,50);
AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 10,10,10,10));
hframe->MapWindow();
label=new TGLabel(hframe,"Image Pixels");
hframe->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 5, 5, 5, 5));
label->MapWindow();
label->SetTextJustify(kTextLeft);
label=new TGLabel(hframe,"X: ");
hframe->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 5, 5, 5, 5));
label->MapWindow();
label->SetTextJustify(kTextRight);
ePixX=new TGNumberEntry(hframe, 0, 9,999, TGNumberFormat::kNESInteger,
TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax,0,16535);
hframe->AddFrame(ePixX,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
ePixX->MapWindow();
ePixX->SetNumber(400);
e= ePixX->TGNumberEntry::GetNumberEntry();
ePixX->Connect("ValueSet(Long_t)","ctbAcquisition",this,"ChangeImagePixels(Long_t)");
e->Connect("ReturnPressed()","ctbAcquisition",this,"ChangeImagePixels()");
label=new TGLabel(hframe,"Y: ");
hframe->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 5, 5, 5, 5));
label->MapWindow();
label->SetTextJustify(kTextRight);
ePixY=new TGNumberEntry(hframe, 0, 9,999, TGNumberFormat::kNESInteger,
TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax,0,16535);
hframe->AddFrame(ePixY,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
ePixY->MapWindow();
ePixY->SetNumber(400);
e= ePixY->TGNumberEntry::GetNumberEntry();
ePixY->Connect("ValueSet(Long_t)","ctbAcquisition",this,"ChangeImagePixels(Long_t)");
e->Connect("ReturnPressed()","ctbAcquisition",this,"ChangeImagePixels()");
hframe=new TGHorizontalFrame(this, 800,50);
@ -609,8 +663,10 @@ hframe=new TGHorizontalFrame(this, 800,50);
cout <<"Registering data callback" << endl;
try {
myDet->registerDataCallback(&dataCallback, (void*)this);
} CATCH_DISPLAY ("Could not get register call back.", "ctbAcquisition::ctbAcquisition")
} CATCH_DISPLAY ("Could not get register call back.", "ctbAcquisition::ctbAcquisition")
try {
myDet->setRxZmqDataStream(true);
} CATCH_DISPLAY ("Could not get set RxZmqDataStream.", "ctbAcquisition::ctbAcquisition")
cout <<"Done" << endl;
// mgAdcs=new TMultiGraph();
@ -832,7 +888,7 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
// cout <<"global plot is " << globalPlot << endl;
// cout << "*******************************************" <<endl;
// cout <<"------Plot: "<< index << " prog:" << data->progressIndex << " npoints:" << data->npoints << " npy: " << data->npy << " " << data->fileName << " bytes: " << data->databytes << " dr:"<< data->dynamicRange << " fi: " << data ->fileIndex << endl;
cout <<"------Plot: "<< index << " prog:" << data->progressIndex << " nx:" << data->nx << " ny: " << data->ny << " " << data->fileName << " bytes: " << data->databytes << " dr:"<< data->dynamicRange << " fi: " << data ->fileIndex << endl;
if (globalPlot || cbGetPedestal->IsOn()) {
//#ifdef TESTADC
// cout <<"------"<< index << " " << ip << " " << data->npoints << endl;
@ -859,6 +915,11 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
nx=eNumCount->GetIntNumber();
dr=eDynRange->GetIntNumber();
soff=eSerOff->GetIntNumber();
// cout <<"deserializer: " << endl;
// cout << "Number of chans:\t" << nx << endl;
// cout << "Serial Offset:\t" << soff << endl;
// cout << "Dynamic range:\t" << dr << endl;
}
i=0;
@ -923,7 +984,8 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
for (int y=0; y<ny; y++) {
ped=0;
aval=dataStructure->getValue(data->data,x,y);
//aval=dataStructure->getChannel(data->data,x,y);
cout << x << " " <<y << " "<< aval << endl;
if (cbGetPedestal->IsOn()) {
if (photonFinder) {
photonFinder->addToPedestal(aval,x,y);
@ -1094,8 +1156,20 @@ void ctbAcquisition::Draw(){
void ctbAcquisition::changePlot(){
if (rbPlotOff->IsOn()) {
adcPlot=0;
dbitPlot=0;
dbitPlot=0;
try {
myDet->registerDataCallback(nullptr, this);
} CATCH_DISPLAY ("Could not get unregister call back.", "ctbAcquisition::ctbAcquisition")
try {
myDet->setRxZmqDataStream(false);
} CATCH_DISPLAY ("Could not get unset RxZmqDataStream.", "ctbAcquisition::ctbAcquisition")
} else {
try {
myDet->registerDataCallback(&dataCallback, (void*)this);
} CATCH_DISPLAY ("Could not get register call back.", "ctbAcquisition::ctbAcquisition")
try {
myDet->setRxZmqDataStream(true);
} CATCH_DISPLAY ("Could not get set RxZmqDataStream.", "ctbAcquisition::ctbAcquisition")
adcPlot=0;
dbitPlot=0;
for (int ii=0; ii<NADCS; ii++)
@ -1200,6 +1274,9 @@ void ctbAcquisition::changeDetector(){
eNumCount->SetState(kFALSE);
eDynRange->SetState(kFALSE);
eSerOff->SetState(kFALSE);
ePixX->SetState(kFALSE);
ePixY->SetState(kFALSE);
deserializer=0;
if (rb2D->IsOn() ) {//|| rbScan->IsOn()
switch (cbDetType->GetSelected()) {
@ -1210,7 +1287,6 @@ void ctbAcquisition::changeDetector(){
// commonMode=new moench03CommonMode();
break;
case MOENCH04:
try {
auto retval = myDet->getTenGiga().tsquash("Different values");
if (retval) {
@ -1223,6 +1299,54 @@ void ctbAcquisition::changeDetector(){
cout << "MOENCH 0.4!" << endl;
commonMode=new moench03CommonMode();
break;
case MOENCH03:
//try {
// auto retval = myDet->getTenGiga().tsquash("Different values");
// if (retval) {
dataStructure=new moench03T1ZmqDataNew(nAnalogSamples);
// } else {
// dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples);
// }
//} CATCH_DISPLAY ("Could not get ten giga enable.", "ctbAcquisition::changeDetector")
cout << "MOENCH 0.3! USE JUNGFRAU MODULE!" << endl;
commonMode=new moench03CommonMode();
break;
case IMAGE32B:
//try {
// auto retval = myDet->getTenGiga().tsquash("Different values");
// if (retval) {
// if (deserializer) {
ePixX->SetState(kTRUE);
ePixY->SetState(kTRUE);
// }
dataStructure=new imageZmq32bit(ePixX->GetIntNumber(),ePixY->GetIntNumber());
// } else {
// dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples);
// }
//} CATCH_DISPLAY ("Could not get ten giga enable.", "ctbAcquisition::changeDetector")
cout << "Image 32bit, no channel shuffling" << endl;
commonMode=NULL;
break;
case IMAGE16B:
//try {
// auto retval = myDet->getTenGiga().tsquash("Different values");
// if (retval) {
// if (deserializer) {
ePixX->SetState(kTRUE);
ePixY->SetState(kTRUE);
// }
dataStructure=new imageZmq16bit(ePixX->GetIntNumber(),ePixY->GetIntNumber());
// } else {
// dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples);
// }
//} CATCH_DISPLAY ("Could not get ten giga enable.", "ctbAcquisition::changeDetector")
cout << "Image 16bit, no channel shuffling" << endl;
commonMode=NULL;
break;
// case 1:
// cout << "************** T!!!!!!!!!!" << endl;
@ -1286,6 +1410,7 @@ void ctbAcquisition::changeDetector(){
photonFinder=new singlePhotonDetector(dataStructure,csize,nsigma,1,cm); //sign is positive - should correct with ADC mask, no common mode
//photonFinder=new singlePhotonDetector(dataStructure,csize,nsigma,1,cm); //sign is positive - should correct with ADC mask, no common mode
dataStructure->getDetectorSize(nx,ny);
}
if (deserializer) {
ny=1;
@ -1511,20 +1636,23 @@ void ctbAcquisition::update() {
if (dataStructure) {
cout << cbDetType->GetSelected()<< endl;
if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){
cout << "settings deserialiation parameters for MYTHEN" << endl;
mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
eSerOff->SetNumber( ms->setSerialOffset(-1));
eDynRange->SetNumber( ms->setDynamicRange(-1));
eNumCount->SetNumber( ms->setNumberOfCounters(-1));
}
// if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){
// cout << "settings deserialiation parameters for MYTHEN" << endl;
// mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
// eSerOff->SetNumber( ms->setSerialOffset(-1));
// eDynRange->SetNumber( ms->setDynamicRange(-1));
// eNumCount->SetNumber( ms->setNumberOfCounters(-1));
// }
}
try {
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::update")
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
dBitOffset = 0;
} else {
try {
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::update")
}
try {
tenG = myDet->getTenGiga().tsquash("Different values");
} CATCH_DISPLAY ("Could not get ten giga enable", "ctbAcquisition::update")
@ -1610,9 +1738,13 @@ void ctbAcquisition::toggleAcquisition() {
setDigitalSamples(retval);
} CATCH_DISPLAY ("Could not get number of digital samples", "ctbAcquisition::toggleAcquisition")
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
dBitOffset = 0;
} else {
try {
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::toggleAcquisition")
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::toggleAcquisition")
}
try {
roMode = static_cast<int>(myDet->getReadoutMode().tsquash("Different values"));
@ -1849,14 +1981,18 @@ void ctbAcquisition::setDbitEnable(Int_t reg){
void ctbAcquisition::updateChans() {
// dbit list
try {
auto retval = myDet->getRxDbitList().tsquash("Different values");
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
dbitlist.clear();
if (!retval.empty()) {
for (const auto &value : retval)
dbitlist.push_back(value);
}
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbAcquisition::updateChans")
} else {
try {
auto retval = myDet->getRxDbitList().tsquash("Different values");
dbitlist.clear();
if (!retval.empty()) {
for (const auto &value : retval)
dbitlist.push_back(value);
}
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbAcquisition::updateChans")
}
// adc mask
try {
@ -1977,20 +2113,22 @@ void ctbAcquisition::ChangeNumberOfChannels(Long_t a){
void ctbAcquisition::ChangeSerialOffset(){
changeDetector();
// if (dataStructure) {
// // cout << cbDetType->GetSelected()<< endl;
// // if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302 ){
// // cout << "settings offsets for MYTHEN" << endl;
// // mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
// // ms->setSerialOffset(eSerOff->GetIntNumber());
// cout << cbDetType->GetSelected()<< endl;
// if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302 ){
// cout << "settings offsets for MYTHEN" << endl;
// mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
// ms->setSerialOffset(eSerOff->GetIntNumber());
// // }
// }
// }
};
void ctbAcquisition::ChangeDynamicRange(){
changeDetector();
// if (dataStructure) {
// cout << cbDetType->GetSelected()<< endl;
@ -2004,6 +2142,7 @@ void ctbAcquisition::ChangeDynamicRange(){
};
void ctbAcquisition::ChangeNumberOfChannels(){
changeDetector();
// if (dataStructure) {
// cout << cbDetType->GetSelected()<< endl;
// if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){
@ -2017,6 +2156,24 @@ void ctbAcquisition::ChangeNumberOfChannels(){
changePlot();
};
void ctbAcquisition::ChangeImagePixels(Long_t a){
ChangeImagePixels();
};
void ctbAcquisition::ChangeImagePixels(){
changeDetector();
// if (dataStructure) {
// cout << cbDetType->GetSelected()<< endl;
// if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){
// cout << "settings number of channels for MYTHEN" << endl;
// mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
// ms->setNumberOfCounters(eNumCount->GetIntNumber());
// }
// }
// if (deserializer)
// changePlot();
};
void ctbAcquisition::ChangeHistoLimitsPedSub(Long_t a){

View File

@ -42,7 +42,7 @@ using namespace std;
class ctbAcquisition : public TGGroupFrame {
enum {DESERIALIZER, MOENCH04, MOENCH02, ADCSAR2, MYTHEN301, MYTHEN302};
enum {DESERIALIZER, MOENCH04, MOENCH02, MOENCH03, IMAGE32B, IMAGE16B, ADCSAR2, MYTHEN301, MYTHEN302};
private:
@ -57,6 +57,9 @@ class ctbAcquisition : public TGGroupFrame {
TGNumberEntry *eNumCount;
TGNumberEntry *ePixX;
TGNumberEntry *ePixY;
TGNumberEntry *eFitADC;
TGNumberEntry *eBitPlot;
TGNumberEntry *eMinRaw;
@ -231,7 +234,8 @@ class ctbAcquisition : public TGGroupFrame {
void ChangeNumberOfChannels(Long_t);
void ChangeDynamicRange();
void ChangeDynamicRange(Long_t);
void ChangeImagePixels();
void ChangeImagePixels(Long_t);
void canvasClicked();
void FitADC();

View File

@ -108,15 +108,26 @@ string ctbDac::getLabel() {
}
int ctbDac::getMoenchDacId() {
slsDetectorDefs::dacIndex moenchDacIndices[8] = {slsDetectorDefs::VBP_COLBUF, slsDetectorDefs::VIPRE, slsDetectorDefs::VIN_CM, slsDetectorDefs::VB_SDA, slsDetectorDefs::VCASC_SFP, slsDetectorDefs::VOUT_CM, slsDetectorDefs::VIPRE_CDS, slsDetectorDefs::IBIAS_SFP};
if (id >= 8) {
return id;
}
return static_cast<int>(moenchDacIndices[id]);
}
void ctbDac::setValue(Long_t a) {setValue();}
void ctbDac::setValue() {
cout << "setting dac! "<< id << " value " << dacsEntry->GetIntNumber() << " units " << dacsUnit->IsOn() << endl;
try {
myDet->setDAC(static_cast<slsDetectorDefs::dacIndex>(id), dacsEntry->GetIntNumber(), dacsUnit->IsOn());
int sid = id;
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
sid = getMoenchDacId();
}
myDet->setDAC(static_cast<slsDetectorDefs::dacIndex>(sid), dacsEntry->GetIntNumber(), dacsUnit->IsOn());
} CATCH_DISPLAY ("Could not set dac " + to_string(id) + ".", "ctbDac::setValue")
getValue();
@ -128,7 +139,11 @@ void ctbDac::setOn(Bool_t b) {
setValue();
} else {
try {
myDet->setDAC(static_cast<slsDetectorDefs::dacIndex>(id), -100, false);
int sid = id;
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
sid = getMoenchDacId();
}
myDet->setDAC(static_cast<slsDetectorDefs::dacIndex>(sid), -100, false);
} CATCH_DISPLAY ("Could not power off dac " + to_string(id) + ".", "ctbDac::setOn")
}
getValue();
@ -136,7 +151,11 @@ void ctbDac::setOn(Bool_t b) {
int ctbDac::getValue() {
try {
int val = myDet->getDAC(static_cast<slsDetectorDefs::dacIndex>(id), dacsUnit->IsOn()).tsquash("Different values");
int sid = id;
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
sid = getMoenchDacId();
}
int val = myDet->getDAC(static_cast<slsDetectorDefs::dacIndex>(sid), dacsUnit->IsOn()).tsquash("Different values");
cout << "dac " << id << " " << val << endl;
dacsValue->SetText(to_string(val).c_str());
if (val >= 0) {

View File

@ -45,7 +45,7 @@ class ctbDac : public TGHorizontalFrame {
int setLabel(char *tit, int mv);
string getLabel();
int getMoenchDacId();
ClassDef(ctbDac,0)
@ -54,8 +54,6 @@ class ctbDac : public TGHorizontalFrame {
class ctbDacs : public TGGroupFrame {
private:
ctbDac *dacs[NDACS+2];
sls::Detector* myDet;

View File

@ -71,14 +71,14 @@ class ctbDefs {
std::string exceptionMessage,
std::string source) {
// because sls_detector_exceptions cannot be included
if (exceptionMessage.find("hared memory")) {
if (exceptionMessage.find("hared memory") != std::string::npos) {
throw;
}
if (exceptionMessage.find("annot connect")) {
if (exceptionMessage.find("annot connect") != std::string::npos) {
throw;
}
cprintf(RED, "Warning (%s): %s [Caught Exception: %s]\n", source.c_str(), message.c_str(), exceptionMessage.c_str());
//return Message(qDefs::WARNING, message + std::string("\nCaught exception:\n") + exceptionMessage, source);
};
};
};

View File

@ -259,8 +259,10 @@ ctbMain::ctbMain(const TGWindow *p, sls::Detector *det)
cout << "connect mtab" << endl;
setReadoutMode(pat->getReadoutMode());
try{
setReadoutMode(pat->getReadoutMode());
} CATCH_DISPLAY ("Could not get readout flags", "ctbPattern::getReadoutMode")
setADCEnable(adcs->setEnable());
setAnalogSamples(pat->getAnalogSamples());
setDigitalSamples(pat->getDigitalSamples());

View File

@ -1035,33 +1035,42 @@ void ctbPattern::readoutModeChanged(int flags) {
}
int ctbPattern::getReadoutMode() {
try{
auto retval = myDet->getReadoutMode().tsquash("Different values");
switch(retval) {
case slsDetectorDefs::ANALOG_AND_DIGITAL:
cout << "analog and digital" << endl;
cbAnalog->SetOn(kTRUE);
cbDigital->SetOn(kTRUE);
break;
case slsDetectorDefs::DIGITAL_ONLY:
cout << "digital only" << endl;
cbAnalog->SetOn(kFALSE);
cbDigital->SetOn(kTRUE);
break;
case slsDetectorDefs::ANALOG_ONLY:
cout << "analog only" << endl;
cbAnalog->SetOn(kTRUE);
cbDigital->SetOn(kFALSE);
break;
default:
throw("unknown readout flag");
}
int ctbPattern::getReadoutMode() {
int retval=slsDetectorDefs::ANALOG_ONLY;
if (myDet->getDetectorType().squash() == slsDetectorDefs::CHIPTESTBOARD) {
try{
retval = myDet->getReadoutMode().tsquash("Different values");
} CATCH_DISPLAY ("Could not get readout flags", "ctbPattern::getReadoutMode")
switch(retval) {
case slsDetectorDefs::ANALOG_AND_DIGITAL:
cout << "analog and digital" << endl;
cbAnalog->SetOn(kTRUE);
cbDigital->SetOn(kTRUE);
break;
case slsDetectorDefs::DIGITAL_ONLY:
cout << "digital only" << endl;
cbAnalog->SetOn(kFALSE);
cbDigital->SetOn(kTRUE);
break;
case slsDetectorDefs::ANALOG_ONLY:
cout << "analog only" << endl;
cbAnalog->SetOn(kTRUE);
cbDigital->SetOn(kFALSE);
break;
default:
throw("unknown readout flag");
}
} else {
cbAnalog->SetOn(kTRUE);
cbDigital->SetOn(kFALSE);
}
Emit("readoutModeChanged(int)",static_cast<int>(retval));
return retval;
} CATCH_DISPLAY ("Could not get readout flags", "ctbPattern::getReadoutMode")
return -1;
}
int ctbPattern::getAnalogSamples() {
@ -1075,13 +1084,17 @@ int ctbPattern::getAnalogSamples() {
return -1;
}
int ctbPattern::getDigitalSamples() {
try{
auto retval = myDet->getNumberOfDigitalSamples().tsquash("Different values");
eDigitalSamples->SetNumber((Double_t)retval);
Emit("digitalSamplesChanged(const int)", eDigitalSamples->GetNumber());
return eDigitalSamples->GetNumber();
} CATCH_DISPLAY ("Could not get number of triggers.", "ctbPattern::update")
int ctbPattern::getDigitalSamples() {
int retval=0;
if (myDet->getDetectorType().squash() == slsDetectorDefs::CHIPTESTBOARD) {
try{
auto retval = myDet->getNumberOfDigitalSamples().tsquash("Different values");
} CATCH_DISPLAY ("Could not get number of digital samples.", "ctbPattern::getDigitalSamples")
}
eDigitalSamples->SetNumber((Double_t)retval);
Emit("digitalSamplesChanged(const int)", eDigitalSamples->GetNumber());
return eDigitalSamples->GetNumber();
return -1;
}

View File

@ -374,33 +374,43 @@ void ctbSignals::update() {
} CATCH_DISPLAY ("Could not get patternIOcontrol.", "ctbSignals::update")
try {
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
// enable all
if (dbitlist.empty()) {
for (int is=0; is<64; is++) {
signals[is]->setDbitList(1);
}
}
else {
// disable all
for (int is=0; is<64; is++) {
signals[is]->setDbitList(0);
for (int is=0; is<64; is++) {
signals[is]->setDbitList(1);
}
eDbitOffset->SetNumber(0);
}
// ctb
else {
try {
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
// enable all
if (dbitlist.empty()) {
for (int is=0; is<64; is++) {
signals[is]->setDbitList(1);
}
}
// enable selected
for (const auto &value : dbitlist) {
signals[value]->setDbitList(1);
else {
// disable all
for (int is=0; is<64; is++) {
signals[is]->setDbitList(0);
}
// enable selected
for (const auto &value : dbitlist) {
signals[value]->setDbitList(1);
}
}
}
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbSignals::update")
try {
auto val = myDet->getRxDbitOffset().tsquash("Different values");
eDbitOffset->SetNumber(val);
} CATCH_DISPLAY ("Could not get receiver dbit offset.", "ctbSignals::update")
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbSignals::update")
try {
auto val = myDet->getRxDbitOffset().tsquash("Different values");
eDbitOffset->SetNumber(val);
} CATCH_DISPLAY ("Could not get receiver dbit offset.", "ctbSignals::update")
}
}

View File

@ -21,6 +21,7 @@ if [ -f "$infile" ]
then
gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ;
echo compiling
echo gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ;
$exe ;
echo cleaning
rm $exe

View File

@ -1,69 +1,69 @@
find_package(Doxygen)
find_package(Sphinx)
find_package(Doxygen REQUIRED)
find_package(Sphinx REQUIRED)
if (DOXYGEN_FOUND AND SPHINX_FOUND)
message(${CMAKE_PROJECT_SORURCE_DIR}/slsDetectorSoftware/src)
# Utility to generate command line documentation
add_executable(gendoc src/gendoc.cpp)
# This is a bit hacky, but better than exposing stuff?
target_include_directories(gendoc PRIVATE ${PROJECT_SOURCE_DIR}/slsDetectorSoftware/src)
target_link_libraries(gendoc PRIVATE
slsDetectorShared
)
set_target_properties(gendoc PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
#Doxygen
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
# Utility to generate command line documentation
add_executable(gendoc src/gendoc.cpp)
# This is a bit hacky, but better than exposing stuff?
target_include_directories(gendoc PRIVATE ${PROJECT_SOURCE_DIR}/slsDetectorSoftware/src)
target_link_libraries(gendoc PRIVATE
slsDetectorShared
)
set_target_properties(gendoc PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
#Sphinx
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR})
set(SPHINX_SOURCE_FILES
src/commandline.rst
src/container_utils.rst
src/dependencies.rst
src/detector.rst
src/index.rst
src/installation.rst
src/pydetector.rst
src/pyenums.rst
src/pyexamples.rst
src/receiver.rst
src/result.rst
src/type_traits.rst
src/ToString.rst
)
foreach(filename ${SPHINX_SOURCE_FILES})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${filename}
"${SPHINX_BUILD}/${filename}")
endforeach(filename ${SPHINX_SOURCE_FILES})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
"${SPHINX_BUILD}/conf.py"
@ONLY)
#Doxygen
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
#Sphinx
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR})
set(SPHINX_SOURCE_FILES
src/commandline.rst
src/container_utils.rst
src/consuming.rst
src/dependencies.rst
src/detector.rst
src/index.rst
src/installation.rst
src/pydetector.rst
src/pyenums.rst
src/pyexamples.rst
src/receiver.rst
src/result.rst
src/type_traits.rst
src/ToString.rst
src/examples.rst
)
foreach(filename ${SPHINX_SOURCE_FILES})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${filename}
"${SPHINX_BUILD}/${filename}")
endforeach(filename ${SPHINX_SOURCE_FILES})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
"${SPHINX_BUILD}/conf.py"
@ONLY)
add_custom_target(docs
gendoc
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
COMMAND ${SPHINX_EXECUTABLE} -a -b html
-Dbreathe_projects.slsDetectorPackage=${CMAKE_CURRENT_BINARY_DIR}/xml
-c "${SPHINX_BUILD}"
${SPHINX_BUILD}/src
${SPHINX_BUILD}/html
COMMENT "Generating documentation with Sphinx")
add_custom_target(docs
gendoc
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
COMMAND ${SPHINX_EXECUTABLE} -a -b html
-Dbreathe_projects.slsDetectorPackage=${CMAKE_CURRENT_BINARY_DIR}/xml
-c "${SPHINX_BUILD}"
${SPHINX_BUILD}/src
${SPHINX_BUILD}/html
COMMENT "Generating documentation with Sphinx")
else (DOXYGEN_FOUND AND SPHINX_FOUND)
message("Doxygen and Sphinx are needed to build documentation")
endif (DOXYGEN_FOUND AND SPHINX_FOUND)

116
docs/src/consuming.rst Normal file
View File

@ -0,0 +1,116 @@
Consuming slsDetectorPackage
===============================
Depending on how you want to build your integration with
slsDetectorPackage there are a few different ways to
consume our package. The recommended way is to use one of the
CMake approaches.
CMake: slsDetectorPackage as submodule in your project
---------------------------------------
If you are using CMake to build your integration and want to build everything
in one go, we support adding slsDetectorPackage as a subfolder in your cmake project.
A minimal CMakeLists.txt could look like this:
.. code-block:: cmake
project(myDetectorIntegration)
cmake_minimum_required(VERSION 3.12)
add_subdirectory(slsDetectorPackage)
#Add your executable
add_executable(example main.cpp)
target_compile_features(example PRIVATE cxx_std_11)
#Link towards slsDetectorShared
target_link_libraries(example slsDetectorShared)
A fully working example can be found at:
https://github.com/slsdetectorgroup/cmake-subfolder-example
CMake: find_package(slsDetectorPackage)
------------------------------------------
If you have compiled and installed slsDetectorPackage we also support
find_package in CMake. If installed in a system wide location no path
should be needed, otherwise specify cmake prefix path.
.. code-block:: cmake
cmake_minimum_required(VERSION 3.12)
project(myintegration)
find_package(slsDetectorPackage 5.0 REQUIRED)
add_executable(example main.cpp)
target_link_libraries(example slsDetectorShared)
Then assuming the slsDetectorPackage is installed in /path/to/sls/install
you should be able to configure and build your project in this way.
.. code-block:: bash
cmake ../path/to/your/source -DCMAKE_PREFIX_PATH=/path/to/sls/install
make
A minimal example is available at: https://github.com/slsdetectorgroup/minimal-cmake
CMake: find_package and conda
----------------------------------
.. note::
conda can also be used for installing dependencies such as zmq, Qt4 etc.
find_package(slsDetectorPackage) also works if you have installed slsDetectorPackage using conda.
The only difference is that you point CMake to $CONDA_PREFIX
.. code-block:: bash
#assuming myenv contains slsdetlib
conda activate myenv
cmake ../path/to/your/source -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
make
Depending on your system compiler you might also have to install gxx_linux-64 to compiled.
No tools minimal approach
-----------------------------
While not recommended it is still possible to specify the include and library paths
manually when invoking g++. This can sometimes be handy for a quick try.
.. code-block:: cpp
#include "Detector.h"
#include <iostream>
int main(){
sls::Detector det;
//Get all values and print them
std::cout << "Hostname: " << det.getHostname() << "\n";
std::cout << "Type: " << det.getDetectorType() << "\n";
std::cout << "Udp ip: " << det.getSourceUDPIP() << "\n";
//Get mac addr
const int module = 0;
auto mac = det.getSourceUDPMAC()[module];
std::cout << "Mac addr of module "<< module << " is " << mac.str() << '\n';
}
.. code-block:: bash
g++ -I/install/path/include/ -L/install/path/lib64/ myapp.cpp -lSlsDetector -lSlsSupport -Wl,-rpath=../install/path/lib64

View File

@ -13,7 +13,7 @@ To use the basic building blocks, meaning sls_detector_get/put and
the shared libraries these are needed:
* Linux, preferably recent kernel (currently no cross platform support)
* CMake > 3.9
* CMake > 3.12
* C++11 compatible compiler. (We test with gcc and clang)
* ZeroMQ version 4
@ -24,7 +24,7 @@ GUI
The GUI is currently using Qt4 but watch out for an upgrade to 5.
* Qt 4.8
* Qwt 6
* Qwt 6.1
-----------------------
Python bindings

115
docs/src/examples.rst Normal file
View File

@ -0,0 +1,115 @@
Examples
===========
Setup
------------
The examples here assume that you have compiled and installed slsDetectorPackage
to ~/sls/install and that the option for SLS_USE_SIMULATOR was enabled. This also builds
the virtual detector servers that we will be using for testing.
We also add ~/sls/detector/install/bin to the path for convenience.
Compile examples
-------------------
The source code of the examples is available at:
https://github.com/slsdetectorgroup/api-examples
.. code-block:: bash
git clone https://github.com/slsdetectorgroup/api-examples.git
mkdir build && cd build
cmake ../api-examples -DCMAKE_PREFIX_PATH=~/sls/detector/install
make
Below follows a short description of what is included in the examples.
Running a config file [e1]
-----------------------------
.. code-block:: cpp
#include "Detector.h"
...
sls::Detector det;
det.loadConfig("path/to/config/file.config");
To configure the connection between PC and detector the easiest
is to run a config file. For this example we first launch a virtual Jungfrau server and
then set up the detector.
**Launch a virtual detector server**
.. code-block:: bash
jungfrauDetectorServer_virtual
This launches a virtual Jungfrau detector server. As default is uses port 1952 and 1953
for communication over TCP. Most commands go on 1952 and only stop and status on 1953.
**Run example to configure**
.. code-block:: bash
./e1-config one_det_no_receiver.config
- 12:01:06.371 INFO: Shared memory deleted /slsDetectorPackage_multi_0_sls_0
- 12:01:06.371 INFO: Shared memory deleted /slsDetectorPackage_multi_0
- 12:01:06.372 INFO: Shared memory created /slsDetectorPackage_multi_0
- 12:01:06.376 INFO: Loading configuration file: one_det_no_receiver.config
- 12:01:06.376 INFO: Adding detector localhost
- 12:01:06.377 INFO: Shared memory created /slsDetectorPackage_multi_0_sls_0
- 12:01:06.377 INFO: Checking Detector Version Compatibility
- 12:01:06.378 INFO: Detector connecting - updating!
hostname [localhost]
Jungfrau detector with 1 modules configured
Using the return type sls::Result [e2]
-----------------------------------------
Since many our detectors have multiple modules we cannot return
a single value when reading from the Detector. Hostname, Ip and also
for example exposure time can differ between modules.
Therefore we return Result<T> which is a thin wrapper around
std::vector.
.. code-block:: cpp
sls::Result<int> res1{1, 1, 1};
std::cout << "res1: " << res1 << '\n';
res1.squash();
res1.squash(-1);
Setting exposure time [e3]
-----------------------------------------
For setting times, like exposure time, period, delay etc.
we use std::chrono::duration.
Example 3 shows how to set and read exposure time as well
as converting to floating point.
.. code-block:: cpp
#include "Detector.h"
#include <chrono>
...
std::chrono::microseconds t0{500};
det.setExptime(t0);

View File

@ -1,7 +1,7 @@
/**
* Utility program to generate input files for the command line
/**
* Utility program to generate input files for the command line
* documentation. Uses the string returned from sls_detector_help cmd
*
*
*/
#include <fstream>
#include <iostream>
@ -9,7 +9,6 @@
#include <string>
#include <vector>
#include "CmdProxy.h"
#include "Detector.h"
#include "sls_detector_defs.h"
@ -52,5 +51,4 @@ int main() {
auto help = replace_all(tmp, "\n\t", "\n\t\t");
fs << '\t' << cmd << usage << help << "\n";
}
}

View File

@ -6,12 +6,18 @@
Welcome to slsDetectorPackage's documentation!
==============================================
.. note ::
This is the documentation for the latest development version of slsDetectorPackage
For documentation on current and previous releases visit the official page: https://www.psi.ch/en/detectors/documentation
.. toctree::
:maxdepth: 1
:caption: Installation:
installation
dependencies
consuming
.. toctree::
:caption: C++ API
@ -20,6 +26,7 @@ Welcome to slsDetectorPackage's documentation!
detector
result
receiver
examples
.. toctree::
:caption: Python API

View File

@ -2,4 +2,68 @@
Installation
==============================================
get the source etc.
Build from source using CMake
---------------------------------
.. note ::
The default branch of our git repository is developer. It contains the
latest development version. It is expected to compile and work but
features might be added or tweaked. In some cases the API might also change
without being communicated. If absolute stability of the API is needed please
use one of the release versions.
.. code-block:: bash
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git
mkdir build && cd build
cmake ../slsDetectorPackage -DCMAKE_INSTALL_PREFIX=/your/install/path
make -j12
make install
Install binaries using conda
--------------------------------
.. code-block:: bash
#Add channels for dependencies and our library
conda config --add channels conda-forge
conda config --add channels slsdetectorgroup
conda config --set channel_priority strict
#cerate an environment with our library, then activate
conda create -n myenv slsdetlib=2020.03.18.dev2
codna activate myenv
#ready to use
sls_detector_get exptime
etc ...
Build from source on old distributions
-----------------------------------------
If your linux distribution doesn't come with a C++11 compiler (gcc>4.8) then
it's possible to install a newer gcc using conda and build the slsDetectorPackage
using this compiler
.. code-block:: bash
#Create an environment with the dependencies
conda create -n myenv gxx_linux-64 cmake zmq
conda activate myenv
cmake ../slsDetectorPackage -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
make -j12
Build this documentation
-------------------------------
The documentation for the slsDetectorPackage is build using a combination
of Doxygen, Sphinx and Breathe. The easiest way to install the dependencies
is to use conda
.. code-block:: bash
conda create -n myenv python sphinx sphinx_rtd_theme

View File

@ -1,9 +1,9 @@
Detector
=====================================================
.. py:currentmodule:: sls_detector
.. py:currentmodule:: slsdet
.. autoclass:: ExperimentalDetector
.. autoclass:: Detector
:members:
:undoc-members:
:show-inheritance:

View File

@ -12,7 +12,7 @@ file writing etc.
.. code-block:: python
from sls_detector import Eiger
from slsdet import Eiger
d = Eiger()
threshold = range(0, 2000, 200)

View File

@ -0,0 +1,29 @@
hostname strip3
udp_srcip 10.1.1.184
udp_dstip 10.1.1.107
udp_dstport2 50084
udp_srcip2 10.1.1.185
udp_dstip2 10.1.1.107
rx_hostname pc12365:1954
#udp_dstmac 3c:fd:fe:d2:a4:25
fpath /tmp
fname run
fwrite 0
bursts 10
frames 2700
burstperiod 100ms
numinterfaces 2
veto 1
#fixing data looks
# Sampling pipeline 1 clk
reg 0x120 0x00000010
clkphase 1 135 deg

View File

@ -1,4 +1,14 @@
hostname bchip085+
initialchecks 0
#############################################
### edit with hostname or IP address of your detector
############################################
hostname bchip181+
runclk 40
adcclk 20
dbitclk 40
patword 0000 0000000000000000
patword 0001 0000000000000000
@ -408,84 +418,84 @@ patnloop1 0
patloop2 0400 0400
patnloop2 0
patwait0 00aa
patwaittime0 40000
patwaittime0 10000
patwait1 0400
patwaittime1 0
patwait2 0400
patwaittime2 0
####mcp2011
#0:rx_udpip 10.1.1.102
#0:detectorip 10.1.1.19
#0:rx_udpport 32410
####gui listening to
#zmqip 129.129.202.131
#zmqport 30001
####data streaming out of
#rx_zmqip 10.1.2.103
#rx_zmqport 30003
#0:rx_hostname mpc2011
#0:rx_tcpport 1977
####mx-test-1
0:rx_udpip 10.1.1.100
0:detectorip 10.1.1.19
0:rx_udpport 32410
####gui listening to (on receiver pc)
zmqip 129.129.202.92
zmqport 30001
####data streaming out of
rx_zmqip 10.1.1.100
rx_zmqport 30003
0:rx_hostname pcmoench01
#############################################
### edit with 10 Gbs IP of your server
############################################
0:udp_dstip 10.1.1.102
#0:udp_dstip 129.129.202.136
#############################################
### edit with any number in the subnet of your server (first 3 numbers as above)
############################################
0:udp_srcip 10.1.1.19
#0:udp_srcip 129.129.202.13
0:udp_dstport 33410
#############################################
### edit with 10 Gbs IP of your server
############################################
#zmqip 129.129.202.110
#rx_zmqip 10.1.1.102
#rx_zmqport 30001
#############################################
### edit with 1 Gbs IP of PC where you will run the GUI
############################################
#zmqip 129.129.202.110
#zmqport 50001
#############################################
### edit with hostname or 1Gbs IP address of your server
############################################
rx_hostname mpc2011
tengiga 1
#turn on datastream from commandline
rx_datastream 1
r_readfreq 1
#0:configuremac -1
rx_datastream 1
r_readfreq 1
rx_readfreq 1
dac:6 800
dac:0 1300
dac:4 1428
dac:1 1000
dac:7 900
dac:3 680
dac:2 1400
dac:5 1200
dac 6 800
dac 0 1300
dac 4 1428
dac 1 1000
dac 7 900
dac 3 680
dac 2 1400
dac 5 1200
adcinvert 4a342593
samples 5000
adcphase 90
adcpipeline 15
#0xb5cbda6c
asamples 5000
dsamples 0
adcphase 30 deg
adcpipeline 14
adcreg 14 40
powerchip 1
frames 1000
period 0.001
#############################################
### edit with directory you want to write to
############################################
fpath /tmp/
fwrite 0
romode analog
#rx_jsonaddheader frameMode
rx_jsonpara frameMode newpedestal
#rx_jsonaddheader detectorMode
rx_jsonpara detectorMode analog
#flags newpedestal
#flags analog
reg 0x5e 0x00010000
#powerchip 1
vhighvoltage 90
period 0.005
frames 100
period 0.1
outdir /scratch/
enablefwrite 0

View File

@ -0,0 +1,63 @@
initialchecks 0
#############################################
### edit with hostname or IP address of your detector
############################################
hostname bchip181+
#############################################
### edit with hostname or 1Gbs IP address of your server
############################################
rx_hostname mpc2011
rx_tcpport 1954
#############################################
### edit with 10 Gbs IP of your server
############################################
udp_dstip 10.1.1.102
#############################################
### edit with any number in the subnet of your server (first 3 numbers as above)
############################################
udp_srcip 10.1.1.19
udp_dstport 32411
#############################################
### edit with 10 Gbs IP of your server
############################################
rx_zmqip 10.1.1.102
rx_zmqport 50003
#############################################
### edit with 1 Gbs IP of PC where you will run the GUI
############################################
zmqip 129.129.202.136
zmqport 50001
tengiga 1
rx_datastream 1
frames 100000
period 0.0006
#############################################
### edit with directory you want to write to
############################################
fpath /mnt/moench_data/scratch/
fwrite 0
rx_datastream 1
rx_jsonpara frameMode frame
rx_jsonpara detectorMode counting
rx_discardpolicy discardpartial
adcpipeline 15
powerchip 1
vhighvoltage 90
#adcreg 0x14 0x40

View File

@ -1,12 +1,12 @@
#include "DetectorImpl.h"
#include "catch.hpp"
#include "multiSlsDetector.h"
#include "string_utils.h"
#include "tests/globals.h"
#include <iostream>
class MultiDetectorFixture {
protected:
multiSlsDetector d;
DetectorImpl d;
public:
MultiDetectorFixture() : d(0, true, true) {

90
integrationTests/test-integrationDectector.cpp Executable file → Normal file
View File

@ -2,9 +2,9 @@
#include "catch.hpp"
#include "ClientSocket.h"
#include "DetectorImpl.h"
#include "Module.h"
#include "logger.h"
#include "multiSlsDetector.h"
#include "slsDetector.h"
#include "sls_detector_defs.h"
#include "Timer.h"
@ -23,10 +23,10 @@
// extern dt type;
TEST_CASE("Single detector no receiver", "[.integration][.single]") {
auto t = slsDetector::getTypeFromDetector(test::hostname);
auto t = Module::getTypeFromDetector(test::hostname);
CHECK(t == test::type);
slsDetector d(t);
Module d(t);
CHECK(d.getDetectorTypeAsEnum() == t);
CHECK(d.getDetectorTypeAsString() == test::detector_type);
@ -51,7 +51,7 @@ TEST_CASE("Set control port then create a new object with this control port",
int new_cport = 1993;
int new_sport = 2000;
{
slsDetector d(test::type);
Module d(test::type);
d.setHostname(test::hostname);
CHECK(d.getControlPort() == old_cport);
d.setControlPort(new_cport);
@ -60,7 +60,7 @@ TEST_CASE("Set control port then create a new object with this control port",
d.freeSharedMemory();
}
{
slsDetector d(test::type);
Module d(test::type);
d.setHostname(test::hostname);
d.setControlPort(new_cport);
d.setStopPort(new_sport);
@ -73,24 +73,23 @@ TEST_CASE("Set control port then create a new object with this control port",
d.freeSharedMemory();
}
slsDetector d(test::type);
Module d(test::type);
d.setHostname(test::hostname);
CHECK(d.getStopPort() == DEFAULT_PORTNO + 1);
d.freeSharedMemory();
}
TEST_CASE("single EIGER detector no receiver basic set and get",
"[.integration][eiger]") {
// TODO! this test should take command line arguments for config
SingleDetectorConfig c;
// Read type by connecting to the detector
auto type = slsDetector::getTypeFromDetector(c.hostname);
auto type = Module::getTypeFromDetector(c.hostname);
CHECK(type == c.type_enum);
// Create slsDetector of said type and set hostname and detector online
slsDetector d(type);
// Create Module of said type and set hostname and detector online
Module d(type);
CHECK(d.getDetectorTypeAsEnum() == type);
CHECK(d.getDetectorTypeAsString() == c.type_string);
@ -130,10 +129,8 @@ TEST_CASE("single EIGER detector no receiver basic set and get",
d.freeSharedMemory();
}
TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
slsDetector d(test::type);
Module d(test::type);
d.setHostname(test::hostname);
// Check that detector server is unlocked then lock
@ -154,13 +151,12 @@ TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
d.freeSharedMemory();
}
TEST_CASE("Set settings", "[.integration][.single]"){
slsDetector d(test::type);
TEST_CASE("Set settings", "[.integration][.single]") {
Module d(test::type);
d.setHostname(test::hostname);
CHECK(d.setSettings(defs::STANDARD) == defs::STANDARD);
}
TEST_CASE("Timer functions", "[.integration][cli]") {
// FRAME_NUMBER, /**< number of real time frames: total number of
// acquisitions is number or frames*number of triggers */ ACQUISITION_TIME,
@ -185,7 +181,7 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
// MEASURED_SUBPERIOD, /**< measured subperiod */
// MAX_TIMERS
slsDetector d(test::type);
Module d(test::type);
d.setHostname(test::hostname);
// Number of frames
@ -204,8 +200,7 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
if (test::type != dt::EIGER) {
auto delay = 10000;
d.setDelayAfterTrigger(delay);
CHECK(d.getDelayAfterTrigger() ==
delay);
CHECK(d.getDelayAfterTrigger() == delay);
}
auto triggers = 2;
@ -218,16 +213,15 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
CHECK(d.getSubExptime() == subtime);
}
// for (int i =0; i!=frames; ++i)
d.startAndReadAll();
d.startAndReadAll();
d.freeSharedMemory();
}
// TEST_CASE("Aquire", "[.integration][eiger]"){
// SingleDetectorConfig c;
// auto type = slsDetector::getTypeFromDetector(c.hostname);
// slsDetector d(type);
// auto type = Module::getTypeFromDetector(c.hostname);
// Module d(type);
// d.setHostname(c.hostname);
// auto period = 1000000000;
@ -252,7 +246,7 @@ TEST_CASE(
int ratecorr = 125;
// pick up multi detector from shm id 0
multiSlsDetector m(0);
DetectorImpl m(0);
// ensure eiger detector type, hostname and online
REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum);
@ -302,7 +296,7 @@ TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
SingleDetectorConfig c;
// pick up multi detector from shm id 0
multiSlsDetector m(0);
DetectorImpl m(0);
// ensure ctb detector type, hostname and online
REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum);
@ -382,12 +376,12 @@ TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
}
}
TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegration][dbit]") {
TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert",
"[.ctbintegration][dbit]") {
SingleDetectorConfig c;
// pick up multi detector from shm id 0
multiSlsDetector m(0);
DetectorImpl m(0);
// ensure ctb detector type, hostname and online
REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum);
@ -403,27 +397,27 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
// dbit list
std::vector <int> list = m.getReceiverDbitList();
std::vector<int> list = m.getReceiverDbitList();
list.clear();
for (int i = 0; i < 10; ++i)
list.push_back(i);
m.setReceiverDbitList(list);
CHECK(m.getReceiverDbitList().size() == 10);
list.push_back(64);
CHECK_THROWS_AS(m.setReceiverDbitList(list), sls::RuntimeError);
CHECK_THROWS_WITH(m.setReceiverDbitList(list),
Catch::Matchers::Contains("be between 0 and 63"));
CHECK_THROWS_WITH(m.setReceiverDbitList(list),
Catch::Matchers::Contains("be between 0 and 63"));
list.clear();
for (int i = 0; i < 65; ++i)
list.push_back(i);
CHECK(list.size() == 65);
CHECK_THROWS_WITH(m.setReceiverDbitList(list),
Catch::Matchers::Contains("be greater than 64"));
CHECK_THROWS_WITH(m.setReceiverDbitList(list),
Catch::Matchers::Contains("be greater than 64"));
list.clear();
list.clear();
m.setReceiverDbitList(list);
CHECK(m.getReceiverDbitList().empty());
@ -441,8 +435,8 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
m.setExternalSamplingSource(62);
CHECK(m.getExternalSamplingSource() == 62);
CHECK_THROWS_WITH(m.setExternalSamplingSource(64),
Catch::Matchers::Contains("be 0-63"));
CHECK(m.getExternalSamplingSource() == 62);
Catch::Matchers::Contains("be 0-63"));
CHECK(m.getExternalSamplingSource() == 62);
m.setExternalSampling(1);
CHECK(m.getExternalSampling() == 1);
m.setExternalSampling(0);
@ -450,20 +444,23 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
m.setExternalSampling(1);
CHECK(m.getExternalSampling() == 1);
CHECK(m.readRegister(0x7b) == 0x1003E);
}
TEST_CASE("Eiger or Jungfrau startingfnum", "[.eigerintegration][.jungfrauintegration][startingfnum]") {
TEST_CASE("Eiger or Jungfrau startingfnum",
"[.eigerintegration][.jungfrauintegration][startingfnum]") {
SingleDetectorConfig c;
// pick up multi detector from shm id 0
multiSlsDetector m(0);
DetectorImpl m(0);
// ensure ctb detector type, hostname and online
REQUIRE(((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER) || (m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::JUNGFRAU)));
REQUIRE(
((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER) ||
(m.getDetectorTypeAsEnum() ==
slsDetectorDefs::detectorType::JUNGFRAU)));
REQUIRE(m.getHostname() == c.hostname);
CHECK(m.setNumberOfFrames(1) == 1);
CHECK(m.setNumberOfFrames(1) == 1);
// starting fnum
uint64_t val = 8;
@ -495,10 +492,11 @@ TEST_CASE("Eiger readnlines", "[.eigerintegration][readnlines]") {
SingleDetectorConfig c;
// pick up multi detector from shm id 0
multiSlsDetector m(0);
DetectorImpl m(0);
// ensure detector type, hostname
REQUIRE((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER));
REQUIRE(
(m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER));
REQUIRE(m.getHostname() == c.hostname);
m.setDynamicRange(16);
@ -507,7 +505,7 @@ TEST_CASE("Eiger readnlines", "[.eigerintegration][readnlines]") {
CHECK(m.getReadNLines() == 256);
m.setReadNLines(1);
CHECK(m.getReadNLines() == 1);
m.setDynamicRange(8);
m.setReadNLines(256);
CHECK(m.getReadNLines() == 256);

10
integrationTests/test-integrationMulti.cpp Executable file → Normal file
View File

@ -1,5 +1,5 @@
#include "DetectorImpl.h"
#include "catch.hpp"
#include "multiSlsDetector.h"
#include "string_utils.h"
#include "tests/globals.h"
#include <iostream>
@ -9,7 +9,7 @@ using namespace Catch::literals;
TEST_CASE("Initialize a multi detector", "[.integration][.multi]") {
auto hostnames = sls::split(test::hostname, '+');
multiSlsDetector d(0, true, true);
DetectorImpl d(0, true, true);
d.setHostname(test::hostname.c_str());
CHECK(d.getHostname() == test::hostname);
@ -24,11 +24,9 @@ TEST_CASE("Initialize a multi detector", "[.integration][.multi]") {
d.freeSharedMemory();
}
TEST_CASE("Set and read timers", "[.integration][.multi]") {
multiSlsDetector d(0, true, true);
DetectorImpl d(0, true, true);
d.setHostname(test::hostname.c_str());
// FRAME_NUMBER
@ -57,7 +55,6 @@ TEST_CASE("Set and read timers", "[.integration][.multi]") {
// PROGRESS, /**< fraction of measurement elapsed - only get! */
// MEASUREMENTS_NUMBER,
// FRAMES_FROM_START,
// FRAMES_FROM_START_PG,
// SAMPLES,
@ -78,7 +75,6 @@ TEST_CASE("Set and read timers", "[.integration][.multi]") {
CHECK(d.setSubFrameExposureDeadTime(-1) == Approx(subframe_deadtime));
}
if (test::type == dt::EIGER) {
// 32bit is needed for subframe exposure
d.setDynamicRange(32);

View File

@ -17,13 +17,13 @@
/*! \file document.h */
#include "reader.h"
#include "encodedstream.h"
#include "internal/meta.h"
#include "internal/strfunc.h"
#include "memorystream.h"
#include "encodedstream.h"
#include <new> // placement new
#include "reader.h"
#include <limits>
#include <new> // placement new
RAPIDJSON_DIAG_PUSH
#ifdef _MSC_VER

View File

@ -15,8 +15,8 @@
#ifndef RAPIDJSON_ENCODEDSTREAM_H_
#define RAPIDJSON_ENCODEDSTREAM_H_
#include "stream.h"
#include "memorystream.h"
#include "stream.h"
#ifdef __GNUC__
RAPIDJSON_DIAG_PUSH

View File

@ -15,9 +15,9 @@
#ifndef RAPIDJSON_STRTOD_
#define RAPIDJSON_STRTOD_
#include "ieee754.h"
#include "biginteger.h"
#include "diyfp.h"
#include "ieee754.h"
#include "pow10.h"
RAPIDJSON_NAMESPACE_BEGIN

View File

@ -164,8 +164,8 @@
#include "msinttypes/inttypes.h"
#else
// Other compilers should have this.
#include <stdint.h>
#include <inttypes.h>
#include <stdint.h>
#endif
//!@endcond
#ifdef RAPIDJSON_DOXYGEN_RUNNING

View File

@ -18,11 +18,11 @@
/*! \file reader.h */
#include "allocators.h"
#include "stream.h"
#include "encodedstream.h"
#include "internal/meta.h"
#include "internal/stack.h"
#include "internal/strtod.h"
#include "stream.h"
#include <limits>
#if defined(RAPIDJSON_SIMD) && defined(_MSC_VER)

View File

@ -176,6 +176,7 @@ One can configure all the detector settings in a parameter file {\tt{setup.det}}
\begin{verbatim}
sls_detector_put 0-parameters setup.det
\end{verbatim}
Note that the parameter file for any realease before 4.1.1 has not the possibility to understand parameters to be set differently for different half modules, i.e. {\tt{0:txndelay\_left xxxxx},\tt{1:txndelay\_left yyyyy}}.
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:
@ -609,18 +610,19 @@ The detector can be setup such to receive external triggers. Connect a LEMO sign
\begin{verbatim}
sls_detector_put 0-timing [auto/trigger/burst_trigger/gating]
sls_detector_put 0-frames x
sls_detector_put 0-triggers y
sls_detector_put 0-cycles y
sls_detector_acquire 0-
\end{verbatim}
No timeout is expected between the start of the acquisition and the arrival of the first trigger.
Here are the implemented options so far:
\begin{itemize}
\item {\tt{auto}} is the software controlled acquisition (does not use triggers), where {\tt{exptime}} and {\tt{period}} have to be set. Set number of triggers (i.e. triggers) to 1 using {\tt{triggers}}. Set number of frames using {\tt{frames}}.
\item {\tt{trigger}} 1 frame taken for 1 trigger. Your {\tt{frames}} needs to be 1 always, {\tt{triggers}} can be changed and defines how many triggers are considered. {\tt{exptime}} needs to be set. In the GUI this is called trigger exposure series.
\item {\tt{burst\_trigger}} gets only 1 trigger, but allows to take many frames. With {\tt{frames}} one can change the number of frames. {\tt{triggers}} needs to be 1. {\tt{exptime}} and {\tt{period}} have to be set. In the gui it is called trigger readout.
\item{\tt{gating}} allows to get a frame only when the trigger pulse is gating. Note that in this case the exp time and period only depend on the gating signal. {\tt{triggers}} allows to select how many gates to consider. Set number of frames to 1 using {\tt{frames}}. IMPORTANT: Up to firmware 23, the last subframe is oblige to finish being taken, despite the gate signal going down. This will be configurable from later fw and software version. Also, in gating mode, due to timimg of the state machine, you need to leave 500~$\mu$s deadtime between the end on an acquisition and the next. This is as the state machine is unable to check for changes in the status in the first 500~$\mu$s. ATTENTION: if you are in 16 bit mode and you are applying online rate corrections, as now the exptime is generated by the trigger, you might not have correct rate corrections. If you know what the exposure time is in the gating signal, then you can set the {\tt{exptime}} once and the rate corrections will be correct. In 32 bit mode, it does not matter as the rate corrections depends on the {\tt{subexptime}} which is software set independently from the gate exptime.
\item {\tt{auto}} is the software controlled acquisition (does not use triggers), where {\tt{exptime}} and {\tt{period}} have to be set. Set number of cycles (i.e. triggers) to 1 using {\tt{cycles}}. Set number of frames using {\tt{frames}}.
\item {\tt{trigger}} 1 frame taken for 1 trigger. Your {\tt{frames}} needs to be 1 always, {\tt{cycles}} can be changed and defines how many triggers are considered. {\tt{exptime}} needs to be set. In the GUI this is called trigger exposure series.
\item {\tt{burst\_trigger}} gets only 1 trigger, but allows to take many frames. With {\tt{frames}} one can change the number of frames. {\tt{cycles}} needs to be 1. {\tt{exptime}} and {\tt{period}} have to be set. In the gui it is called trigger readout.
\item{\tt{gating}} allows to get a frame only when the trigger pulse is gating. Note that in this case the exp time and period only depend on the gating signal. {\tt{cycles}} allows to select how many gates to consider. Set number of frames to 1 using {\tt{frames}}. IMPORTANT: Up to firmware 23, the last subframe is oblige to finish being taken, despite the gate signal going down. This will be configurable from later fw and software version. Also, in gating mode, due to timimg of the state machine, you need to leave 500~$\mu$s deadtime between the end on an acquisition and the next. This is as the state machine is unable to check for changes in the status in the first 500~$\mu$s. ATTENTION: if you are in 16 bit mode and you are applying online rate corrections, as now the exptime is generated by the trigger, you might not have correct rate corrections. If you know what the exposure time is in the gating signal, then you can set the {\tt{exptime}} once and the rate corrections will be correct. In 32 bit mode, it does not matter as the rate corrections depends on the {\tt{subexptime}} which is software set independently from the gate exptime.
ATTENTION: From release 4.1.1 with the {\tt{trigger}} option it is possible to have software triggers as a debugging tool (instead of the hardware trigger signal. One should start the acquisition (with the blocking {\tt{sls\_detector\_acquire}} if wanted and with another client one can send the softare trigger {\tt{sls\_detector\_put status trigger}}. This option allows for example to perform a motor scan (moving a motor in between single images) and still writing all images to the same file.
When using 32-bit mode, by default the acquisition ends the last complete subframe that was started when still the acquisition time was valid. This has been chosen as many people wants to know the exact acquisition time for when the detector was taking data and also, if {\tt{ratecorr}} are active, the last subframe will be correctly corrected, while otherwise it will be corrected with a wrong subdeadtime.
However, from 4.1.0, in gating mode, an option to immediately terminate the subframe when the gate signal goes down it is implemented to stop the acquisition at the same time. This option is {\tt{./sls\_detector\_put interruptsubframe 1}} while the default option is {\tt{./sls\_detector\_put interruptsubframe 0}}.
@ -628,13 +630,13 @@ However, from 4.1.0, in gating mode, an option to immediately terminate the subf
Hardware-wise, the ENABLE OUT signal outputs when the chips are really acquiring. This means that the single subframes will be output 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}} trigger modes and make both {\tt{frames}} and {\tt{triggers}} configurable at the same time.
We are planning to change some functionality, i.e. unify the {\tt{trigger}} and {\tt{burst\_trigger}} trigger modes and make both {\tt{frames}} and {\tt{cycles}} configurable at the same time.
There is the possibility to use {\tt{timing trigger/burst\_trigger}} and send software single commands to fake the trigger. This is done with:
\begin{verbatim}
sls_detector_put 0-timing [trigger/burst_trigger]
sls_detector_put 0-frames x
sls_detector_put 0-triggers y
sls_detector_put 0-cycles y
sls_detector_status trigger
\end{verbatim}
Note that this functionality is very (!) useful if you need to do something between and acquisition and the next. This can be used to do a fast threshold scan for example. See section~\ref{sec:fastthresholdscan}.
@ -715,7 +717,7 @@ If \textbf{dr} is 32 and \textbf{clkdivider} is not 2, whatever the detector get
Here is a list of parameters that should be reset:
\begin{enumerate}
\item \textbf{resetframescaught} should be reset to zero after every acquisition taken with {\tt{receiver start}},{\tt{status start}},{\tt{receiver stop}}. If the acquisition is taken with {\tt{sls\_detector\_acquire}}, there is no need to reset this.
\item After changing the {\tt{timing}} mode of the detector, one should reset to '1' the unused value, in that specific timing mode, between \textbf{frames} and \textbf{triggers}. See section~\ref{triggering} for how to use the timing. At the present moment the detector will acquire more frames than planned if the variable not used between \textbf{frames} and \textbf{triggers} is not reset. In future releases, the unused variable will be ignored. Still resetting is a good practice.
\item After changing the {\tt{timing}} mode of the detector, one should reset to '1' the unused value, in that specific timing mode, between \textbf{frames} and \textbf{cycles}. See section~\ref{triggering} for how to use the timing. At the present moment the detector will acquire more frames than planned if the variable not used between \textbf{frames} and \textbf{cycles} is not reset. In future releases, the unused variable will be ignored. Still resetting is a good practice.
\end{enumerate}
@ -988,13 +990,14 @@ Packets Caught Mask : 64 bytes
Note that if one wants to reconstruct the real time the detector was acquiring in 32 bit (autosumming mode), one would have to multiply the SubExptime (ns) for the SubFrame Number.
\subsection{Offline image reconstruction}
The offline image reconstruction{\tt{slsImageReconstruction}} is not part of the package anymore. The code is still available doing \\
{\tt{git clone git@git.psi.ch:sls\_detectors\_software/sls\_image\_reconstruction.git slsImageReconstruction}}.
Checkout the {\tt{developer}} branch if in a 3.1.X release, the {\tt{v4.0.0}} branch if in 4.0.X release, or the {\tt{v4.1}} branch if in 4.1.X release of the {\tt{slsDetector}} code.
The offline image reconstruction{\tt{slsImageReconstruction}} is not part of the package anymore. However, it can be retrieved from \\
{\tt{git clone https://github.com/slsdetectorgroup/slsImageReconstruction.git slsImageReconstruction}}.\\
Checkout the {\tt{v3.1}} branch if in a 3.1.X release, the {\tt{v4.0.0}} branch if in 4.0.X release, or the {\tt{v4.1}} branch if in 4.1.X release of the {\tt{slsDetector}} code. There is a {\tt{developer}} branch that has newer updates but needs to be tested.
Three possible conversions are possible: into \textbf{cbf}, \textbf{hdf5} and \textbf{root} format. The detector writes 4 raw files per receiver. An offline image reconstruction executable has been written to collate the possible files together and produce output files. By default an interpolation between the values of the large pixels is performed. Gap pixels between modules are also inserted.
Three possible conversions are possible: into \textbf{cbf}, \textbf{hdf5}. \textbf{tiff} and \textbf{root} format. The detector writes 2 raw files per receiver. An offline image reconstruction executable has been written to collate the possible files together and produce output files. By default an interpolation between the values of the large pixels is performed. Gap pixels between modules are also inserted.
Note that the number of images per file in the 3.1.X release is hardcoded and needs to match whatever you are using in {\tt{slsDetectorsPackage/slsReceiverSoftware/include/sls\_receiver\_defs.h}}:
Note that the number of images per file in the 3.1.X release is hardcoded and needs to match whatever you are using in \\
{\tt{slsDetectorsPackage/slsReceiverSoftware/include/sls\_receiver\_defs.h}}:
\begin{verbatim}
#define EIGER_MAX_FRAMES_PER_FILE 2000
\end{verbatim}
@ -1043,11 +1046,12 @@ cbfMaker9M [file_name_with_dir]
contain the hardcoded geometry for the 1.5M (3 modules horizontal on the long side), the 1.5M OMNY geometry (3 modules next to each other 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.
From the new {{v4.1.1}} all the define that you see below need only to be modified in the Makefile.
Make sure the following options are uncommented in the {\tt{slsImageReconstruction/src/main\_csaxs.cpp}} file.
\begin{verbatim}
#define MYCBF
##following line only if you need to process with
##BUBBLE (Material Science / uXAS beamlines).
##following line only if you need to process with BUBBLE
#define MSHeader
\end{verbatim}
Compile it with:
@ -1096,6 +1100,10 @@ To use it any geometry:\\
eg.
{\tt image /scratch/run\_63\_d0\_f000000000000\_3.raw 3072 512 1 2 ``Eiger'' 0}.\\
With new new software, the new options to run the cbfMaker/hdf5Maker executablesare:
./hdf5Maker -f [filename] -d [outdirname] -x [npix\_x] -y [npix\_y] -v (v flags that longedge is vertical, no argument) -n [name\_of\_hdf5\_dataset] -m (mask\_hot\_pixels, need to be in file maskpix.txt in the samedir as executable, no argument) -g [0,no filling/1,division/2,interpolation/3,interpolate,alternative]
\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 boards:
@ -1257,7 +1265,7 @@ We have also been requested if we could speed up the threshold scan. At the mome
./sls_detector_put enablefwrite 0
./sls_detector_put resetframescaught 0
./sls_detector_put index 0
./sls_detector_put triggers 21
./sls_detector_put cycles 21
./sls_detector_put receiver start
./sls_detector_put status start
for i in $(seq 0 20);
@ -1515,8 +1523,8 @@ frames number
where {\tt{number}} is a string to be interpreted as an integer.
\item \begin{verbatim}
sls_detector_get triggers
triggers number
sls_detector_get cycles
cycles number
\end{verbatim}
where {\tt{number}} is a string to be interpreted as an integer.

View File

@ -1,19 +1,22 @@
pybind11_add_module(_sls_detector
# find_package (Python COMPONENTS Interpreter Development)
pybind11_add_module(_slsdet
src/main.cpp
src/enums.cpp
src/experimental.cpp
src/detector.cpp
src/network.cpp
)
target_link_libraries(_sls_detector PUBLIC
target_link_libraries(_slsdet PUBLIC
slsDetectorShared
slsReceiverShared
slsSupportLib
zmq )
)
set_target_properties(_sls_detector PROPERTIES
set_target_properties(_slsdet PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
@ -24,20 +27,21 @@ set( PYTHON_FILES
dacs.py
decorators.py
detector_property.py
# detector.py
# eiger.py
detector.py
eiger.py
errors.py
experimental.py
# jungfrau_ctb.py
# jungfrau.py
ctb.py
jungfrau.py
mythen3.py
registers.py
lookup.py
utils.py
)
foreach(FILE ${PYTHON_FILES})
configure_file( sls_detector/${FILE}
${CMAKE_BINARY_DIR}/bin/sls_detector/${FILE} )
configure_file( slsdet/${FILE}
${CMAKE_BINARY_DIR}/bin/slsdet/${FILE} )
endforeach(FILE ${PYTHON_FILES})

View File

@ -0,0 +1,82 @@
import pytest
import datetime as dt
from slsdet import Detector, timingMode, detectorType
not_eiger = pytest.mark.skipif(
Detector().type == detectorType.EIGER, reason="Does not work for eiger"
)
@pytest.fixture
def det():
from slsdet import Detector
return Detector()
def test_frames(det):
for n in [1, 100, 3245, 10000]:
det.frames = n
assert det.frames == n
det.frames = 1
def test_triggers(det):
for n in [1, 100, 3245, 10000]:
det.triggers = n
assert det.triggers == n
det.triggers = 1
def test_exptime(det):
det.exptime = 1
assert det.exptime == 1
det.exptime = dt.timedelta(milliseconds=10)
assert det.exptime == 0.01
det.exptime = 1
def test_period(det):
det.period = 3.2
assert det.period == 3.2
p = dt.timedelta(microseconds=1020)
det.period = p
assert det.period == 0.001020
r = det.getPeriod()
assert r[0] == p
det.period = 0
assert det.period == 0
def test_lock(det):
for l in [True, False]:
det.lock = l
assert det.lock == l
def test_timing(det):
# auto and trigger is available for all det
for m in [timingMode.TRIGGER_EXPOSURE, timingMode.AUTO_TIMING]:
det.timing = m
assert det.timing == m
@not_eiger
def test_delay(det):
det.delay = 1
assert det.delay == 1
t = dt.timedelta(microseconds=1)
det.delay = t
assert det.delay == t.total_seconds()
r = det.getDelayAfterTrigger()[0]
assert r == t
det.delay = 0
assert det.delay == 0
@not_eiger
def test_delayl(det):
assert det.delayl == 0

View File

@ -0,0 +1,89 @@
import pytest
import datetime as dt
from slsdet import Detector, detectorType
"""
These tests are designed to work the API and catch
any changes in behavior or naming. Tests are expected
to pass with a virtual detector or a real one
"""
@pytest.fixture
def jf():
from slsdet import Jungfrau
return Jungfrau()
jungfrautest = pytest.mark.skipif(
Detector().type != detectorType.JUNGFRAU, reason="Only valid for Jungfrau"
)
@jungfrautest
def test_storagecells(jf):
for i in range(16):
jf.storagecells = i
assert jf.storagecells == i
jf.storagecells = 0 # default
@jungfrautest
def test_storagecell_start(jf):
for i in range(16):
jf.storagecell_start = i
assert jf.storagecell_start == i
jf.storagecells = 15 # default
@jungfrautest
def test_storagecell_delay(jf):
for t in [0.001, 0.0002, 0.0013]:
jf.storagecell_delay = t
assert jf.storagecell_delay == t
jf.storagecell_delay = 0 # default
@jungfrautest
def test_temp_event(jf):
# hard to test with virtual server
assert jf.temp_event == 0
@jungfrautest
def test_temp_threshold(jf):
for th in [0, 10, 43, 72]:
jf.temp_threshold = th
assert jf.temp_threshold == th
jf.temp_threshold = 0
@jungfrautest
def test_auto_comp_disable(jf):
for v in [True, False]:
jf.auto_comp_disable = v
assert jf.auto_comp_disable == v
@jungfrautest
def test_numinterfaces(jf):
for n in [2, 1]:
jf.numinterfaces = n
assert jf.numinterfaces == n
@jungfrautest
def test_dr(jf):
assert jf.dr == 16
@jungfrautest
def test_temp_control(jf):
for v in [True, False]:
jf.temp_control = v
assert jf.temp_control == v
@jungfrautest
def test_startingfnum(jf):
for n in [10, 127, 43321, 1]:
jf.startingfnum = n
assert jf.startingfnum == n
@jungfrautest
def test_selinterface(jf):
for i in [1, 0]:
jf.selinterface = i
assert jf.selinterface == i

View File

@ -2,9 +2,14 @@ import os
import sys
import numpy as np
sys.path.append(os.path.join(os.getcwd(), 'bin'))
# from sls_detector import Eiger, Jungfrau, Detector, defs
from sls_detector import Detector
from sls_detector import dacIndex
from slsdet import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb
from slsdet import dacIndex, readoutMode
from slsdet.lookup import view, find
d = Detector()
# e = Eiger()
c = Ctb()
# j = Jungfrau()
# m = Mythen3()

View File

@ -0,0 +1,26 @@
import subprocess
import locale
out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding())
cmd = out.stdout.splitlines()
cmd.pop(0)
from slsdet import Detector, Eiger, Ctb
pycmd = dir(Detector)+dir(Eiger)+dir(Ctb)
#Add commands that we should not expect as direct commands in python
pycmd += ['vrf', 'vtr', 'vrs', 'vtgstv', 'vsvn', 'vtrim',
'vsvp', 'vth1', 'vth2', 'vth3', 'vshaper', 'vshaperneg', 'rxb_rb',
'rxb_lb', 'vref_prech', 'vref_rstore', 'vref_cds',
'vpreamp', 'vref_comp', 'vref_comp_fe vref_ds', 'vref_h_adc',
'vref_l_adc', 'iodelay', 'list', 'vref_ds', 'vis', 'vpl',
'vref_comp_fe', 'vph', 'vout_cm', 'vcp', 'vcn', 'vcmp_ll', 'vcmp_lr'
, 'vcmp_rl', 'vcmp_rr', 'daclist', 'dacvalues', 'vcal', 'vcas']
missing = []
for c in cmd:
if c not in pycmd:
print(c)
missing.append(c)
print(f'Missing: {len(missing)} commands')

View File

@ -9,19 +9,11 @@ enums.cpp
import re
import subprocess
from parse import remove_comments
# def remove_comments(text):
# def replacer(match):
# s = match.group(0)
# if s.startswith('/'):
# return " " # note: a space and not an empty string
# else:
# return s
# pattern = re.compile(
# r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
# re.DOTALL | re.MULTILINE
# )
# return re.sub(pattern, replacer, text)
def single_line_enum(line):
sub = line[line.find('{')+1:line.find('}')]
return sub.strip().split(',')
def extract_enums(lines):
line_iter = iter(lines)
@ -30,19 +22,26 @@ def extract_enums(lines):
m = re.search("(?<=enum )\w+(?= {)", line)
if m:
enum_name = m.group()
# print(enum_name)
print(enum_name)
# print(line)
fields = []
while True:
l = next(line_iter)
if '};' in l:
break
m = re.search("\w+", l)
try:
# print('\t', m.group())
fields.append(m.group())
except:
pass
#deal with single line enums
if '};' in line:
fields = single_line_enum(line)
else:
#deal with multi line enums
while True:
l = next(line_iter)
if '};' in l:
break
m = re.search("\w+", l)
try:
# print('\t', m.group())
fields.append(m.group())
except:
pass
enums[enum_name] = fields
return enums

View File

@ -0,0 +1,123 @@
"""
This file is used to auto generate Python bindings for the
sls::Detector class. The tool needs the libclang bindings
to be installed.
When the Detector API is updated this file should be run
manually
"""
from clang import cindex
import subprocess
import argparse
from parse import system_include_paths
default_build_path = "/home/l_frojdh/sls/build/"
fpath = "../../slsDetectorSoftware/src/Detector.cpp"
parser = argparse.ArgumentParser()
parser.add_argument(
"-p",
"--build_path",
help="Path to the build database",
type=str,
default=default_build_path,
)
cargs = parser.parse_args()
db = cindex.CompilationDatabase.fromDirectory(cargs.build_path)
index = cindex.Index.create()
args = db.getCompileCommands(fpath)
args = list(iter(args).__next__().arguments)[0:-1]
args = args + "-x c++ --std=c++11".split()
syspath = system_include_paths("clang++")
incargs = ["-I" + inc for inc in syspath]
args = args + incargs
tu = index.parse(fpath, args=args)
m = []
ag = []
lines = []
ag2 = []
cn = []
def get_arguments(node):
args = [a.type.spelling for a in node.get_arguments()]
args = [
"py::arg() = Positions{}" if item == "sls::Positions" else "py::arg()"
for item in args
]
args = ", ".join(args)
if args:
args = f", {args}"
return args
def get_fdec(node):
args = [a.type.spelling for a in node.get_arguments()]
if node.result_type.spelling:
return_type = node.result_type.spelling
else:
return_type = 'void'
if node.is_const_method():
const = 'const'
else:
const = ''
args = ", ".join(args)
args = f'({return_type}(Detector::*)({args}){const})'
return args
def visit(node):
if node.kind == cindex.CursorKind.CLASS_DECL:
if node.displayname == "Detector":
for child in node.get_children():
if (
child.kind == cindex.CursorKind.CXX_METHOD
and child.access_specifier == cindex.AccessSpecifier.PUBLIC
):
m.append(child)
args = get_arguments(child)
fs = get_fdec(child)
lines.append(
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
)
cn.append(child)
for child in node.get_children():
visit(child)
# .def("setRxHostname",
# (void (Detector::*)(const std::string &, Positions)) &
# Detector::setRxHostname,
# py::arg(), py::arg() = Positions{})
# .def("setRxHostname",
# (void (Detector::*)(const std::vector<std::string> &)) &
# Detector::setRxHostname,
# py::arg())
visit(tu.cursor)
with open("../src/detector_in.cpp") as f:
data = f.read()
s = "".join(lines)
s += ";"
text = data.replace("[[FUNCTIONS]]", s)
warning = "/* WARINING This file is auto generated any edits might be overwritten without warning */\n\n"
with open("../src/detector.cpp", "w") as f:
f.write(warning)
f.write(text)
# run clang format on the output
subprocess.run(["clang-format", "../src/detector.cpp", "-i"])

29
python/scripts/list_tested_cmd.py Normal file → Executable file
View File

@ -1,11 +1,19 @@
"""
Utility to find and list which command line functions have tests and
where the tests are located
"""
#local import for for parsing c++
import parse
from pathlib import Path
#General python stuff
import os
import locale
import argparse
path = Path('../../slsDetectorSoftware/tests/')
import subprocess
from pathlib import Path
#Realative path from this dir
path = Path('../../slsDetectorSoftware/tests/')
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--startswith", help="for filter", type = str, default=None)
args = parser.parse_args()
@ -15,15 +23,12 @@ tested = []
for fname in files:
with open(path/fname) as f:
data = f.read()
data = parse.remove_comments(data)
data = data.splitlines()
for line in data:
if 'TEST_CASE' in line or 'SECTION' in line:
cmd = line.split("\"")[1]
tested.append(cmd)
tested.append([cmd, fname])
out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding())
all_cmd = out.stdout.splitlines()
@ -33,18 +38,18 @@ all_cmd.pop(0)
if args.startswith is not None:
all_cmd = [cmd for cmd in all_cmd if cmd.startswith(args.startswith)]
tested = [cmd for cmd in tested if cmd.startswith(args.startswith)]
tested = [cmd for cmd in tested if cmd[0].startswith(args.startswith)]
tn = [cmd[0] for cmd in tested]
not_tested = [cmd for cmd in all_cmd if cmd not in tested]
misnamed = [cmd for cmd in tested if cmd not in all_cmd]
tested = [cmd for cmd in tested if cmd in all_cmd]
not_tested = [cmd for cmd in all_cmd if cmd not in tn]
misnamed = [cmd for cmd in tn if cmd not in all_cmd]
tested = [cmd for cmd in tested if cmd[0] in all_cmd]
print("\nThe following commands are tested:")
for cmd in tested:
print(cmd)
print(f'{cmd[0]:>18} : {cmd[1]}')
print("\nThe following commands are NOT tested:")
for cmd in not_tested:

View File

@ -1,4 +1,9 @@
import re
import subprocess
from subprocess import PIPE
import os
def remove_comments(text):
def replacer(match):
s = match.group(0)
@ -10,4 +15,42 @@ def remove_comments(text):
r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
re.DOTALL | re.MULTILINE
)
return re.sub(pattern, replacer, text)
return re.sub(pattern, replacer, text)
#based on ccsyspath: https://github.com/AndrewWalker/ccsyspath
def compiler_preprocessor_verbose(compiler, extraflags):
"""Capture the compiler preprocessor stage in verbose mode
"""
lines = []
with open(os.devnull, 'r', encoding='utf-8') as devnull:
cmd = [compiler, '-E']
cmd += extraflags
cmd += ['-', '-v']
p = subprocess.Popen(cmd, stdin=devnull, stdout=PIPE, stderr=PIPE)
p.wait()
lines = p.stderr.read()
lines = lines.splitlines()
return lines
def system_include_paths(compiler, cpp=True):
extraflags = []
if cpp:
extraflags = b'-x c++'.split()
lines = compiler_preprocessor_verbose(compiler, extraflags)
lines = [ line.strip() for line in lines ]
start = lines.index(b'#include <...> search starts here:')
end = lines.index(b'End of search list.')
lines = lines[start+1:end]
paths = []
for line in lines:
line = line.replace(b'(framework directory)', b'')
line = line.strip()
paths.append(line)
paths = [p.decode('utf-8') for p in paths]
return paths

View File

@ -8,7 +8,7 @@ import sys
import setuptools
import os
__version__ = 'refactor'
__version__ = os.environ.get('GIT_DESCRIBE_TAG', 'developer')
def get_conda_path():
@ -19,31 +19,33 @@ def get_conda_path():
return os.environ['CONDA_PREFIX']
class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
The purpose of this class is to postpone importing pybind11
until it is actually installed, so that the ``get_include()``
method can be invoked. """
# class get_pybind_include(object):
# """Helper class to determine the pybind11 include path
# The purpose of this class is to postpone importing pybind11
# until it is actually installed, so that the ``get_include()``
# method can be invoked. """
def __init__(self, user=False):
self.user = user
# def __init__(self, user=False):
# self.user = user
def __str__(self):
import pybind11
return pybind11.get_include(self.user)
# def __str__(self):
# import pybind11
# return pybind11.get_include(self.user)
ext_modules = [
Extension(
'_sls_detector',
'_slsdet',
['src/main.cpp',
'src/enums.cpp',
'src/experimental.cpp'],
'src/detector.cpp',
'src/network.cpp'],
include_dirs=[
# Path to pybind11 headers
get_pybind_include(),
get_pybind_include(user=True),
os.path.join(get_conda_path(), 'include/slsDetectorPackage'),
# get_pybind_include(),
# get_pybind_include(user=True),
os.path.join('../libs/pybind11/include'),
os.path.join(get_conda_path(), 'include'),
],
libraries=['SlsDetector', 'SlsReceiver', 'zmq'],
@ -108,20 +110,28 @@ class BuildExt(build_ext):
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
for ext in self.extensions:
ext.extra_compile_args = opts
build_ext.build_extensions(self)
print('**************************************************')
print(ct)
print(opts)
print('**************************************************')
build_ext.build_extensions(self)
def get_shared_lib():
return [f for f in os.listdir('.') if '_slsdet' in f]
setup(
name='sls_detector',
name='slsdet',
version=__version__,
author='Erik Frojdh',
author_email='erik.frojdh@psi.ch',
url='https://github.com/slsdetectorgroup/sls_detector',
url='https://github.com/slsdetectorgroup/slsDetectorPackage',
description='Detector API for SLS Detector Group detectors',
long_description='',
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
ext_modules=ext_modules,
install_requires=['pybind11>=2.2'],
cmdclass={'build_ext': BuildExt},
zip_safe=False,
)

View File

@ -1,17 +0,0 @@
# from .detector import Detector, DetectorError, free_shared_memory
# from .eiger import Eiger
from .experimental import Detector
# from .jungfrau import Jungfrau
# from .jungfrau_ctb import JungfrauCTB
# from _sls_detector import DetectorApi
import _sls_detector
defs = _sls_detector.slsDetectorDefs
runStatus = _sls_detector.slsDetectorDefs.runStatus
speedLevel = _sls_detector.slsDetectorDefs.speedLevel
timingMode = _sls_detector.slsDetectorDefs.timingMode
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
detectorType = _sls_detector.slsDetectorDefs.detectorType
detectorSettings = _sls_detector.slsDetectorDefs.detectorSettings

View File

@ -1,596 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 6 11:51:18 2017
@author: l_frojdh
"""
import socket
from collections.abc import Iterable
from collections import namedtuple
from functools import partial
from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs
from .detector import Detector
from .detector_property import DetectorProperty
from .utils import element_if_equal
from sls_detector.errors import DetectorValueError, DetectorError
class EigerVcmp:
"""
Convenience class to be able to loop over vcmp for Eiger
.. todo::
Support single assignment and perhaps unify with Dac class
"""
def __init__(self, detector):
_names = ['vcmp_ll',
'vcmp_lr',
'vcmp_rl',
'vcmp_rr']
self.set = []
self.get = []
for i in range(detector.n_modules):
if i % 2 == 0:
name = _names
else:
name = _names[::-1]
for n in name:
self.set.append(partial(detector._api.setDac, n, i))
self.get.append(partial(detector._api.getDac, n, i))
def __getitem__(self, key):
if key == slice(None, None, None):
return [_d() for _d in self.get]
return self.get[key]()
def __setitem__(self, i, value):
self.set[i](value)
def __repr__(self):
return 'vcmp: '+ str(self[:])
class EigerDacs(DetectorDacs):
_dacs = [('vsvp', 0, 4000, 0),
('vtr', 0, 4000, 2500),
('vrf', 0, 4000, 3300),
('vrs', 0, 4000, 1400),
('vsvn', 0, 4000, 4000),
('vtgstv', 0, 4000, 2556),
('vcmp_ll', 0, 4000, 1500),
('vcmp_lr', 0, 4000, 1500),
('vcall', 0, 4000, 4000),
('vcmp_rl', 0, 4000, 1500),
('rxb_rb', 0, 4000, 1100),
('rxb_lb', 0, 4000, 1100),
('vcmp_rr', 0, 4000, 1500),
('vcp', 0, 4000, 200),
('vcn', 0, 4000, 2000),
('vis', 0, 4000, 1550),
('iodelay', 0, 4000, 660)]
_dacnames = [_d[0] for _d in _dacs]
# noinspection PyProtectedMember
class DetectorDelays:
_delaynames = ['frame', 'left', 'right']
def __init__(self, detector):
# We need to at least initially know which detector we are connected to
self._detector = detector
setattr(self, '_frame', DetectorProperty(detector._api.getDelayFrame,
detector._api.setDelayFrame,
detector._api.getNumberOfDetectors,
'frame'))
setattr(self, '_left', DetectorProperty(detector._api.getDelayLeft,
detector._api.setDelayLeft,
detector._api.getNumberOfDetectors,
'left'))
setattr(self, '_right', DetectorProperty(detector._api.getDelayRight,
detector._api.setDelayRight,
detector._api.getNumberOfDetectors,
'right'))
# Index to support iteration
self._current = 0
def __getattr__(self, name):
return self.__getattribute__('_' + name)
def __setattr__(self, name, value):
if name in self._delaynames:
return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value)
else:
super().__setattr__(name, value)
def __next__(self):
if self._current >= len(self._delaynames):
self._current = 0
raise StopIteration
else:
self._current += 1
return self.__getattr__(self._delaynames[self._current-1])
def __iter__(self):
return self
def __repr__(self):
hn = self._detector.hostname
r_str = ['Transmission delay [ns]\n'
'{:11s}{:>8s}{:>8s}{:>8s}'.format('', 'left', 'right', 'frame')]
for i in range(self._detector.n_modules):
r_str.append('{:2d}:{:8s}{:>8d}{:>8d}{:>8d}'.format(i, hn[i], self.left[i], self.right[i], self.frame[i]))
return '\n'.join(r_str)
class Eiger(Detector):
"""
Subclassing Detector to set up correct dacs and detector specific
functions.
"""
_detector_dynamic_range = [4, 8, 16, 32]
_settings = ['standard', 'highgain', 'lowgain', 'veryhighgain', 'verylowgain']
"""available settings for Eiger, note almost always standard"""
def __init__(self, id=0):
super().__init__(id)
self._active = DetectorProperty(self._api.getActive,
self._api.setActive,
self._api.getNumberOfDetectors,
'active')
self._vcmp = EigerVcmp(self)
self._dacs = EigerDacs(self)
self._trimbit_limits = namedtuple('trimbit_limits', ['min', 'max'])(0, 63)
self._delay = DetectorDelays(self)
# Eiger specific adcs
self._temp = DetectorAdcs()
self._temp.fpga = Adc('temp_fpga', self)
self._temp.fpgaext = Adc('temp_fpgaext', self)
self._temp.t10ge = Adc('temp_10ge', self)
self._temp.dcdc = Adc('temp_dcdc', self)
self._temp.sodl = Adc('temp_sodl', self)
self._temp.sodr = Adc('temp_sodr', self)
self._temp.fpgafl = Adc('temp_fpgafl', self)
self._temp.fpgafr = Adc('temp_fpgafr', self)
@property
def active(self):
"""
Is the detector active? Can be used to enable or disable a detector
module
Examples
----------
::
d.active
>> active: [True, True]
d.active[1] = False
>> active: [True, False]
"""
return self._active
@active.setter
def active(self, value):
self._active[:] = value
@property
def measured_period(self):
return self._api.getMeasuredPeriod()
@property
def measured_subperiod(self):
return self._api.getMeasuredSubPeriod()
@property
def add_gappixels(self):
"""Enable or disable the (virual) pixels between ASICs
Examples
----------
::
d.add_gappixels = True
d.add_gappixels
>> True
"""
return self._api.getGapPixels()
@add_gappixels.setter
def add_gappixels(self, value):
self._api.setGapPixels(value)
@property
def dacs(self):
"""
An instance of DetectorDacs used for accessing the dacs of a single
or multi detector.
Examples
---------
::
d = Eiger()
#Set all vrf to 1500
d.dacs.vrf = 1500
#Check vrf
d.dacs.vrf
>> vrf : 1500, 1500
#Set a single vtr
d.dacs.vtr[0] = 1800
#Set vrf with multiple values
d.dacs.vrf = [3500,3700]
d.dacs.vrf
>> vrf : 3500, 3700
#read into a variable
var = d.dacs.vrf[:]
#set multiple with multiple values, mostly used for large systems
d.dacs.vcall[0,1] = [3500,3600]
d.dacs.vcall
>> vcall : 3500, 3600
d.dacs
>>
========== DACS =========
vsvp : 0, 0
vtr : 4000, 4000
vrf : 1900, 1900
vrs : 1400, 1400
vsvn : 4000, 4000
vtgstv : 2556, 2556
vcmp_ll : 1500, 1500
vcmp_lr : 1500, 1500
vcall : 4000, 4000
vcmp_rl : 1500, 1500
rxb_rb : 1100, 1100
rxb_lb : 1100, 1100
vcmp_rr : 1500, 1500
vcp : 1500, 1500
vcn : 2000, 2000
vis : 1550, 1550
iodelay : 660, 660
"""
return self._dacs
@property
def tx_delay(self):
"""
Transmission delay of the modules to allow running the detector
in a network not supporting the full speed of the detector.
::
d.tx_delay
>>
Transmission delay [ns]
left right frame
0:beb048 0 15000 0
1:beb049 100 190000 100
d.tx_delay.left = [2000,5000]
"""
return self._delay
def default_settings(self):
"""
reset the detector to some type of standard settings
mostly used when testing
"""
self.n_frames = 1
self.exposure_time = 1
self.period = 0
self.n_cycles = 1
self.n_measurements = 1
self.dynamic_range = 16
@property
def eiger_matrix_reset(self):
"""
Matrix reset bit for Eiger.
:py:obj:`True` : Normal operation, the matrix is reset before each acq.
:py:obj:`False` : Matrix reset disabled. Used to not reset before
reading out analog test pulses.
"""
return self._api.getCounterBit()
@eiger_matrix_reset.setter
def eiger_matrix_reset(self, value):
self._api.setCounterBit(value)
@property
def flowcontrol_10g(self):
"""
:py:obj:`True` - Flow control enabled :py:obj:`False` flow control disabled.
Sets for all moduels, if for some reason access to a single module is needed
this can be done trough the C++ API.
"""
fc = self._api.getNetworkParameter('flow_control_10g')
return element_if_equal([bool(int(e)) for e in fc])
@flowcontrol_10g.setter
def flowcontrol_10g(self, value):
if value is True:
v = '1'
else:
v = '0'
self._api.setNetworkParameter('flow_control_10g', v, -1)
def pulse_all_pixels(self, n):
"""
Pulse each pixel of the chip **n** times using the analog test pulses.
The pulse height is set using d.dacs.vcall with 4000 being 0 and 0 being
the highest pulse.
::
#Pulse all pixels ten times
d.pulse_all_pixels(10)
#Avoid resetting before acq
d.eiger_matrix_reset = False
d.acq() #take frame
#Restore normal behaviour
d.eiger_matrix_reset = True
"""
self._api.pulseAllPixels(n)
def pulse_diagonal(self, n):
"""
Pulse pixels in super colums in a diagonal fashion. Used for calibration
of vcall. Saves time compared to pulsing all pixels.
"""
self._api.pulseDiagonal(n)
def pulse_chip(self, n):
"""
Advance the counter by toggling enable. Gives 2*n+2 int the counter
"""
n = int(n)
if n >= -1:
self._api.pulseChip(n)
else:
raise ValueError('n must be equal or larger than -1')
@property
def vcmp(self):
"""
Convenience function to get and set the individual vcmp of chips
Used mainly in the calibration code.
Examples
---------
::
#Reading
d.vcmp[:]
>> [500, 500, 500, 500, 500, 500, 500, 500]
#Setting
d.vcmp = [500, 500, 500, 500, 500, 500, 500, 500]
"""
return self._vcmp
@vcmp.setter
def vcmp(self, values):
if len(values) == len(self._vcmp.set):
for i, v in enumerate(values):
self._vcmp.set[i](v)
else:
raise ValueError('vcmp only compatible with setting all')
@property
def rx_udpport(self):
"""
UDP port for the receiver. Each module has two ports referred to
as rx_udpport and rx_udpport2 in the command line interface
here they are grouped for each detector
::
[0:rx_udpport, 0:rx_udpport2, 1:rx_udpport ...]
Examples
-----------
::
d.rx_udpport
>> [50010, 50011, 50004, 50005]
d.rx_udpport = [50010, 50011, 50012, 50013]
"""
p0 = self._api.getReceiverUDPPort()
p1 = self._api.getReceiverUDPPort2()
return [int(val) for pair in zip(p0, p1) for val in pair]
@rx_udpport.setter
def rx_udpport(self, ports):
"""Requires iterating over elements two and two for setting ports"""
a = iter(ports)
for i, p in enumerate(zip(a, a)):
self._api.setReceiverUDPPort(p[0], i)
self._api.setReceiverUDPPort2(p[1], i)
@property
def rx_zmqport(self):
"""
Return the receiver zmq ports. Note that Eiger has two ports per receiver!
::
detector.rx_zmqport
>> [30001, 30002, 30003, 30004]
"""
_s = self._api.getReceiverStreamingPort()
if _s == '':
return []
else:
return [int(_p) + i for _p in _s for i in range(2)]
@rx_zmqport.setter
def rx_zmqport(self, port):
if isinstance(port, Iterable):
for i, p in enumerate(port):
self._api.setReceiverStreamingPort(p, i)
else:
self._api.setReceiverStreamingPort(port, -1)
@property
def sub_exposure_time(self):
"""
Sub frame exposure time in *seconds* for Eiger in 32bit autosumming mode
::
d.sub_exposure_time
>> 0.0023
d.sub_exposure_time = 0.002
"""
return self._api.getSubExposureTime() / 1e9
@sub_exposure_time.setter
def sub_exposure_time(self, t):
#TODO! checking here or in the detector?
ns_time = int(t * 1e9)
if ns_time > 0:
self._api.setSubExposureTime(ns_time)
else:
raise DetectorValueError('Sub exposure time must be larger than 0')
@property
def sub_deadtime(self):
"""
Deadtime between subexposures. Used to mimize noise by delaying the start of the next
subexposure.
"""
return self._api.getSubExposureDeadTime() / 1e9
@sub_deadtime.setter
def sub_deadtime(self, t):
ns_time = int(t * 1e9)
if ns_time >= 0:
self._api.setSubExposureDeadTime(ns_time)
else:
raise ValueError('Sub deadtime time must be larger or equal to 0')
@property
def temp(self):
"""
An instance of DetectorAdcs used to read the temperature
of different components
Examples
-----------
::
detector.temp
>>
temp_fpga : 36.90°C, 45.60°C
temp_fpgaext : 31.50°C, 32.50°C
temp_10ge : 0.00°C, 0.00°C
temp_dcdc : 36.00°C, 36.00°C
temp_sodl : 33.00°C, 34.50°C
temp_sodr : 33.50°C, 34.00°C
temp_fpgafl : 33.81°C, 30.93°C
temp_fpgafr : 27.88°C, 29.15°C
a = detector.temp.fpga[:]
a
>> [36.568, 45.542]
"""
return self._temp
@property
def tengiga(self):
"""Enable 10Gbit/s data output
Examples
----------
::
d.tengiga
>> False
d.tengiga = True
"""
return self._api.getTenGigabitEthernet()
@tengiga.setter
def tengiga(self, value):
self._api.setTenGigabitEthernet(value)
def set_delays(self, delta):
self.tx_delay.left = [delta*(i*2) for i in range(self.n_modules)]
self.tx_delay.right = [delta*(i*2+1) for i in range(self.n_modules)]
def setup500k(self, hostnames):
"""
Setup the Eiger detector to run on the local machine
"""
self.hostname = hostnames
self.file_write = False
self.image_size = (512, 1024)
self.rx_tcpport = [1954, 1955]
self.rx_udpport = [50010, 50011, 50004, 50005]
self.rx_hostname = socket.gethostname().split('.')[0]
self.rx_datastream = False
self.file_write = False
self.online = True
self.receiver_online = True

View File

@ -1,633 +0,0 @@
from _sls_detector import CppDetectorApi
from _sls_detector import slsDetectorDefs
runStatus = slsDetectorDefs.runStatus
speedLevel = slsDetectorDefs.speedLevel
dacIndex = slsDetectorDefs.dacIndex
from .utils import element_if_equal, all_equal
from .utils import Geometry, to_geo
import datetime as dt
from functools import wraps
from collections import namedtuple
class Register:
"""
Helper class to read and write to registers using a
more Pythonic syntax
"""
def __init__(self, detector):
self._detector = detector
def __getitem__(self, key):
return self._detector.readRegister(key)
def __setitem__(self, key, value):
self._detector.writeRegister(key, value)
def freeze(cls):
cls.__frozen = False
def frozensetattr(self, key, value):
if self.__frozen and not hasattr(self, key):
raise AttributeError(
"Class {} is frozen. Cannot set {} = {}".format(
cls.__name__, key, value
)
)
else:
object.__setattr__(self, key, value)
def init_decorator(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
func(self, *args, **kwargs)
self.__frozen = True
return wrapper
cls.__setattr__ = frozensetattr
cls.__init__ = init_decorator(cls.__init__)
return cls
@freeze
class Detector(CppDetectorApi):
"""
This class is the base for detector specific
interfaces. Most functions exists in two versions
like the getExptime() function that uses the
C++ API directly and the simplified exptime property.
"""
def __init__(self, multi_id=0):
"""
multi_id refers to the shared memory id of the
slsDetectorPackage. Default value is 0.
"""
super().__init__(multi_id)
self._register = Register(self)
# CONFIGURATION
def __len__(self):
return self.size()
def __repr__(self):
return '{}(id = {})'.format(self.__class__.__name__,
self.getShmId())
def free(self):
self.freeSharedMemory()
@property
def config(self):
return NotImplementedError("config is set only")
@config.setter
def config(self, fname):
self.loadConfig(fname)
@property
def parameters(self):
return NotImplementedError("parameters is set only")
@parameters.setter
def parameters(self, fname):
self.loadParameters(fname)
@property
def hostname(self):
return self.getHostname()
@hostname.setter
def hostname(self, hostnames):
if isinstance(hostnames, str):
hostnames = [hostnames]
if isinstance(hostnames, list):
self.setHostname(hostnames)
else:
raise ValueError("hostname needs to be string or list of strings")
@property
def fw_version(self):
return element_if_equal(self.getFirmwareVersion())
@property
def server_version(self):
#TODO! handle hex print
return element_if_equal(self.getDetectorServerVersion())
@property
def client_version(self):
return element_if_equal(self.getClientVersion())
@property
def rx_version(self):
return element_if_equal(self.getReceiverVersion())
@property
def detector_type(self):
return element_if_equal(self.getDetectorType())
@property
def dr(self):
return element_if_equal(self.getDynamicRange())
@dr.setter
def dr(self, dr):
self.setDynamicRange(dr)
@property
def module_geometry(self):
return to_geo(self.getModuleGeometry())
@property
def module_size(self):
ms = [to_geo(item) for item in self.getModuleSize()]
return element_if_equal(ms)
@property
def detector_size(self):
return to_geo(self.getDetectorSize())
@property
def settings(self):
return element_if_equal(self.getSettings())
@settings.setter
def settings(self, value):
self.setSettings(value)
@property
def frames(self):
return element_if_equal(self.getNumberOfFrames())
@frames.setter
def frames(self, n_frames):
self.setNumberOfFrames(n_frames)
@property
def exptime(self):
res = self.getExptime()
return element_if_equal([it.total_seconds() for it in res])
@exptime.setter
def exptime(self, t):
if isinstance(t, dt.timedelta):
self.setExptime(t)
else:
self.setExptime(dt.timedelta(seconds=t))
@property
def subexptime(self):
res = self.getSubExptime()
return element_if_equal([it.total_seconds() for it in res])
@subexptime.setter
def subexptime(self, t):
if isinstance(t, dt.timedelta):
self.setSubExptime(t)
else:
self.setSubExptime(dt.timedelta(seconds=t))
@property
def period(self):
res = self.getPeriod()
return element_if_equal([it.total_seconds() for it in res])
@period.setter
def period(self, t):
if isinstance(t, dt.timedelta):
self.setPeriod(t)
else:
self.setPeriod(dt.timedelta(seconds=t))
# Time
#TODO! Rename to rx_framescaught
@property
def framescaught(self):
return element_if_equal(self.getFramesCaught())
@property
def startingfnum(self):
return element_if_equal(self.getStartingFrameNumber())
@startingfnum.setter
def startingfnum(self, value):
self.setStartingFrameNumber(value)
#TODO! testing switches on automatically?
@property
def flowcontrol_10g(self):
return element_if_equal(self.getTenGigaFlowControl())
@flowcontrol_10g.setter
def flowcontrol_10g(self, enable):
self.setTenGigaFlowControl(enable)
#TODO! add txdelay
@property
def use_receiver(self):
return element_if_equal(self.getUseReceiverFlag())
@property
def rx_hostname(self):
return element_if_equal(self.getRxHostname())
@rx_hostname.setter
def rx_hostname(self, hostname):
self.setRxHostname(hostname)
@property
def rx_tcpport(self):
return element_if_equal(self.getRxPort())
@rx_tcpport.setter
def rx_tcpport(self, port):
self.setRxPort(port)
@property
def rx_fifodepth(self):
return element_if_equal(self.getRxFifoDepth())
@rx_fifodepth.setter
def rx_fifodepth(self, frames):
self.setRxFifoDepth(frames)
@property
def rx_silent(self):
return element_if_equal(self.getRxSilentMode())
@rx_silent.setter
def rx_silent(self, value):
self.setRxSilentMode(value)
@property
def rx_discardpolicy(self):
return element_if_equal(self.getRxFrameDiscardPolicy())
@rx_discardpolicy.setter
def rx_discardpolicy(self, policy):
self.setRxFrameDiscardPolicy()
@property
def rx_padding(self):
return element_if_equal(self.getPartialFramesPadding())
@rx_padding.setter
def rx_padding(self, policy):
self.setPartialFramesPadding(policy)
@property
def rx_lock(self):
"""Lock the receiver to a specific IP"""
return element_if_equal(self.getRxLock())
@rx_lock.setter
def rx_lock(self, value):
self.setRxLock(value)
@property
def rx_lastclient(self):
return element_if_equal(self.getRxLastClientIP())
#FILE
@property
def fformat(self):
return element_if_equal(self.getFileFormat())
@fformat.setter
def fformat(self, format):
self.setFileFormat(format)
@property
def findex(self):
return element_if_equal(self.getAcquisitionIndex())
@findex.setter
def findex(self, index):
self.setAcquisitionIndex(index)
@property
def fname(self):
return element_if_equal(self.getFileNamePrefix())
@fname.setter
def fname(self, file_name):
self.setFileNamePrefix(file_name)
@property
def fpath(self):
return element_if_equal(self.getFilePath())
@fpath.setter
def fpath(self, path):
self.setFilePath(path)
@property
def fwrite(self):
return element_if_equal(self.getFileWrite())
@fwrite.setter
def fwrite(self, value):
self.setFileWrite(value)
@property
def foverwrite(self):
return element_if_equal(self.getFileOverWrite())
@foverwrite.setter
def foverwrite(self, value):
self.setFileOverWrite(value)
@property
def fmaster(self):
return element_if_equal(self.getMasterFileWrite())
@fmaster.setter
def fmaster(self, enable):
self.setMasterFileWrite(enable)
@property
def rx_framesperfile(self):
return element_if_equal(self.getFramesPerFile())
@rx_framesperfile.setter
def rx_framesperfile(self, n_frames):
self.setFramesPerFile(n_frames)
# ZMQ Streaming Parameters (Receiver<->Client)
@property
def rx_datastream(self):
return element_if_equal(self.getRxZmqDataStream())
@rx_datastream.setter
def rx_zmqdatastream(self, enable):
self.setRxZmqDataStream(enable)
@property
def rx_readfreq(self):
return element_if_equal(self.getRxZmqFrequency())
@rx_readfreq.setter
def rx_readfreq(self, nth_frame):
self.setRxZmqFrequency(nth_frame)
@property
def rx_zmqport(self):
return element_if_equal(self.getRxZmqPort())
@rx_zmqport.setter
def rx_zmqport(self, port):
self.setRxZmqPort(port)
@property
def zmqport(self):
return element_if_equal(self.getClientZmqPort())
@zmqport.setter
def zmqport(self, port):
self.setClientZmqPort(port)
@property
def rx_zmqip(self):
return element_if_equal(self.getRxZmqIP())
@rx_zmqip.setter
def rx_zmqip(self, ip):
self.setRxZmqIP(ip)
@property
def zmqip(self):
return element_if_equal(self.getClientZmqIp())
@zmqip.setter
def zmqip(self, ip):
self.setClientZmqIp(ip)
@property
def udp_dstip(self):
return element_if_equal(self.getDestinationUDPIP())
@udp_dstip.setter
def udp_dstip(self, ip):
self.getDestinationUDPIP(ip)
@property
def udp_dstip2(self):
return element_if_equal(self.getDestinationUDPIP2())
@udp_dstip2.setter
def udp_dstip2(self, ip):
self.getDestinationUDPIP2(ip)
@property
def udp_dstmac(self):
return element_if_equal(self.getDestinationUDPMAC())
@udp_dstmac.setter
def udp_dstmac(self, mac):
self.getDestinationUDPMAC2(mac)
@property
def udp_dstmac2(self):
return element_if_equal(self.getDestinationUDPMAC2())
@udp_dstmac2.setter
def udp_dstmac2(self, mac):
self.getDestinationUDPMAC2(mac)
@property
def udp_dstport(self):
return element_if_equal(self.getDestinationUDPPort())
@udp_dstport.setter
def udp_dstport(self, port):
self.setDestinationUDPPort(port)
@property
def udp_dstport2(self):
return element_if_equal(self.getDestinationUDPPort2())
@udp_dstport2.setter
def udp_dstport2(self, port):
self.setDestinationUDPPort2(port)
@property
def src_udpmac(self):
return element_if_equal(self.getSourceUDPMAC())
@src_udpmac.setter
def src_udpmac(self, mac):
self.setSourceUDPMAC(mac)
@property
def src_udpip2(self):
return element_if_equal(self.getSourceUDPIP())
@src_udpip2.setter
def src_udpip2(self, ip):
self.setSourceUDPIP(ip)
@property
def src_udpip(self):
return element_if_equal(self.getSourceUDPIP())
@src_udpip.setter
def src_udpip(self, ip):
self.setSourceUDPIP(ip)
@property
def src_udpmac2(self):
return element_if_equal(self.getSourceUDPMAC2())
@src_udpmac2.setter
def src_udpmac2(self, mac):
self.setSourceUDPMAC2(mac)
@property
def vhighvoltage(self):
return element_if_equal(self.getHighVoltage())
@vhighvoltage.setter
def vhighvoltage(self, v):
self.setHighVoltage(v)
@property
def user(self):
return self.getUserDetails()
@property
def settingspath(self):
return element_if_equal(self.getSettingsPath())
@settingspath.setter
def settingspath(self, path):
self.setSettingsPath(path)
@property
def status(self):
return element_if_equal(self.getDetectorStatus())
@property
def rx_status(self):
return element_if_equal(self.getReceiverStatus())
@property
def rx_udpsocksize(self):
return element_if_equal(self.getRxUDPSocketBufferSize())
@rx_udpsocksize.setter
def rx_udpsocksize(self, buffer_size):
self.setRxUDPSocketBufferSize(buffer_size)
@property
def rx_realudpsocksize(self):
return element_if_equal(self.getRxRealUDPSocketBufferSize())
@property
def trimbits(self):
return NotImplementedError('trimbits are set only')
@trimbits.setter
def trimbits(self, fname):
self.loadTrimbits(fname)
@property
def lock(self):
return element_if_equal(self.getDetectorLock())
@lock.setter
def lock(self, value):
self.setDetectorLock(value)
@property
def rx_lock(self):
return element_if_equal(self.getRxLock())
@rx_lock.setter
def rx_lock(self, value):
self.setRxLock(value)
@property
def lastclient(self):
return element_if_equal(self.getLastClientIP())
@property
def reg(self):
return self._register
@property
def ratecorr(self):
""" tau in ns """
return element_if_equal(self.getRateCorrection())
@ratecorr.setter
def ratecorr(self, tau):
self.setRateCorrection(tau)
@property
def clkdivider(self):
res = [int(value) for value in self.getSpeed()]
return element_if_equal(res)
@clkdivider.setter
def clkdivider(self, value):
self.setSpeed(speedLevel(value))
@property
def frameindex(self):
return self.getRxCurrentFrameIndex()
@property
def threshold(self):
return element_if_equal(self.getThresholdEnergy())
@threshold.setter
def threshold(self, eV):
self.setThresholdEnergy(eV)
@property
def timing(self):
return element_if_equal(self.getTimingMode())
@timing.setter
def timing(self, mode):
self.setTimingMode(mode)
@property
def trimen(self):
return element_if_equal(self.getTrimEnergies())
@trimen.setter
def trimen(self, energies):
self.setTrimEnergies(energies)
@property
def vthreshold(self):
return element_if_equal(self.getDAC(dacIndex.THRESHOLD))

View File

@ -1,41 +0,0 @@
"""
Utility functions that are useful for testing and troubleshooting
but not directly used in controlling the detector
"""
from collections import namedtuple
import _sls_detector #C++ lib
Geometry = namedtuple('Geometry', ['x', 'y'])
def to_geo(value):
if isinstance(value, _sls_detector.xy):
return Geometry(x = value.x, y = value.y)
else:
raise ValueError("Can only convert sls_detector.xy")
def all_equal(mylist):
"""If all elements are equal return true otherwise false"""
return all(x == mylist[0] for x in mylist)
def element_if_equal(mylist):
"""If all elements are equal return only one element"""
if all_equal(mylist):
if len(mylist) == 0:
return None
else:
return mylist[0]
else:
return mylist
def eiger_register_to_time(register):
"""
Decode register value and return time in s. Values are stored in
a 32bit register with bits 2->0 containing the exponent and bits
31->3 containing the significand (int value)
"""
clocks = register >> 3
exponent = register & 0b111
return clocks*10**exponent / 100e6

23
python/slsdet/__init__.py Executable file
View File

@ -0,0 +1,23 @@
# from .detector import Detector, DetectorError, free_shared_memory
from .eiger import Eiger
from .ctb import Ctb
from .dacs import DetectorDacs, Dac
from .detector import Detector
from .jungfrau import Jungfrau
from .mythen3 import Mythen3
# from .jungfrau_ctb import JungfrauCTB
# from _slsdet import DetectorApi
import _slsdet
defs = _slsdet.slsDetectorDefs
runStatus = _slsdet.slsDetectorDefs.runStatus
speedLevel = _slsdet.slsDetectorDefs.speedLevel
timingMode = _slsdet.slsDetectorDefs.timingMode
dacIndex = _slsdet.slsDetectorDefs.dacIndex
detectorType = _slsdet.slsDetectorDefs.detectorType
detectorSettings = _slsdet.slsDetectorDefs.detectorSettings
readoutMode = _slsdet.slsDetectorDefs.readoutMode
IpAddr = _slsdet.IpAddr
MacAddr = _slsdet.MacAddr

43
python/slsdet/ctb.py Normal file
View File

@ -0,0 +1,43 @@
from .detector import Detector
from .utils import element_if_equal
from .dacs import DetectorDacs
import _slsdet
dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
class CtbDacs(DetectorDacs):
"""
Ctb dacs
"""
_dacs = [('dac0', dacIndex(0), 0, 4000, 1400),
('dac1', dacIndex(1), 0, 4000, 1200),
('dac2', dacIndex(2), 0, 4000, 900),
('dac3', dacIndex(3), 0, 4000, 1050),
('dac4', dacIndex(4), 0, 4000, 1400),
('dac5', dacIndex(5), 0, 4000, 655),
('dac6', dacIndex(6), 0, 4000, 2000),
('dac7', dacIndex(7), 0, 4000, 1400),
('dac8', dacIndex(8), 0, 4000, 850),
('dac9', dacIndex(9), 0, 4000, 2000),
('dac10', dacIndex(10), 0, 4000, 2294),
('dac11', dacIndex(11), 0, 4000, 983),
('dac12', dacIndex(12), 0, 4000, 1475),
('dac13', dacIndex(13), 0, 4000, 1200),
('dac14', dacIndex(14), 0, 4000, 1600),
('dac15', dacIndex(15), 0, 4000, 1455),
('dac16', dacIndex(16), 0, 4000, 0),
('dac17', dacIndex(17), 0, 4000, 1000),
]
_dacnames = [_d[0] for _d in _dacs]
from .utils import element
class Ctb(Detector):
def __init__(self, id = 0):
super().__init__(id)
self._frozen = False
self._dacs = CtbDacs(self)
@property
def dacs(self):
return self._dacs

View File

@ -1,7 +1,9 @@
from .detector_property import DetectorProperty
from functools import partial
import numpy as np
import _slsdet
from .detector import freeze
dacIndex = _slsdet.slsDetectorDefs.dacIndex
class Dac(DetectorProperty):
"""
This class represents a dac on the detector. One instance handles all
@ -14,11 +16,11 @@ class Dac(DetectorProperty):
"""
def __init__(self, name, low, high, default, detector):
def __init__(self, name, enum, low, high, default, detector):
super().__init__(partial(detector._api.getDac, name),
partial(detector._api.setDac, name),
detector._api.getNumberOfDetectors,
super().__init__(partial(detector.getDAC, enum, False),
lambda x, y : detector.setDAC(enum, x, False, y),
detector.size,
name)
self.min_value = low
@ -29,30 +31,16 @@ class Dac(DetectorProperty):
def __repr__(self):
"""String representation for a single dac in all modules"""
r_str = ['{:10s}: '.format(self.__name__)]
r_str += ['{:5d}, '.format(self.get(i)) for i in range(self.get_nmod())]
return ''.join(r_str).strip(', ')
dacstr = ''.join([f'{item:5d}' for item in self.get()])
return f'{self.__name__:10s}:{dacstr}'
# a = Dac('vrf', dacIndex.VRF, 0, 4000, 2500, d )
# @freeze
class DetectorDacs:
_dacs = [('vsvp', 0, 4000, 0),
('vtr', 0, 4000, 2500),
('vrf', 0, 4000, 3300),
('vrs', 0, 4000, 1400),
('vsvn', 0, 4000, 4000),
('vtgstv', 0, 4000, 2556),
('vcmp_ll', 0, 4000, 1500),
('vcmp_lr', 0, 4000, 1500),
('vcall', 0, 4000, 4000),
('vcmp_rl', 0, 4000, 1500),
('rxb_rb', 0, 4000, 1100),
('rxb_lb', 0, 4000, 1100),
('vcmp_rr', 0, 4000, 1500),
('vcp', 0, 4000, 200),
('vcn', 0, 4000, 2000),
('vis', 0, 4000, 1550),
('iodelay', 0, 4000, 660)]
_dacs = []
_dacnames = [_d[0] for _d in _dacs]
_allowed_attr = ['_detector', '_current']
_frozen = False
def __init__(self, detector):
# We need to at least initially know which detector we are connected to
@ -65,6 +53,8 @@ class DetectorDacs:
for _d in self._dacs:
setattr(self, '_'+_d[0], Dac(*_d, detector))
self._frozen = True
def __getattr__(self, name):
return self.__getattribute__('_' + name)
@ -73,8 +63,11 @@ class DetectorDacs:
if name in self._dacnames:
return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value)
else:
if self._frozen == True and name not in self._allowed_attr:
raise AttributeError(f'Dac not found: {name}')
super().__setattr__(name, value)
def __next__(self):
if self._current >= len(self._dacs):
self._current = 0
@ -95,7 +88,7 @@ class DetectorDacs:
"""
Read the dacs into a numpy array with dimensions [ndacs, nmodules]
"""
dac_array = np.zeros((len(self._dacs), self._detector.n_modules))
dac_array = np.zeros((len(self._dacs), len(self._detector)))
for i, _d in enumerate(self):
dac_array[i,:] = _d[:]
return dac_array
@ -115,11 +108,3 @@ class DetectorDacs:
for _d in self:
_d[:] = _d.default
def update_nmod(self):
"""
Update the cached value of nmod, needs to be run after adding or
removing detectors
"""
for _d in self:
_d._n_modules = self._detector.n_modules

1194
python/slsdet/detector.py Executable file

File diff suppressed because it is too large Load Diff

View File

@ -14,21 +14,20 @@ class DetectorProperty:
def __getitem__(self, key):
if key == slice(None, None, None):
return [self.get(i) for i in range(self.get_nmod())]
return self.get()
elif isinstance(key, Iterable):
return [self.get(k) for k in key]
return self.get(list(key))
else:
return self.get(key)
return self.get([key])[0] #No list for single value
def __setitem__(self, key, value):
#operate on all values
if key == slice(None, None, None):
if isinstance(value, (np.integer, int)):
for i in range(self.get_nmod()):
self.set(i, value)
self.set(value, [])
elif isinstance(value, Iterable):
for i in range(self.get_nmod()):
self.set(i, value[i])
self.set(value[i], [i])
else:
raise ValueError('Value should be int or np.integer not', type(value))
@ -36,15 +35,14 @@ class DetectorProperty:
elif isinstance(key, Iterable):
if isinstance(value, Iterable):
for k,v in zip(key, value):
self.set(k,v)
self.set(v, [k])
elif isinstance(value, int):
for k in key:
self.set(k, value)
self.set(value, list(key))
#Set single value
elif isinstance(key, int):
self.set(key, value)
self.set(value, [key])
def __repr__(self):
s = ', '.join(str(v) for v in self[:])

476
python/slsdet/eiger.py Executable file
View File

@ -0,0 +1,476 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 6 11:51:18 2017
@author: l_frojdh
"""
from .detector import Detector
# from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs
import _slsdet
dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
# from .utils import element_if_equal
# from sls_detector.errors import DetectorValueError, DetectorError
class EigerVcmp:
"""
Convenience class to be able to loop over vcmp for Eiger
.. todo::
Support single assignment and perhaps unify with Dac class
"""
def __init__(self, detector):
_dacs = [ dacIndex.VCMP_LL,
dacIndex.VCMP_LR,
dacIndex.VCMP_RL,
dacIndex.VCMP_RR]
self.set = []
self.get = []
for i in range(detector.size()):
if i % 2 == 0:
dacs = _dacs
else:
dacs = _dacs[::-1]
for d in dacs:
self.set.append(lambda x, d=d, i=i : detector.setDAC(d, x, False, [i]))
self.get.append(lambda d=d, i=i : detector.getDAC(d, False, [i])[0])
def __getitem__(self, key):
if key == slice(None, None, None):
return [_d() for _d in self.get]
return self.get[key]()
def __setitem__(self, i, value):
self.set[i](value)
def __repr__(self):
return 'vcmp: '+ str(self[:])
class EigerDacs(DetectorDacs):
"""
Eiger specific dacs
"""
_dacs = [('vsvp', dacIndex.SVP,0, 4000, 0),
('vtr', dacIndex.VTR,0, 4000, 2500),
('vrf', dacIndex.VRF,0, 4000, 3300),
('vrs', dacIndex.VRS,0, 4000, 1400),
('vsvn', dacIndex.SVN,0, 4000, 4000),
('vtgstv', dacIndex.VTGSTV,0, 4000, 2556),
('vcmp_ll', dacIndex.VCMP_LL,0, 4000, 1500),
('vcmp_lr', dacIndex.VCMP_LR,0, 4000, 1500),
('vcall', dacIndex.CAL,0, 4000, 4000),
('vcmp_rl', dacIndex.VCMP_RL,0, 4000, 1500),
('rxb_rb', dacIndex.RXB_RB,0, 4000, 1100),
('rxb_lb', dacIndex.RXB_LB,0, 4000, 1100),
('vcmp_rr', dacIndex.VCMP_RR,0, 4000, 1500),
('vcp', dacIndex.VCP,0, 4000, 200),
('vcn', dacIndex.VCN,0, 4000, 2000),
('vis', dacIndex.VIS,0, 4000, 1550),
('iodelay', dacIndex.IO_DELAY,0, 4000, 660)]
_dacnames = [_d[0] for _d in _dacs]
# # noinspection PyProtectedMember
# class DetectorDelays:
# _delaynames = ['frame', 'left', 'right']
# def __init__(self, detector):
# # We need to at least initially know which detector we are connected to
# self._detector = detector
# setattr(self, '_frame', DetectorProperty(detector._api.getDelayFrame,
# detector._api.setDelayFrame,
# detector._api.getNumberOfDetectors,
# 'frame'))
# setattr(self, '_left', DetectorProperty(detector._api.getDelayLeft,
# detector._api.setDelayLeft,
# detector._api.getNumberOfDetectors,
# 'left'))
# setattr(self, '_right', DetectorProperty(detector._api.getDelayRight,
# detector._api.setDelayRight,
# detector._api.getNumberOfDetectors,
# 'right'))
# # Index to support iteration
# self._current = 0
# def __getattr__(self, name):
# return self.__getattribute__('_' + name)
# def __setattr__(self, name, value):
# if name in self._delaynames:
# return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value)
# else:
# super().__setattr__(name, value)
# def __next__(self):
# if self._current >= len(self._delaynames):
# self._current = 0
# raise StopIteration
# else:
# self._current += 1
# return self.__getattr__(self._delaynames[self._current-1])
# def __iter__(self):
# return self
# def __repr__(self):
# hn = self._detector.hostname
# r_str = ['Transmission delay [ns]\n'
# '{:11s}{:>8s}{:>8s}{:>8s}'.format('', 'left', 'right', 'frame')]
# for i in range(self._detector.n_modules):
# r_str.append('{:2d}:{:8s}{:>8d}{:>8d}{:>8d}'.format(i, hn[i], self.left[i], self.right[i], self.frame[i]))
# return '\n'.join(r_str)
from .detector import freeze
@freeze
class Eiger(Detector):
"""
Subclassing Detector to set up correct dacs and detector specific
functions.
"""
_detector_dynamic_range = [4, 8, 16, 32]
_settings = ['standard', 'highgain', 'lowgain', 'veryhighgain', 'verylowgain']
"""available settings for Eiger, note almost always standard"""
def __init__(self, id=0):
super().__init__(id)
self._frozen = False
self._dacs = EigerDacs(self)
self._vcmp = EigerVcmp(self)
# self._active = DetectorProperty(self.getActive,
# self.setActive,
# self.size,
# 'active')
# self._trimbit_limits = namedtuple('trimbit_limits', ['min', 'max'])(0, 63)
# self._delay = DetectorDelays(self)
# # Eiger specific adcs
# self._temp = DetectorAdcs()
# self._temp.fpga = Adc('temp_fpga', self)
# self._temp.fpgaext = Adc('temp_fpgaext', self)
# self._temp.t10ge = Adc('temp_10ge', self)
# self._temp.dcdc = Adc('temp_dcdc', self)
# self._temp.sodl = Adc('temp_sodl', self)
# self._temp.sodr = Adc('temp_sodr', self)
# self._temp.fpgafl = Adc('temp_fpgafl', self)
# self._temp.fpgafr = Adc('temp_fpgafr', self)
# @property
# def active(self):
# """
# Is the detector active? Can be used to enable or disable a detector
# module
# Examples
# ----------
# ::
# d.active
# >> active: [True, True]
# d.active[1] = False
# >> active: [True, False]
# """
# return self._active
# @active.setter
# def active(self, value):
# self._active[:] = value
# @property
# def measured_period(self):
# return self._api.getMeasuredPeriod()
# @property
# def measured_subperiod(self):
# return self._api.getMeasuredSubPeriod()
# @property
# def add_gappixels(self):
# """Enable or disable the (virual) pixels between ASICs
# Examples
# ----------
# ::
# d.add_gappixels = True
# d.add_gappixels
# >> True
# """
# return self._api.getGapPixels()
# @add_gappixels.setter
# def add_gappixels(self, value):
# self._api.setGapPixels(value)
@property
def dacs(self):
"""
An instance of DetectorDacs used for accessing the dacs of a single
or multi detector.
Examples
---------
::
d = Eiger()
#Set all vrf to 1500
d.dacs.vrf = 1500
#Check vrf
d.dacs.vrf
>> vrf : 1500, 1500
#Set a single vtr
d.dacs.vtr[0] = 1800
#Set vrf with multiple values
d.dacs.vrf = [3500,3700]
d.dacs.vrf
>> vrf : 3500, 3700
#read into a variable
var = d.dacs.vrf[:]
#set multiple with multiple values, mostly used for large systems
d.dacs.vcall[0,1] = [3500,3600]
d.dacs.vcall
>> vcall : 3500, 3600
d.dacs
>>
========== DACS =========
vsvp : 0, 0
vtr : 4000, 4000
vrf : 1900, 1900
vrs : 1400, 1400
vsvn : 4000, 4000
vtgstv : 2556, 2556
vcmp_ll : 1500, 1500
vcmp_lr : 1500, 1500
vcall : 4000, 4000
vcmp_rl : 1500, 1500
rxb_rb : 1100, 1100
rxb_lb : 1100, 1100
vcmp_rr : 1500, 1500
vcp : 1500, 1500
vcn : 2000, 2000
vis : 1550, 1550
iodelay : 660, 660
"""
return self._dacs
# @property
# def tx_delay(self):
# """
# Transmission delay of the modules to allow running the detector
# in a network not supporting the full speed of the detector.
# ::
# d.tx_delay
# >>
# Transmission delay [ns]
# left right frame
# 0:beb048 0 15000 0
# 1:beb049 100 190000 100
# d.tx_delay.left = [2000,5000]
# """
# return self._delay
# def pulse_all_pixels(self, n):
# """
# Pulse each pixel of the chip **n** times using the analog test pulses.
# The pulse height is set using d.dacs.vcall with 4000 being 0 and 0 being
# the highest pulse.
# ::
# #Pulse all pixels ten times
# d.pulse_all_pixels(10)
# #Avoid resetting before acq
# d.eiger_matrix_reset = False
# d.acq() #take frame
# #Restore normal behaviour
# d.eiger_matrix_reset = True
# """
# self._api.pulseAllPixels(n)
# def pulse_diagonal(self, n):
# """
# Pulse pixels in super colums in a diagonal fashion. Used for calibration
# of vcall. Saves time compared to pulsing all pixels.
# """
# self._api.pulseDiagonal(n)
# def pulse_chip(self, n):
# """
# Advance the counter by toggling enable. Gives 2*n+2 int the counter
# """
# n = int(n)
# if n >= -1:
# self._api.pulseChip(n)
# else:
# raise ValueError('n must be equal or larger than -1')
@property
def vcmp(self):
"""
Convenience function to get and set the individual vcmp of chips
Used mainly in the calibration code.
Examples
---------
::
#Reading
d.vcmp[:]
>> [500, 500, 500, 500, 500, 500, 500, 500]
#Setting
d.vcmp = [500, 500, 500, 500, 500, 500, 500, 500]
"""
return self._vcmp
@vcmp.setter
def vcmp(self, values):
if len(values) == len(self._vcmp.set):
for i, v in enumerate(values):
self._vcmp.set[i](v)
else:
raise ValueError('vcmp only compatible with setting all')
# @property
# def rx_udpport(self):
# """
# UDP port for the receiver. Each module has two ports referred to
# as rx_udpport and rx_udpport2 in the command line interface
# here they are grouped for each detector
# ::
# [0:rx_udpport, 0:rx_udpport2, 1:rx_udpport ...]
# Examples
# -----------
# ::
# d.rx_udpport
# >> [50010, 50011, 50004, 50005]
# d.rx_udpport = [50010, 50011, 50012, 50013]
# """
# p0 = self._api.getReceiverUDPPort()
# p1 = self._api.getReceiverUDPPort2()
# return [int(val) for pair in zip(p0, p1) for val in pair]
# @rx_udpport.setter
# def rx_udpport(self, ports):
# """Requires iterating over elements two and two for setting ports"""
# a = iter(ports)
# for i, p in enumerate(zip(a, a)):
# self._api.setReceiverUDPPort(p[0], i)
# self._api.setReceiverUDPPort2(p[1], i)
@property
def rx_zmqport(self):
"""
Return the receiver zmq ports. Note that Eiger has two ports per receiver!
This functions therefore differ from the base class.
::
e.rx_zmqport
>> [30001, 30002, 30003, 30004]
"""
ports = self.getRxZmqPort()
return [p + i for p in ports for i in range(2)]
# @rx_zmqport.setter
# def rx_zmqport(self, port):
# if isinstance(port, Iterable):
# for i, p in enumerate(port):
# self._api.setReceiverStreamingPort(p, i)
# else:
# self._api.setReceiverStreamingPort(port, -1)
# @property
# def temp(self):
# """
# An instance of DetectorAdcs used to read the temperature
# of different components
# Examples
# -----------
# ::
# detector.temp
# >>
# temp_fpga : 36.90°C, 45.60°C
# temp_fpgaext : 31.50°C, 32.50°C
# temp_10ge : 0.00°C, 0.00°C
# temp_dcdc : 36.00°C, 36.00°C
# temp_sodl : 33.00°C, 34.50°C
# temp_sodr : 33.50°C, 34.00°C
# temp_fpgafl : 33.81°C, 30.93°C
# temp_fpgafr : 27.88°C, 29.15°C
# a = detector.temp.fpga[:]
# a
# >> [36.568, 45.542]
# """
# return self._temp
# def set_delays(self, delta):
# self.tx_delay.left = [delta*(i*2) for i in range(self.n_modules)]
# self.tx_delay.right = [delta*(i*2+1) for i in range(self.n_modules)]

54
python/slsdet/jungfrau.py Normal file
View File

@ -0,0 +1,54 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This file contains the specialization for the Jungfrau detector
"""
from .detector import Detector, freeze
# from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs
import _slsdet
dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
# @freeze
class JungfrauDacs(DetectorDacs):
"""
Jungfrau specific DACs
"""
_dacs = [('vb_comp', dacIndex.VB_COMP, 0, 4000, 1220),
('vdd_prot', dacIndex.VDD_PROT, 0, 4000, 3000),
('vin_com', dacIndex.VIN_COM, 0, 4000, 1053),
('vref_prech', dacIndex.VREF_PRECH, 0, 4000, 1450),
('vb_pixbuff', dacIndex.VB_PIXBUF, 0, 4000, 750),
('vb_ds', dacIndex.VB_DS, 0, 4000, 1000),
('vref_ds', dacIndex.VREF_DS, 0, 4000, 480),
('vref_comp', dacIndex.VREF_COMP, 0, 4000, 420),
]
_dacnames = [_d[0] for _d in _dacs]
@freeze
class Jungfrau(Detector):
"""
Subclassing Detector to set up correct dacs and detector specific
functions.
"""
_detector_dynamic_range = [4, 8, 16, 32]
_settings = ['standard', 'highgain', 'lowgain', 'veryhighgain', 'verylowgain']
"""available settings for Eiger, note almost always standard"""
def __init__(self, id=0):
super().__init__(id)
self._frozen = False
self._dacs = JungfrauDacs(self)
@property
def dacs(self):
return self._dacs

9
python/slsdet/lookup.py Normal file
View File

@ -0,0 +1,9 @@
from .detector import Detector
def view(name, det = Detector):
names = find(name, det)
for n in names:
print(n)
def find(name, det = Detector):
return [n for n in dir(det) if name.lower() in n.lower()]

80
python/slsdet/mythen3.py Normal file
View File

@ -0,0 +1,80 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This file contains the specialization for the Jungfrau detector
"""
from .detector import Detector, freeze
# from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs
import _slsdet
dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
# vcassh 1200,
# vth2 2800,
# vshaper 1280,
# vshaperneg 2800,
# vipre_out 1220,
# vth3 2800,
# vth1 2800,
# vicin 1708,
# vcas 1800,
# vpreamp 1100,
# vpl 1100,
# vipre 2624,
# viinsh 1708,
# vph 1712,
# vtrim 2800,
# vdcsh 800
# @freeze
class Mythen3Dacs(DetectorDacs):
"""
Jungfrau specific DACs
"""
_dacs = [('vcassh', dacIndex.CASSH, 0, 4000, 1220),
('vth2', dacIndex.VTH2, 0, 4000, 2800),
('vshaper', dacIndex.SHAPER1, 0, 4000, 1280),
('vshaperneg', dacIndex.SHAPER2, 0, 4000, 2800),
('vipre_out', dacIndex.VIPRE_OUT, 0, 4000, 1220),
('vth3', dacIndex.VTH3, 0, 4000, 2800),
('vth1', dacIndex.THRESHOLD, 0, 4000, 2800),
('vicin', dacIndex.VICIN, 0, 4000, 1708),
('vcas', dacIndex.CAS, 0, 4000, 1800),
('vpreamp', dacIndex.PREAMP, 0, 4000, 1100),
('vpl', dacIndex.VPL, 0, 4000, 1100),
('vipre', dacIndex.VIPRE, 0, 4000, 2624),
('viinsh', dacIndex.VIINSH, 0, 4000, 1708),
('vph', dacIndex.CALIBRATION_PULSE, 0, 4000, 1712),
('vtrim', dacIndex.TRIMBIT_SIZE, 0, 4000, 2800),
('vdcsh', dacIndex.VDCSH, 0, 4000, 800),
]
_dacnames = [_d[0] for _d in _dacs]
@freeze
class Mythen3(Detector):
"""
Subclassing Detector to set up correct dacs and detector specific
functions.
"""
_detector_dynamic_range = [4, 8, 16, 32]
_settings = ['standard', 'highgain', 'lowgain', 'veryhighgain', 'verylowgain']
"""available settings for Eiger, note almost always standard"""
def __init__(self, id=0):
super().__init__(id)
self._frozen = False
self._dacs = Mythen3Dacs(self)
@property
def dacs(self):
return self._dacs

View File

@ -3,14 +3,17 @@ class Register:
self._detector = detector
def __getitem__(self, key):
return self._detector._api.readRegister(key)
return self._detector.readRegister(key)
def __setitem__(self, key, value):
self._detector._api.writeRegister(key, value)
self._detector.writeRegister(key, value)
class Adc_register:
def __init__(self, detector):
self._detector = detector
def __setitem__(self, key, value):
self._detector._api.writeAdcRegister(key, value)
self._detector.writeAdcRegister(key, value)
def __getitem__(self, key):
raise ValueError('Adc registers cannot be read back')

95
python/slsdet/utils.py Executable file
View File

@ -0,0 +1,95 @@
"""
Utility functions that are useful for testing and troubleshooting
but not directly used in controlling the detector
"""
from collections import namedtuple
import _slsdet #C++ lib
import functools
import datetime as dt
Geometry = namedtuple('Geometry', ['x', 'y'])
def is_iterable(item):
try:
iter(item)
except TypeError:
return False
return True
def get_set_bits(mask):
"""
Return a list of the set bits in a python integer
"""
return [i for i in range(mask.bit_length()) if (mask>>i)&1]
def list_to_bitmask(values):
"""
Convert a list of integers to a bitmask with set bits
where the list indicates
"""
mask = int(0)
values = list(set(values)) #Remove duplicates
for v in values:
mask += 1 << v
return mask
def to_geo(value):
if isinstance(value, _slsdet.xy):
return Geometry(x = value.x, y = value.y)
else:
raise ValueError("Can only convert sls_detector.xy")
def all_equal(mylist):
"""If all elements are equal return true otherwise false"""
return all(x == mylist[0] for x in mylist)
def element_if_equal(mylist):
"""If all elements are equal return only one element"""
if not is_iterable(mylist):
return mylist
if all_equal(mylist):
if len(mylist) == 0:
return None
else:
return mylist[0]
else:
return mylist
def reduce_time(mylist):
res = element_if_equal(element_if_equal(mylist))
if isinstance(res, dt.timedelta):
return res.total_seconds()
elif isinstance(res[0], list):
return [[item.total_seconds() for item in subl] for subl in res]
else:
return [r.total_seconds() for r in res]
def element(func):
"""
Wrapper to return either list or element
"""
@functools.wraps(func)
def wrapper(self, *args, **kwargs):
return element_if_equal(func(self, *args, **kwargs))
return wrapper
def eiger_register_to_time(register):
"""
Decode register value and return time in s. Values are stored in
a 32bit register with bits 2->0 containing the exponent and bits
31->3 containing the significand (int value)
"""
clocks = register >> 3
exponent = register & 0b111
return clocks*10**exponent / 100e6
def make_timedelta(t):
if isinstance(t, dt.timedelta):
return t
else:
return dt.timedelta(seconds=t)

View File

@ -2,7 +2,7 @@ C++ API
=====================================================
.. py:currentmodule:: _sls_detector
.. py:currentmodule:: _slsdet
.. autoclass:: DetectorApi
:members:

View File

@ -2,7 +2,7 @@ sls_detector - Python interface for the slsDetectorsPackage
==============================================================
sls_detector provide Python bindings to the slsDetectorsPackage using mainly the
multiSlsDetector API. This module contains two parts, a compiled C module to
DetectorImpl API. This module contains two parts, a compiled C module to
expose the API and a Python class to offer a more Pythonic interface.

1411
python/src/detector.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
#include <pybind11/chrono.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "Detector.h"
#include "ToString.h"
#include "network_utils.h"
#include "sls_detector_defs.h"
#include "typecaster.h"
#include "TimeHelper.h"
#include <array>
#include <chrono>
namespace py = pybind11;
void init_det(py::module &m) {
using sls::Detector;
using sls::Positions;
using sls::Result;
using sls::defs;
using sls::ns;
py::class_<Detector> CppDetectorApi(m, "CppDetectorApi");
CppDetectorApi
.def(py::init<int>())
[[FUNCTIONS]]
}

View File

@ -65,38 +65,14 @@ void init_enums(py::module &m) {
.export_values();
py::enum_<slsDetectorDefs::externalSignalFlag>(Defs, "externalSignalFlag")
.value("GET_EXTERNAL_SIGNAL_FLAG",
slsDetectorDefs::externalSignalFlag::GET_EXTERNAL_SIGNAL_FLAG)
.value("SIGNAL_OFF", slsDetectorDefs::externalSignalFlag::SIGNAL_OFF)
.value("GATE_IN_ACTIVE_HIGH",
slsDetectorDefs::externalSignalFlag::GATE_IN_ACTIVE_HIGH)
.value("GATE_IN_ACTIVE_LOW",
slsDetectorDefs::externalSignalFlag::GATE_IN_ACTIVE_LOW)
.value("TRIGGER_IN_RISING_EDGE",
slsDetectorDefs::externalSignalFlag::TRIGGER_IN_RISING_EDGE)
.value("TRIGGER_IN_FALLING_EDGE",
slsDetectorDefs::externalSignalFlag::TRIGGER_IN_FALLING_EDGE)
.value("RO_TRIGGER_IN_RISING_EDGE",
slsDetectorDefs::externalSignalFlag::RO_TRIGGER_IN_RISING_EDGE)
.value("RO_TRIGGER_IN_FALLING_EDGE",
slsDetectorDefs::externalSignalFlag::RO_TRIGGER_IN_FALLING_EDGE)
.value("GATE_OUT_ACTIVE_HIGH",
slsDetectorDefs::externalSignalFlag::GATE_OUT_ACTIVE_HIGH)
.value("GATE_OUT_ACTIVE_LOW",
slsDetectorDefs::externalSignalFlag::GATE_OUT_ACTIVE_LOW)
.value("TRIGGER_OUT_RISING_EDGE",
slsDetectorDefs::externalSignalFlag::TRIGGER_OUT_RISING_EDGE)
.value("TRIGGER_OUT_FALLING_EDGE",
slsDetectorDefs::externalSignalFlag::TRIGGER_OUT_FALLING_EDGE)
.value("RO_TRIGGER_OUT_RISING_EDGE",
slsDetectorDefs::externalSignalFlag::RO_TRIGGER_OUT_RISING_EDGE)
.value("RO_TRIGGER_OUT_FALLING_EDGE",
slsDetectorDefs::externalSignalFlag::RO_TRIGGER_OUT_FALLING_EDGE)
.value("OUTPUT_LOW", slsDetectorDefs::externalSignalFlag::OUTPUT_LOW)
.value("OUTPUT_HIGH", slsDetectorDefs::externalSignalFlag::OUTPUT_HIGH)
.value(
"MASTER_SLAVE_SYNCHRONIZATION",
slsDetectorDefs::externalSignalFlag::MASTER_SLAVE_SYNCHRONIZATION)
.value("INVERSION_ON",
slsDetectorDefs::externalSignalFlag::INVERSION_ON)
.value("INVERSION_OFF",
slsDetectorDefs::externalSignalFlag::INVERSION_OFF)
.export_values();
py::enum_<slsDetectorDefs::timingMode>(Defs, "timingMode")
@ -106,6 +82,9 @@ void init_enums(py::module &m) {
slsDetectorDefs::timingMode::TRIGGER_EXPOSURE)
.value("GATED", slsDetectorDefs::timingMode::GATED)
.value("BURST_TRIGGER", slsDetectorDefs::timingMode::BURST_TRIGGER)
.value("TRIGGER_GATED", slsDetectorDefs::timingMode::TRIGGER_GATED)
.value("NUM_TIMING_MODES",
slsDetectorDefs::timingMode::NUM_TIMING_MODES)
.export_values();
py::enum_<slsDetectorDefs::dacIndex>(Defs, "dacIndex")
@ -169,7 +148,7 @@ void init_enums(py::module &m) {
.value("VB_COMP_FE", slsDetectorDefs::dacIndex::VB_COMP_FE)
.value("VB_COMP_ADC", slsDetectorDefs::dacIndex::VB_COMP_ADC)
.value("VCOM_CDS", slsDetectorDefs::dacIndex::VCOM_CDS)
.value("VREF_RESTORE", slsDetectorDefs::dacIndex::VREF_RESTORE)
.value("VREF_RSTORE", slsDetectorDefs::dacIndex::VREF_RSTORE)
.value("VB_OPA_1ST", slsDetectorDefs::dacIndex::VB_OPA_1ST)
.value("VREF_COMP_FE", slsDetectorDefs::dacIndex::VREF_COMP_FE)
.value("VCOM_ADC1", slsDetectorDefs::dacIndex::VCOM_ADC1)
@ -184,6 +163,11 @@ void init_enums(py::module &m) {
.value("VB_PIXBUF", slsDetectorDefs::dacIndex::VB_PIXBUF)
.value("VIN_COM", slsDetectorDefs::dacIndex::VIN_COM)
.value("VDD_PROT", slsDetectorDefs::dacIndex::VDD_PROT)
.value("VBP_COLBUF", slsDetectorDefs::dacIndex::VBP_COLBUF)
.value("VB_SDA", slsDetectorDefs::dacIndex::VB_SDA)
.value("VCASC_SFP", slsDetectorDefs::dacIndex::VCASC_SFP)
.value("VIPRE_CDS", slsDetectorDefs::dacIndex::VIPRE_CDS)
.value("IBIAS_SFP", slsDetectorDefs::dacIndex::IBIAS_SFP)
.value("V_POWER_A", slsDetectorDefs::dacIndex::V_POWER_A)
.value("V_POWER_B", slsDetectorDefs::dacIndex::V_POWER_B)
.value("V_POWER_C", slsDetectorDefs::dacIndex::V_POWER_C)
@ -224,6 +208,18 @@ void init_enums(py::module &m) {
.value("FORCESWITCHG2",
slsDetectorDefs::detectorSettings::FORCESWITCHG2)
.value("VERYLOWGAIN", slsDetectorDefs::detectorSettings::VERYLOWGAIN)
.value("G1_HIGHGAIN", slsDetectorDefs::detectorSettings::G1_HIGHGAIN)
.value("G1_LOWGAIN", slsDetectorDefs::detectorSettings::G1_LOWGAIN)
.value("G2_HIGHCAP_HIGHGAIN",
slsDetectorDefs::detectorSettings::G2_HIGHCAP_HIGHGAIN)
.value("G2_HIGHCAP_LOWGAIN",
slsDetectorDefs::detectorSettings::G2_HIGHCAP_LOWGAIN)
.value("G2_LOWCAP_HIGHGAIN",
slsDetectorDefs::detectorSettings::G2_LOWCAP_HIGHGAIN)
.value("G2_LOWCAP_LOWGAIN",
slsDetectorDefs::detectorSettings::G2_LOWCAP_LOWGAIN)
.value("G4_HIGHGAIN", slsDetectorDefs::detectorSettings::G4_HIGHGAIN)
.value("G4_LOWGAIN", slsDetectorDefs::detectorSettings::G4_LOWGAIN)
.value("UNDEFINED", slsDetectorDefs::detectorSettings::UNDEFINED)
.value("UNINITIALIZED",
slsDetectorDefs::detectorSettings::UNINITIALIZED)
@ -231,22 +227,22 @@ void init_enums(py::module &m) {
py::enum_<slsDetectorDefs::clockIndex>(Defs, "clockIndex")
.value("ADC_CLOCK", slsDetectorDefs::clockIndex::ADC_CLOCK)
.value("DBIT_CLOCK", slsDetectorDefs::clockIndex::DBIT_CLOCK)
.value("RUN_CLOCK", slsDetectorDefs::clockIndex::RUN_CLOCK)
.value("SYNC_CLOCK", slsDetectorDefs::clockIndex::SYNC_CLOCK)
.value(" DBIT_CLOCK", slsDetectorDefs::clockIndex::DBIT_CLOCK)
.value(" RUN_CLOCK", slsDetectorDefs::clockIndex::RUN_CLOCK)
.value(" SYNC_CLOCK", slsDetectorDefs::clockIndex::SYNC_CLOCK)
.export_values();
py::enum_<slsDetectorDefs::readoutMode>(Defs, "readoutMode")
.value("ANALOG_ONLY", slsDetectorDefs::readoutMode::ANALOG_ONLY)
.value("DIGITAL_ONLY", slsDetectorDefs::readoutMode::DIGITAL_ONLY)
.value("ANALOG_AND_DIGITAL",
.value(" DIGITAL_ONLY", slsDetectorDefs::readoutMode::DIGITAL_ONLY)
.value(" ANALOG_AND_DIGITAL",
slsDetectorDefs::readoutMode::ANALOG_AND_DIGITAL)
.export_values();
py::enum_<slsDetectorDefs::speedLevel>(Defs, "speedLevel")
.value("FULL_SPEED", slsDetectorDefs::speedLevel::FULL_SPEED)
.value("HALF_SPEED", slsDetectorDefs::speedLevel::HALF_SPEED)
.value("QUARTER_SPEED", slsDetectorDefs::speedLevel::QUARTER_SPEED)
.value(" HALF_SPEED", slsDetectorDefs::speedLevel::HALF_SPEED)
.value(" QUARTER_SPEED", slsDetectorDefs::speedLevel::QUARTER_SPEED)
.export_values();
py::enum_<slsDetectorDefs::portType>(Defs, "portType")
@ -278,4 +274,18 @@ void init_enums(py::module &m) {
slsDetectorDefs::detectorModeType::INTERPOLATING)
.value("ANALOG", slsDetectorDefs::detectorModeType::ANALOG)
.export_values();
py::enum_<slsDetectorDefs::burstMode>(Defs, "burstMode")
.value("BURST_OFF", slsDetectorDefs::burstMode::BURST_OFF)
.value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL)
.value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL)
.value("NUM_BURST_MODES", slsDetectorDefs::burstMode::NUM_BURST_MODES)
.export_values();
py::enum_<slsDetectorDefs::timingSourceType>(Defs, "timingSourceType")
.value("TIMING_INTERNAL",
slsDetectorDefs::timingSourceType::TIMING_INTERNAL)
.value(" TIMING_EXTERNAL",
slsDetectorDefs::timingSourceType::TIMING_EXTERNAL)
.export_values();
}

View File

@ -1,616 +0,0 @@
#include <pybind11/chrono.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "Detector.h"
#include "ToString.h"
#include "network_utils.h"
#include "sls_detector_defs.h"
#include "typecaster.h"
namespace py = pybind11;
void init_experimental(py::module &m) {
using sls::Detector;
using sls::Positions;
using defs = slsDetectorDefs;
py::class_<Detector> CppDetectorApi(m, "CppDetectorApi");
CppDetectorApi
.def(py::init<int>())
// Configuration
.def("freeSharedMemory", (void (Detector::*)()) &Detector::freeSharedMemory)
.def("loadConfig", &Detector::loadConfig)
.def("loadParameters", &Detector::loadParameters)
.def("setHostname", &Detector::setHostname)
.def("getHostname", &Detector::getHostname, py::arg() = Positions{})
.def("getShmId", &Detector::getShmId)
.def("getFirmwareVersion", &Detector::getFirmwareVersion,
py::arg() = Positions{})
.def("getDetectorServerVersion", &Detector::getDetectorServerVersion,
py::arg() = Positions{})
.def("getSerialNumber", &Detector::getSerialNumber,
py::arg() = Positions{})
.def("getClientVersion", &Detector::getClientVersion)
.def("getReceiverVersion", &Detector::getReceiverVersion,
py::arg() = Positions{})
.def("getDetectorType", &Detector::getDetectorType,
py::arg() = Positions{})
.def("size", &Detector::size)
.def("getModuleGeometry", &Detector::getModuleGeometry)
.def("getModuleSize", &Detector::getModuleSize, py::arg() = Positions{})
.def("getDetectorSize", &Detector::getDetectorSize)
.def("setDetectorSize", &Detector::setDetectorSize)
.def("getSettings", &Detector::getSettings, py::arg() = Positions{})
.def("setSettings", &Detector::setSettings, py::arg(),
py::arg() = Positions{})
// TODO! Python funcs for callbacks?
// Acquisition Parameters
.def("getNumberOfFrames", &Detector::getNumberOfFrames)
.def("setNumberOfFrames", &Detector::setNumberOfFrames)
.def("getNumberOfTriggers", &Detector::getNumberOfTriggers)
.def("setNumberOfTriggers", &Detector::setNumberOfTriggers)
.def("setExptime", &Detector::setExptime, py::arg(),
py::arg() = Positions{})
.def("getExptime", &Detector::getExptime, py::arg() = Positions{})
.def("setPeriod", &Detector::setPeriod, py::arg(),
py::arg() = Positions{})
.def("getPeriod", &Detector::getPeriod, py::arg() = Positions{})
.def("getDelayAfterTrigger", &Detector::getDelayAfterTrigger,
py::arg() = Positions{})
.def("setDelayAfterTrigger", &Detector::setDelayAfterTrigger, py::arg(),
py::arg() = Positions{})
.def("getNumberOfFramesLeft", &Detector::getNumberOfFramesLeft,
py::arg() = Positions{})
.def("getNumberOfTriggersLeft", &Detector::getNumberOfTriggersLeft,
py::arg() = Positions{})
.def("getDelayAfterTriggerLeft", &Detector::getDelayAfterTriggerLeft,
py::arg() = Positions{})
.def("getSpeed", &Detector::getSpeed, py::arg() = Positions{})
.def("setSpeed", &Detector::setSpeed, py::arg(),
py::arg() = Positions{})
.def("getADCPhase", &Detector::getADCPhase, py::arg() = Positions{})
.def("setADCPhase", &Detector::setADCPhase, py::arg(),
py::arg() = Positions{})
.def("getADCPhaseInDegrees", &Detector::getADCPhaseInDegrees,
py::arg() = Positions{})
.def("setADCPhaseInDegrees", &Detector::setADCPhaseInDegrees, py::arg(),
py::arg() = Positions{})
.def("getHighVoltage", &Detector::getHighVoltage,
py::arg() = Positions{})
.def("setHighVoltage", &Detector::setHighVoltage, py::arg(),
py::arg() = Positions{})
.def("getTemperature", &Detector::getTemperature, py::arg(),
py::arg() = Positions{})
.def("getDAC", &Detector::getDAC, py::arg(), py::arg() = false,
py::arg() = Positions{})
.def("setDAC", &Detector::setDAC, py::arg(), py::arg(), py::arg(),
py::arg() = Positions{})
.def("getTimingMode", &Detector::getTimingMode, py::arg() = Positions{})
.def("setTimingMode", &Detector::setTimingMode, py::arg(),
py::arg() = Positions{})
// ACQUISITION
.def("acquire", &Detector::acquire)
.def("startDetector", &Detector::startDetector)
.def("stopDetector", &Detector::stopDetector)
.def("startReceiver", &Detector::startReceiver)
.def("stopReceiver", &Detector::stopReceiver)
.def("clearAcquiringFlag", &Detector::clearAcquiringFlag)
.def("getDetectorStatus", &Detector::getDetectorStatus,
py::arg() = Positions{})
.def("getReceiverStatus", &Detector::getReceiverStatus,
py::arg() = Positions{})
.def("getFramesCaught", &Detector::getFramesCaught,
py::arg() = Positions{})
.def("getStartingFrameNumber", &Detector::getStartingFrameNumber,
py::arg() = Positions{})
.def("setStartingFrameNumber", &Detector::setStartingFrameNumber,
py::arg(), py::arg() = Positions{})
.def("sendSoftwareTrigger", &Detector::sendSoftwareTrigger,
py::arg() = Positions{})
// Network Configuration (Detector<->Receiver)
.def("getNumberofUDPInterfaces", &Detector::getNumberofUDPInterfaces,
py::arg() = Positions{})
.def("setNumberofUDPInterfaces", &Detector::setNumberofUDPInterfaces,
py::arg(), py::arg() = Positions{})
.def("getSelectedUDPInterface", &Detector::getSelectedUDPInterface,
py::arg() = Positions{})
.def("selectUDPInterface", &Detector::selectUDPInterface, py::arg(),
py::arg() = Positions{})
// Using lambda to allow for conversion from IpAddr
.def("getSourceUDPIP",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getSourceUDPIP(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setSourceUDPIP",
[](Detector &d, std::string ip, Positions pos) {
d.setSourceUDPIP(sls::IpAddr(ip), pos);
},
py::arg(), py::arg() = Positions{})
.def("getSourceUDPIP2",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getSourceUDPIP2(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setSourceUDPIP2",
[](Detector &d, std::string ip, Positions pos) {
d.setSourceUDPIP2(sls::IpAddr(ip), pos);
},
py::arg(), py::arg() = Positions{})
.def("getSourceUDPMAC",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getSourceUDPMAC(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setSourceUDPMAC",
[](Detector &d, std::string mac, Positions pos) {
d.setSourceUDPMAC(sls::MacAddr(mac), pos);
},
py::arg(), py::arg() = Positions{})
.def("getSourceUDPMAC2",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getSourceUDPMAC2(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setSourceUDPMAC2",
[](Detector &d, std::string mac, Positions pos) {
d.setSourceUDPMAC2(sls::MacAddr(mac), pos);
},
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPIP",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getDestinationUDPIP(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setDestinationUDPIP",
[](Detector &d, std::string ip, Positions pos) {
d.setDestinationUDPIP(sls::IpAddr(ip), pos);
},
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPIP2",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getDestinationUDPIP2(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setDestinationUDPIP2",
[](Detector &d, std::string ip, Positions pos) {
d.setDestinationUDPIP2(sls::IpAddr(ip), pos);
},
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPMAC",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getDestinationUDPMAC(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setDestinationUDPMAC",
[](Detector &d, std::string mac, Positions pos) {
d.setDestinationUDPMAC(sls::MacAddr(mac), pos);
},
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPMAC2",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getDestinationUDPMAC2(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setDestinationUDPMAC2",
[](Detector &d, std::string mac, Positions pos) {
d.setDestinationUDPMAC2(sls::MacAddr(mac), pos);
},
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPPort", &Detector::getDestinationUDPPort,
py::arg() = Positions{})
.def("setDestinationUDPPort", &Detector::setDestinationUDPPort,
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPPort2", &Detector::getDestinationUDPPort2,
py::arg() = Positions{})
.def("setDestinationUDPPort2", &Detector::setDestinationUDPPort2,
py::arg(), py::arg() = Positions{})
.def("printRxConfiguration", &Detector::printRxConfiguration,
py::arg() = Positions{})
.def("getTenGiga", &Detector::getTenGiga, py::arg() = Positions{})
.def("setTenGiga", &Detector::setTenGiga, py::arg(),
py::arg() = Positions{})
.def("getTenGigaFlowControl", &Detector::getTenGigaFlowControl,
py::arg() = Positions{})
.def("setTenGigaFlowControl", &Detector::setTenGigaFlowControl,
py::arg(), py::arg() = Positions{})
.def("getTransmissionDelayFrame", &Detector::getTransmissionDelayFrame,
py::arg() = Positions{})
.def("setTransmissionDelayFrame", &Detector::setTransmissionDelayFrame,
py::arg(), py::arg() = Positions{})
.def("getTransmissionDelayLeft", &Detector::getTransmissionDelayLeft,
py::arg() = Positions{})
.def("setTransmissionDelayLeft", &Detector::setTransmissionDelayLeft,
py::arg(), py::arg() = Positions{})
.def("getTransmissionDelayRight", &Detector::getTransmissionDelayRight,
py::arg() = Positions{})
.def("setTransmissionDelayRight", &Detector::setTransmissionDelayRight,
py::arg(), py::arg() = Positions{})
/**************************************************
* *
* RECEIVER CONFIG *
* *
* ************************************************/
.def("getUseReceiverFlag", &Detector::getUseReceiverFlag,
py::arg() = Positions{})
.def("getRxHostname", &Detector::getRxHostname, py::arg() = Positions{})
.def("setRxHostname", &Detector::setRxHostname, py::arg(),
py::arg() = Positions{})
.def("getRxPort", &Detector::getRxPort, py::arg() = Positions{})
.def("setRxPort", &Detector::setRxPort, py::arg(),
py::arg() = Positions{})
.def("getRxFifoDepth", &Detector::getRxFifoDepth,
py::arg() = Positions{})
.def("setRxFifoDepth", &Detector::setRxFifoDepth, py::arg(),
py::arg() = Positions{})
.def("getRxSilentMode", &Detector::getRxSilentMode,
py::arg() = Positions{})
.def("setRxSilentMode", &Detector::setRxSilentMode, py::arg(),
py::arg() = Positions{})
.def("getRxFrameDiscardPolicy", &Detector::getRxFrameDiscardPolicy,
py::arg() = Positions{})
.def("setRxFrameDiscardPolicy", &Detector::setRxFrameDiscardPolicy,
py::arg(), py::arg() = Positions{})
.def("getPartialFramesPadding", &Detector::getPartialFramesPadding,
py::arg() = Positions{})
.def("setPartialFramesPadding", &Detector::setPartialFramesPadding,
py::arg(), py::arg() = Positions{})
.def("getRxUDPSocketBufferSize", &Detector::getRxUDPSocketBufferSize,
py::arg() = Positions{})
.def("setRxUDPSocketBufferSize", &Detector::setRxUDPSocketBufferSize,
py::arg(), py::arg() = Positions{})
.def("getRxRealUDPSocketBufferSize",
&Detector::getRxRealUDPSocketBufferSize, py::arg() = Positions{})
.def("getRxLock", &Detector::getRxLock, py::arg() = Positions{})
.def("setRxLock", &Detector::setRxLock, py::arg(),
py::arg() = Positions{})
.def("getRxLastClientIP", &Detector::getRxLastClientIP,
py::arg() = Positions{})
/**************************************************
* *
* FILE *
* *
* ************************************************/
.def("getFileFormat", &Detector::getFileFormat, py::arg() = Positions{})
.def("setFileFormat", &Detector::setFileFormat, py::arg(),
py::arg() = Positions{})
.def("getFilePath", &Detector::getFilePath, py::arg() = Positions{})
.def("setFilePath", &Detector::setFilePath, py::arg(),
py::arg() = Positions{})
.def("getFileNamePrefix", &Detector::getFileNamePrefix,
py::arg() = Positions{})
.def("setFileNamePrefix", &Detector::setFileNamePrefix, py::arg(),
py::arg() = Positions{})
.def("getFilePath", &Detector::getFilePath)
.def("setFilePath", &Detector::setFilePath, py::arg(),
py::arg() = Positions{})
.def("getAcquisitionIndex", &Detector::getAcquisitionIndex,
py::arg() = Positions{})
.def("setAcquisitionIndex", &Detector::setAcquisitionIndex, py::arg(),
py::arg() = Positions{})
.def("setFileWrite", &Detector::setFileWrite, py::arg(),
py::arg() = Positions{})
.def("getFileWrite", &Detector::getFileWrite, py::arg() = Positions{})
.def("setFileOverWrite", &Detector::setFileOverWrite, py::arg(),
py::arg() = Positions{})
.def("getFileOverWrite", &Detector::getFileOverWrite,
py::arg() = Positions{})
.def("setMasterFileWrite", &Detector::setMasterFileWrite, py::arg(),
py::arg() = Positions{})
.def("getMasterFileWrite", &Detector::getMasterFileWrite,
py::arg() = Positions{})
.def("setFramesPerFile", &Detector::setFramesPerFile, py::arg(),
py::arg() = Positions{})
.def("getFramesPerFile", &Detector::getFramesPerFile,
py::arg() = Positions{})
/**************************************************
* *
* ZMQ Streaming Parameters (Receiver<->Client)*
* *
* ************************************************/
.def("getRxZmqDataStream", &Detector::getRxZmqDataStream,
py::arg() = Positions{})
.def("setRxZmqDataStream", &Detector::setRxZmqDataStream, py::arg(),
py::arg() = Positions{})
.def("getRxZmqFrequency", &Detector::getRxZmqFrequency,
py::arg() = Positions{})
.def("setRxZmqFrequency", &Detector::setRxZmqFrequency, py::arg(),
py::arg() = Positions{})
.def("getRxZmqTimer", &Detector::getRxZmqTimer, py::arg() = Positions{})
.def("setRxZmqTimer", &Detector::setRxZmqTimer, py::arg(),
py::arg() = Positions{})
.def("getRxZmqPort", &Detector::getRxZmqPort, py::arg() = Positions{})
.def("setRxZmqPort", &Detector::setRxZmqPort, py::arg(),
py::arg() = Positions{})
.def("getRxZmqIP", &Detector::getRxZmqIP, py::arg() = Positions{})
.def("setRxZmqIP", &Detector::setRxZmqIP, py::arg(),
py::arg() = Positions{})
.def("getClientZmqPort", &Detector::getClientZmqPort,
py::arg() = Positions{})
.def("setClientZmqPort", &Detector::setClientZmqPort, py::arg(),
py::arg() = -1)
.def("getClientZmqIp", &Detector::getClientZmqIp,
py::arg() = Positions{})
.def("setClientZmqIp", &Detector::setClientZmqIp, py::arg(),
py::arg() = Positions{})
/**************************************************
* *
* Eiger Specific *
* *
* ************************************************/
.def("getDynamicRange", &Detector::getDynamicRange,
py::arg() = Positions{})
.def("setDynamicRange", &Detector::setDynamicRange)
.def("getSubExptime", &Detector::getSubExptime, py::arg() = Positions{})
.def("setSubExptime", &Detector::setSubExptime, py::arg(),
py::arg() = Positions{})
.def("getSubDeadTime", &Detector::getSubDeadTime,
py::arg() = Positions{})
.def("setSubDeadTime", &Detector::setSubDeadTime, py::arg(),
py::arg() = Positions{})
.def("getThresholdEnergy", &Detector::getThresholdEnergy,
py::arg() = Positions{})
.def("setThresholdEnergy", &Detector::setThresholdEnergy, py::arg(),
py::arg() = defs::STANDARD, py::arg() = true,
py::arg() = Positions{})
.def("getSettingsPath", &Detector::getSettingsPath,
py::arg() = Positions{})
.def("setSettingsPath", &Detector::setSettingsPath, py::arg(),
py::arg() = Positions{})
.def("loadTrimbits", &Detector::loadTrimbits, py::arg(),
py::arg() = Positions{})
.def("getRxAddGapPixels", &Detector::getRxAddGapPixels,
py::arg() = Positions{})
.def("setRxAddGapPixels", &Detector::setRxAddGapPixels)
.def("getParallelMode", &Detector::getParallelMode,
py::arg() = Positions{})
.def("setParallelMode", &Detector::setParallelMode, py::arg(),
py::arg() = Positions{})
.def("getOverFlowMode", &Detector::getOverFlowMode,
py::arg() = Positions{})
.def("setOverFlowMode", &Detector::setOverFlowMode, py::arg(),
py::arg() = Positions{})
.def("getStoreInRamMode", &Detector::getStoreInRamMode,
py::arg() = Positions{})
.def("setStoreInRamMode", &Detector::setStoreInRamMode, py::arg(),
py::arg() = Positions{})
.def("getBottom", &Detector::getBottom, py::arg() = Positions{})
.def("setBottom", &Detector::setBottom, py::arg(),
py::arg() = Positions{})
.def("getAllTrimbits", &Detector::getAllTrimbits,
py::arg() = Positions{})
.def("setAllTrimbits", &Detector::setAllTrimbits, py::arg(),
py::arg() = Positions{})
.def("getTrimEnergies", &Detector::getTrimEnergies,
py::arg() = Positions{})
.def("setTrimEnergies", &Detector::setTrimEnergies, py::arg(),
py::arg() = Positions{})
.def("getRateCorrection", &Detector::getRateCorrection,
py::arg() = Positions{})
.def("setRateCorrection", &Detector::setRateCorrection, py::arg(),
py::arg() = Positions{})
.def("setDefaultRateCorrection", &Detector::setDefaultRateCorrection,
py::arg() = Positions{})
.def("getPartialReadout", &Detector::getPartialReadout,
py::arg() = Positions{})
.def("setPartialReadout", &Detector::setPartialReadout, py::arg(),
py::arg() = Positions{})
.def("getInterruptSubframe", &Detector::getInterruptSubframe,
py::arg() = Positions{})
.def("setInterruptSubframe", &Detector::setInterruptSubframe, py::arg(),
py::arg() = Positions{})
.def("getMeasuredPeriod", &Detector::getMeasuredPeriod,
py::arg() = Positions{})
.def("getMeasuredSubFramePeriod", &Detector::getMeasuredSubFramePeriod,
py::arg() = Positions{})
.def("getActive", &Detector::getActive, py::arg() = Positions{})
.def("setActive", &Detector::setActive, py::arg(),
py::arg() = Positions{})
.def("getRxPadDeactivatedMode", &Detector::getRxPadDeactivatedMode,
py::arg() = Positions{})
.def("setRxPadDeactivatedMode", &Detector::setRxPadDeactivatedMode,
py::arg(), py::arg() = Positions{})
.def("getPartialReset", &Detector::getPartialReset,
py::arg() = Positions{})
.def("setPartialReset", &Detector::setPartialReset, py::arg(),
py::arg() = Positions{})
.def("pulsePixel", &Detector::pulsePixel, py::arg(), py::arg(),
py::arg() = Positions{})
.def("pulsePixelNMove", &Detector::pulsePixelNMove, py::arg(),
py::arg(), py::arg() = Positions{})
.def("pulseChip", &Detector::pulseChip, py::arg(),
py::arg() = Positions{})
.def("getQuad", &Detector::getQuad, py::arg() = Positions{})
.def("setQuad", &Detector::setQuad)
/**************************************************
* *
* Jungfrau Specific *
* *
* ************************************************/
.def("getThresholdTemperature", &Detector::getThresholdTemperature,
py::arg() = Positions{})
.def("setThresholdTemperature", &Detector::setThresholdTemperature,
py::arg(), py::arg() = Positions{})
.def("getTemperatureControl", &Detector::getTemperatureControl,
py::arg() = Positions{})
.def("setTemperatureControl", &Detector::setTemperatureControl,
py::arg(), py::arg() = Positions{})
.def("getTemperatureEvent", &Detector::getTemperatureEvent,
py::arg() = Positions{})
.def("resetTemperatureEvent", &Detector::resetTemperatureEvent,
py::arg() = Positions{})
.def("getPowerChip", &Detector::getPowerChip, py::arg() = Positions{})
.def("setPowerChip", &Detector::setPowerChip, py::arg(),
py::arg() = Positions{})
.def("getAutoCompDisable", &Detector::getAutoCompDisable,
py::arg() = Positions{})
.def("setAutoCompDisable", &Detector::setAutoCompDisable, py::arg(),
py::arg() = Positions{})
.def("getNumberOfAdditionalStorageCells",
&Detector::getNumberOfAdditionalStorageCells)
.def("setNumberOfAdditionalStorageCells",
&Detector::setNumberOfAdditionalStorageCells)
.def("getStorageCellStart", &Detector::getStorageCellStart,
py::arg() = Positions{})
.def("setStoragecellStart", &Detector::setStoragecellStart, py::arg(),
py::arg() = Positions{})
.def("setStorageCellDelay", &Detector::setStorageCellDelay, py::arg(),
py::arg() = Positions{})
// Bits and registers
.def("setBit", &Detector::setBit, py::arg(), py::arg(),
py::arg() = Positions{})
.def("clearBit", &Detector::clearBit, py::arg(), py::arg(),
py::arg() = Positions{})
.def("readRegister", &Detector::readRegister, py::arg(),
py::arg() = Positions{})
.def("writeRegister", &Detector::writeRegister, py::arg(), py::arg(),
py::arg() = Positions{})
.def("getStartingFrameNumber", &Detector::getStartingFrameNumber,
py::arg() = Positions{})
.def("setStartingFrameNumber", &Detector::setStartingFrameNumber,
py::arg(), py::arg() = Positions{})
/**************************************************
* *
* Insignificant *
* *
* ************************************************/
.def("getControlPort", &Detector::getControlPort,
py::arg() = Positions{})
.def("setControlPort", &Detector::setControlPort, py::arg(),
py::arg() = Positions{})
.def("getStopPort", &Detector::getStopPort, py::arg() = Positions{})
.def("setStopPort", &Detector::setStopPort, py::arg(),
py::arg() = Positions{})
.def("getDetectorLock", &Detector::getDetectorLock,
py::arg() = Positions{})
.def("setDetectorLock", &Detector::setDetectorLock, py::arg(),
py::arg() = Positions{})
.def("getLastClientIP", &Detector::getLastClientIP,
py::arg() = Positions{})
.def("executeCommand", &Detector::executeCommand, py::arg(),
py::arg() = Positions{})
.def("getNumberOfFramesFromStart",
&Detector::getNumberOfFramesFromStart, py::arg() = Positions{})
.def("getActualTime", &Detector::getActualTime, py::arg() = Positions{})
.def("getMeasurementTime", &Detector::getMeasurementTime,
py::arg() = Positions{})
.def("getUserDetails", &Detector::getUserDetails)
.def("getRxCurrentFrameIndex", &Detector::getRxCurrentFrameIndex,
py::arg() = Positions{})
/**************************************************
* *
* CTB Specific *
* *
* ************************************************/
.def("getNumberOfAnalogSamples", &Detector::getNumberOfAnalogSamples,
py::arg() = Positions{})
.def("setNumberOfAnalogSamples", &Detector::setNumberOfAnalogSamples,
py::arg(), py::arg() = Positions{})
.def("getNumberOfDigitalSamples", &Detector::getNumberOfDigitalSamples,
py::arg() = Positions{})
.def("setNumberOfDigitalSamples", &Detector::setNumberOfDigitalSamples,
py::arg(), py::arg() = Positions{})
.def("getReadoutMode", &Detector::getReadoutMode,
py::arg() = Positions{})
.def("setReadoutMode", &Detector::setReadoutMode, py::arg(),
py::arg() = Positions{})
.def("getDBITPhase", &Detector::getDBITPhase, py::arg() = Positions{})
.def("setDBITPhase", &Detector::setDBITPhase, py::arg(),
py::arg() = Positions{})
.def("getMaxDBITPhaseShift", &Detector::getMaxDBITPhaseShift,
py::arg() = Positions{})
.def("getDBITPhaseInDegrees", &Detector::getDBITPhaseInDegrees,
py::arg() = Positions{})
.def("setDBITPhaseInDegrees", &Detector::setDBITPhaseInDegrees,
py::arg(), py::arg() = Positions{})
.def("getADCClock", &Detector::getADCClock, py::arg() = Positions{})
.def("setADCClock", &Detector::setADCClock, py::arg(),
py::arg() = Positions{})
.def("getDBITClock", &Detector::getDBITClock, py::arg() = Positions{})
.def("setDBITClock", &Detector::setDBITClock, py::arg(),
py::arg() = Positions{})
.def("getRUNClock", &Detector::getRUNClock, py::arg() = Positions{})
.def("setRUNClock", &Detector::setRUNClock, py::arg(),
py::arg() = Positions{})
.def("getSYNCClock", &Detector::getSYNCClock, py::arg() = Positions{})
// Time
.def("setSubExptime", &Detector::setSubExptime, py::arg(),
py::arg() = Positions{})
.def("getSubExptime", &Detector::getSubExptime,
py::arg() = Positions{});
}

View File

@ -17,7 +17,9 @@ using ds = std::chrono::duration<double>;
namespace py = pybind11;
void init_enums(py::module &);
void init_experimental(py::module &);
PYBIND11_MODULE(_sls_detector, m) {
void init_det(py::module &);
void init_network(py::module &);
PYBIND11_MODULE(_slsdet, m) {
m.doc() = R"pbdoc(
C/C++ API
-----------------------
@ -29,7 +31,9 @@ PYBIND11_MODULE(_sls_detector, m) {
)pbdoc";
init_enums(m);
init_experimental(m);
init_det(m);
init_network(m);
// init_experimental(m);
py::module io = m.def_submodule("io", "Submodule for io");

41
python/src/network.cpp Normal file
View File

@ -0,0 +1,41 @@
/*
This file contains Python bindings for the IpAddr and MacAddr
classes.
*/
#include <pybind11/chrono.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "network_utils.h"
namespace py = pybind11;
using sls::IpAddr;
using sls::MacAddr;
void init_network(py::module &m) {
py::class_ <IpAddr>(m, "IpAddr")
.def(py::init())
.def(py::init<const std::string&>())
.def(py::init<uint32_t>())
.def(py::init<const IpAddr&>())
.def("hex", &IpAddr::hex)
.def("uint32", &IpAddr::uint32)
.def(py::self == py::self)
.def("__repr__", &IpAddr::str)
.def("str", &IpAddr::str);
py::class_ <MacAddr>(m, "MacAddr")
.def(py::init())
.def(py::init<const std::string&>())
.def(py::init<uint64_t>())
.def(py::init<const MacAddr&>())
.def("hex", &MacAddr::hex)
.def(py::self == py::self)
.def("uint64", &MacAddr::uint64)
.def("__repr__", &MacAddr::str)
.def("str", &MacAddr::str);
}

View File

@ -16,12 +16,12 @@ def d():
def test_acq_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.acq')
m = mocker.patch('_slsdet.DetectorApi.acq')
d.acq()
m.assert_called_once_with()
def test_busy_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getAcquiringFlag')
m = mocker.patch('_slsdet.DetectorApi.getAcquiringFlag')
m.return_value = False
assert d.busy == False
@ -31,103 +31,103 @@ def test_assign_to_detector_type(d):
d.detector_type = 'Eiger'
def test_det_type(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDetectorType')
m = mocker.patch('_slsdet.DetectorApi.getDetectorType')
m.return_value = 'Eiger'
assert d.detector_type == 'Eiger'
def test_set_dynamic_range_4(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDynamicRange')
m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
d.dynamic_range = 4
m.assert_called_with(4)
def test_set_dynamic_range_8(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDynamicRange')
m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
d.dynamic_range = 8
m.assert_called_with(8)
def test_set_dynamic_range_16(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDynamicRange')
m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
d.dynamic_range = 16
m.assert_called_with(16)
def test_set_dynamic_range_32(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDynamicRange')
m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
d.dynamic_range = 32
m.assert_called_with(32)
def test_set_dynamic_range_raises_exception(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setDynamicRange')
mocker.patch('_slsdet.DetectorApi.setDynamicRange')
with pytest.raises(ValueError):
d.dynamic_range = 17
def test_get_dynamic_range_32(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDynamicRange')
m = mocker.patch('_slsdet.DetectorApi.getDynamicRange')
m.return_value = 32
dr = d.dynamic_range
assert dr == 32
def test_eiger_matrix_reset(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getCounterBit')
m = mocker.patch('_slsdet.DetectorApi.getCounterBit')
m.return_value = True
assert d.eiger_matrix_reset == True
def test_set_eiger_matrix_reset(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setCounterBit')
m = mocker.patch('_slsdet.DetectorApi.setCounterBit')
d.eiger_matrix_reset = True
m.assert_called_once_with(True)
def test_get_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getExposureTime')
m = mocker.patch('_slsdet.DetectorApi.getExposureTime')
m.return_value = 100000000
assert d.exposure_time == 0.1
def test_set_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setExposureTime')
m = mocker.patch('_slsdet.DetectorApi.setExposureTime')
d.exposure_time = 1.5
m.assert_called_once_with(1500000000)
def test_set_exposure_time_less_than_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setExposureTime')
mocker.patch('_slsdet.DetectorApi.setExposureTime')
with pytest.raises(ValueError):
d.exposure_time = -7
def test_get_file_index(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFileIndex')
m = mocker.patch('_slsdet.DetectorApi.getFileIndex')
m.return_value = 8
assert d.file_index == 8
def test_set_file_index(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFileIndex')
m = mocker.patch('_slsdet.DetectorApi.setFileIndex')
d.file_index = 9
m.assert_called_with(9)
def test_set_file_index_raises_on_neg(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setFileIndex')
mocker.patch('_slsdet.DetectorApi.setFileIndex')
with pytest.raises(ValueError):
d.file_index = -9
def test_get_file_name(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFileName')
m = mocker.patch('_slsdet.DetectorApi.getFileName')
d.file_name
m.assert_called_once_with()
def test_set_file_name(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFileName')
m = mocker.patch('_slsdet.DetectorApi.setFileName')
d.file_name = 'hej'
m.assert_called_once_with('hej')
def test_get_file_path(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFilePath')
m = mocker.patch('_slsdet.DetectorApi.getFilePath')
d.file_path
m.assert_called_once_with()
def test_set_file_path_when_path_exists(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFilePath')
m = mocker.patch('_slsdet.DetectorApi.setFilePath')
#To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.exists')
mock_os.return_value = True
@ -135,25 +135,25 @@ def test_set_file_path_when_path_exists(d, mocker):
m.assert_called_once_with('/path/to/something/')
def test_set_file_path_raises_when_not_exists(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setFilePath')
mocker.patch('_slsdet.DetectorApi.setFilePath')
mock_os = mocker.patch('os.path.exists')
mock_os.return_value = False
with pytest.raises(FileNotFoundError):
d.file_path = '/path/to/something/'
def test_get_file_write(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFileWrite')
m = mocker.patch('_slsdet.DetectorApi.getFileWrite')
m.return_value = False
assert d.file_write == False
def test_set_file_write(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFileWrite')
m = mocker.patch('_slsdet.DetectorApi.setFileWrite')
d.file_write = True
m.assert_called_once_with(True)
def test_get_firmware_version(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFirmwareVersion')
m = mocker.patch('_slsdet.DetectorApi.getFirmwareVersion')
m.return_value = 20
assert d.firmware_version == 20
@ -162,38 +162,38 @@ def test_cannot_set_fw_version(d):
d.firmware_version = 20
def test_get_high_voltage_call_signature(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDac')
m = mocker.patch('_slsdet.DetectorApi.getDac')
d.high_voltage
m.assert_called_once_with('vhighvoltage', -1)
def test_get_high_voltage(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDac')
m = mocker.patch('_slsdet.DetectorApi.getDac')
m.return_value = 80
assert d.high_voltage == 80
#self._api.setDac('vhighvoltage', -1, voltage)
def test_set_high_voltage(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDac')
m = mocker.patch('_slsdet.DetectorApi.setDac')
d.high_voltage = 80
m.assert_called_once_with('vhighvoltage', -1, 80)
def test_decode_hostname_two_names(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getHostname')
m = mocker.patch('_slsdet.DetectorApi.getHostname')
m.return_value = 'beb059+beb048+'
assert d.hostname == ['beb059', 'beb048']
def test_decode_hostname_four_names(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getHostname')
m = mocker.patch('_slsdet.DetectorApi.getHostname')
m.return_value = 'beb059+beb048+beb120+beb153+'
assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153']
def test_decode_hostname_blank(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getHostname')
m = mocker.patch('_slsdet.DetectorApi.getHostname')
m.return_value = ''
assert d.hostname == []
def test_get_image_size_gives_correct_size(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getImageSize')
m = mocker.patch('_slsdet.DetectorApi.getImageSize')
m.return_value = (512,1024)
im_size = d.image_size
assert im_size.rows == 512
@ -202,7 +202,7 @@ def test_get_image_size_gives_correct_size(d, mocker):
def test_load_config(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.readConfigurationFile')
m = mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
#To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = True
@ -210,14 +210,14 @@ def test_load_config(d, mocker):
m.assert_called_once_with('/path/to/my/file.config')
def test_load_config_raises_when_file_is_not_found(d, mocker):
mocker.patch('_sls_detector.DetectorApi.readConfigurationFile')
mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = False
with pytest.raises(FileNotFoundError):
d.load_config('/path/to/my/file.config')
def test_load_parameters(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.readParametersFile')
m = mocker.patch('_slsdet.DetectorApi.readParametersFile')
#To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = True
@ -225,7 +225,7 @@ def test_load_parameters(d, mocker):
m.assert_called_once_with('/path/to/my/file.par')
def test_load_parameters_raises_when_file_is_not_found(d, mocker):
mocker.patch('_sls_detector.DetectorApi.readParametersFile')
mocker.patch('_slsdet.DetectorApi.readParametersFile')
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = False
with pytest.raises(FileNotFoundError):
@ -233,14 +233,14 @@ def test_load_parameters_raises_when_file_is_not_found(d, mocker):
#getDetectorGeometry
def test_get_module_geometry_gives_correct_size(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDetectorGeometry')
m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
m.return_value = (13,7)
g = d.module_geometry
assert g.vertical == 7
assert g.horizontal == 13
def test_get_module_geometry_access(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDetectorGeometry')
m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
m.return_value = (12,3)
assert d.module_geometry[0] == 12
assert d.module_geometry[1] == 3
@ -248,237 +248,237 @@ def test_get_module_geometry_access(d, mocker):
assert d.module_geometry.horizontal == 12
def test_get_n_frames(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNumberOfFrames')
m = mocker.patch('_slsdet.DetectorApi.getNumberOfFrames')
m.return_value = 3
assert d.n_frames == 3
def test_set_n_frames(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames')
m = mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
d.n_frames = 9
m.assert_called_once_with(9)
def test_set_n_frames_raises_on_neg(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames')
mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
with pytest.raises(ValueError):
d.n_frames = -1
def test_set_n_frames_raises_on_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames')
mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
with pytest.raises(ValueError):
d.n_frames = 0
def test_get_n_modules(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
m = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
m.return_value = 12
assert d.n_modules == 12
def test_get_period_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getPeriod')
m = mocker.patch('_slsdet.DetectorApi.getPeriod')
m.return_value = 130000000
assert d.period == 0.13
def test_set_period_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setPeriod')
m = mocker.patch('_slsdet.DetectorApi.setPeriod')
d.period = 1.953
m.assert_called_once_with(1953000000)
def test_set_period_time_less_than_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setPeriod')
mocker.patch('_slsdet.DetectorApi.setPeriod')
with pytest.raises(ValueError):
d.period = -7
def test_pulse_chip_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.pulseChip')
m = mocker.patch('_slsdet.DetectorApi.pulseChip')
d.pulse_chip(15)
m.assert_called_once_with(15)
def test_pulse_chip_call_minus_one(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.pulseChip')
m = mocker.patch('_slsdet.DetectorApi.pulseChip')
d.pulse_chip(-1)
m.assert_called_once_with(-1)
def test_pulse_chip_asserts_on_smaller_than_minus_one(d, mocker):
mocker.patch('_sls_detector.DetectorApi.pulseChip')
mocker.patch('_slsdet.DetectorApi.pulseChip')
with pytest.raises(ValueError):
d.pulse_chip(-3)
#--------------------------------------------------------------------subexptime
def test_get_sub_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getSubExposureTime')
m = mocker.patch('_slsdet.DetectorApi.getSubExposureTime')
m.return_value = 2370000
assert d.sub_exposure_time == 0.00237
def test_set_sub_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setSubExposureTime')
m = mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
d.sub_exposure_time = 0.002
m.assert_called_once_with(2000000)
def test_set_sub_exposure_time_raises_on_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setSubExposureTime')
mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
with pytest.raises(ValueError):
d.sub_exposure_time = 0
#-------------------------------------------------------------Rate correction
def test_get_rate_correction(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getRateCorrection')
m = mocker.patch('_slsdet.DetectorApi.getRateCorrection')
m.return_value = [132,129]
assert d.rate_correction == [132,129]
def test_set_rate_correction(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
m = mocker.patch('_slsdet.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
mock_n.return_value = 3
d.rate_correction = [123,90,50]
m.assert_called_once_with([123,90,50])
def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
mocker.patch('_slsdet.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
mock_n.return_value = 4
with pytest.raises(ValueError):
d.rate_correction = [123,90,50]
#----------------------------------------------------------------Readout clock
def test_get_readout_clock_0(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed')
m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
m.return_value = 0
assert d.readout_clock == 'Full Speed'
def test_get_readout_clock_1(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed')
m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
m.return_value = 1
assert d.readout_clock == 'Half Speed'
def test_get_readout_clock_2(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed')
m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
m.return_value = 2
assert d.readout_clock == 'Quarter Speed'
def test_get_readout_clock_3(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed')
m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
m.return_value = 3
assert d.readout_clock == 'Super Slow Speed'
def test_set_readout_clock_0(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed')
m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Full Speed'
m.assert_called_once_with(0)
def test_set_readout_clock_1(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed')
m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Half Speed'
m.assert_called_once_with(1)
def test_set_readout_clock_2(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed')
m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Quarter Speed'
m.assert_called_once_with(2)
def test_set_readout_clock_3(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed')
m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Super Slow Speed'
m.assert_called_once_with(3)
#----------------------------------------------------------------rx_datastream
def test_get_rx_datastream(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getRxDataStreamStatus')
m = mocker.patch('_slsdet.DetectorApi.getRxDataStreamStatus')
m.return_value = False
assert d.rx_datastream == False
def test_set_rx_datastream(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setRxDataStreamStatus')
m = mocker.patch('_slsdet.DetectorApi.setRxDataStreamStatus')
d.rx_datastream = True
m.assert_called_once_with(True)
def test_get_rx_zmqip(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
d.rx_zmqip
m.assert_called_once_with('rx_zmqip')
def test_get_rx_zmqport_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
d.rx_zmqport
m.assert_called_once_with('rx_zmqport')
def test_get_rx_zmqport_decode(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
m.return_value = '30001+30003+'
assert d.rx_zmqport == [30001, 30002, 30003, 30004]
def test_get_rx_zmqport_empty(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
m.return_value = ''
assert d.rx_zmqport == []
#--------------------------------------------------------------------status
def test_status_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getRunStatus')
m = mocker.patch('_slsdet.DetectorApi.getRunStatus')
d.status
m.assert_called_once_with()
def test_start_acq_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.startAcquisition')
m = mocker.patch('_slsdet.DetectorApi.startAcquisition')
d.start_acq()
m.assert_called_once_with()
def test_stop_acq_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.stopAcquisition')
m = mocker.patch('_slsdet.DetectorApi.stopAcquisition')
d.stop_acq()
m.assert_called_once_with()
#--------------------------------------------------------------------subexptime
def test_get_sub_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getSubExposureTime')
m = mocker.patch('_slsdet.DetectorApi.getSubExposureTime')
m.return_value = 2370000
assert d.sub_exposure_time == 0.00237
def test_set_sub_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setSubExposureTime')
m = mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
d.sub_exposure_time = 0.002
m.assert_called_once_with(2000000)
def test_set_sub_exposure_time_raises_on_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setSubExposureTime')
mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
with pytest.raises(ValueError):
d.sub_exposure_time = 0
#------------------------------------------------------------------timing mode
def test_get_timing_mode(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getTimingMode')
m = mocker.patch('_slsdet.DetectorApi.getTimingMode')
d.timing_mode
m.assert_called_once_with()
def test_set_timing_mode(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setTimingMode')
m = mocker.patch('_slsdet.DetectorApi.setTimingMode')
d.timing_mode = 'auto'
m.assert_called_once_with('auto')
#----------------------------------------------------------------vthreshold
def test_get_vthreshold(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDac')
m = mocker.patch('_slsdet.DetectorApi.getDac')
d.vthreshold
m.assert_called_once_with('vthreshold', -1)
def test_set_vthreshold(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDac')
m = mocker.patch('_slsdet.DetectorApi.setDac')
d.vthreshold = 1675
m.assert_called_once_with('vthreshold', -1, 1675)
#----------------------------------------------------------------trimbits
def test_get_trimbits(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getAllTrimbits')
m = mocker.patch('_slsdet.DetectorApi.getAllTrimbits')
d.trimbits
m.assert_called_once_with()
def test_set_trimbits(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setAllTrimbits')
m = mocker.patch('_slsdet.DetectorApi.setAllTrimbits')
d.trimbits = 15
m.assert_called_once_with(15)
def test_set_trimbits_raises_outside_range(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setAllTrimbits')
mocker.patch('_slsdet.DetectorApi.setAllTrimbits')
with pytest.raises(ValueError):
d.trimbits = 69

View File

@ -1,8 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Testing parameters and methods of the Detector class using mocks
Testing the Detector python class by mocking calls.
Should only be used when there is functionality in
the detector.py file.
An example is converting a mask to a list of set bits.
"""
from unittest.mock import Mock
import pytest
from pytest_mock import mocker
@ -10,462 +15,474 @@ from pytest_mock import mocker
import sys
sys.path.append('/home/l_frojdh/slsdetectorgrup/sls_detector')
import _sls_detector
import _slsdet
from sls_detector.errors import DetectorValueError, DetectorError
from sls_detector.utils import all_equal, element_if_equal
@pytest.fixture
def d():
from sls_detector import Detector
return Detector()
def test_length(d, mocker):
m = mocker.patch('sls_detector.Detector.size')
m.return_value = 5
assert(len(d) == 5)
def test_length_zero(d):
assert len(d) == 0
def test_counters_single(d, mocker):
m = mocker.patch('sls_detector.Detector.getCounterMask')
m.return_value = [7]
assert(d.counters == [0,1,2])
def test_acq_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.acq')
d.acq()
m.assert_called_once_with()
def test_busy_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getAcquiringFlag')
m.return_value = False
assert d.busy == False
def test_set_busy(d):
d.busy = True
assert d.busy == True
assert d._api.getAcquiringFlag() == True
d.busy = False
assert d.busy == False
assert d._api.getAcquiringFlag() == False
def test_error_mask(d):
d._api.setErrorMask(1)
assert d.error_mask == 1
d.clear_errors()
def test_error_handling(d):
with pytest.raises(DetectorError):
d._provoke_error()
def test_assign_to_detector_type(d):
with pytest.raises(AttributeError):
d.detector_type = 'Eiger'
def test_det_type(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDetectorType')
m.return_value = 'Eiger'
assert d.detector_type == 'Eiger'
def test_get_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getExposureTime')
m.return_value = 100000000
assert d.exposure_time == 0.1
def test_set_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setExposureTime')
d.exposure_time = 1.5
m.assert_called_once_with(1500000000)
def test_set_exposure_time_less_than_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setExposureTime')
with pytest.raises(DetectorValueError):
d.exposure_time = -7
def test_get_file_index(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFileIndex')
m.return_value = 8
assert d.file_index == 8
def test_set_file_index(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFileIndex')
d.file_index = 9
m.assert_called_with(9)
def file_index_with_no_detector(d):
assert d.file_index == -100
def dr_with_no_detector(d):
assert d.dynamic_range == -100
def test_set_file_index_raises_on_neg(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setFileIndex')
with pytest.raises(ValueError):
d.file_index = -9
def test_get_file_name(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFileName')
d.file_name
m.assert_called_once_with()
def test_set_file_name(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFileName')
d.file_name = 'hej'
m.assert_called_once_with('hej')
def test_get_file_path(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFilePath')
d.file_path
m.assert_called_once_with()
def test_set_file_path_when_path_exists(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFilePath')
#To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.exists')
mock_os.return_value = True
d.file_path = '/path/to/something/'
m.assert_called_once_with('/path/to/something/')
def test_set_file_path_raises_when_not_exists(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setFilePath')
mock_os = mocker.patch('os.path.exists')
mock_os.return_value = False
with pytest.raises(FileNotFoundError):
d.file_path = '/path/to/something/'
def test_get_file_write(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFileWrite')
m.return_value = False
assert d.file_write == False
def test_set_file_write(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFileWrite')
d.file_write = True
m.assert_called_once_with(True)
def test_get_firmware_version(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFirmwareVersion')
m.return_value = 20
assert d.firmware_version == 20
def test_cannot_set_fw_version(d):
with pytest.raises(AttributeError):
d.firmware_version = 20
def test_get_high_voltage_call_signature(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDac')
d.high_voltage
m.assert_called_once_with('vhighvoltage', -1)
def test_get_high_voltage(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDac')
m.return_value = 80
assert d.high_voltage == 80
#self._api.setDac('vhighvoltage', -1, voltage)
def test_set_high_voltage(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDac')
d.high_voltage = 80
m.assert_called_once_with('vhighvoltage', -1, 80)
def test_decode_hostname_two_names(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getHostname')
m.return_value = 'beb059+beb048+'
assert d.hostname == ['beb059', 'beb048']
def test_decode_hostname_four_names(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getHostname')
m.return_value = 'beb059+beb048+beb120+beb153+'
assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153']
def test_decode_hostname_blank(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getHostname')
m.return_value = ''
assert d.hostname == []
def test_get_image_size_gives_correct_size(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getImageSize')
m.return_value = (512,1024)
im_size = d.image_size
assert im_size.rows == 512
assert im_size.cols == 1024
def test_load_config(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.readConfigurationFile')
#To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = True
d.load_config('/path/to/my/file.config')
m.assert_called_once_with('/path/to/my/file.config')
def test_load_config_raises_when_file_is_not_found(d, mocker):
mocker.patch('_sls_detector.DetectorApi.readConfigurationFile')
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = False
with pytest.raises(FileNotFoundError):
d.load_config('/path/to/my/file.config')
def test_load_parameters(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.readParametersFile')
#To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = True
d.load_parameters('/path/to/my/file.par')
m.assert_called_once_with('/path/to/my/file.par')
def test_load_parameters_raises_when_file_is_not_found(d, mocker):
mocker.patch('_sls_detector.DetectorApi.readParametersFile')
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = False
with pytest.raises(FileNotFoundError):
d.load_parameters('/path/to/my/file.par')
#getDetectorGeometry
def test_get_module_geometry_gives_correct_size(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDetectorGeometry')
m.return_value = (13,7)
g = d.module_geometry
assert g.vertical == 7
assert g.horizontal == 13
def test_get_module_geometry_access(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDetectorGeometry')
m.return_value = (12,3)
assert d.module_geometry[0] == 12
assert d.module_geometry[1] == 3
assert d.module_geometry.vertical == 3
assert d.module_geometry.horizontal == 12
def test_module_geometry_without_detectors(d):
t = d.module_geometry
assert t.horizontal == 0
assert t.vertical == 0
def test_get_n_frames(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNumberOfFrames')
m.return_value = 3
assert d.n_frames == 3
def test_set_n_frames(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames')
d.n_frames = 9
m.assert_called_once_with(9)
def test_nframes_without_detector(d):
assert d.n_frames == -100
def test_set_n_frames_raises_on_neg(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames')
with pytest.raises(DetectorValueError):
d.n_frames = -1
def test_set_n_frames_raises_on_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames')
with pytest.raises(DetectorValueError):
d.n_frames = 0
def test_n_cycles_without_detector(d):
assert d.n_cycles == -100
def test_set_n_cycles_raises_on_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setCycles')
with pytest.raises(DetectorValueError):
d.n_cycles = 0
def test_set_n_cycles(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setCycles')
d.n_cycles = 56
m.assert_called_once_with(56)
def test_n_measurements_without_detector(d):
assert d.n_measurements == -100
def test_set_n_measurements_raises_on_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setNumberOfMeasurements')
with pytest.raises(DetectorValueError):
d.n_measurements = 0
def test_set_n_measurements(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setNumberOfMeasurements')
d.n_measurements = 560
m.assert_called_once_with(560)
def test_get_n_modules_no_detector(d):
assert d.n_modules == 0
def test_get_n_modules(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
m.return_value = 12
assert d.n_modules == 12
def test_get_period_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getPeriod')
m.return_value = 130000000
assert d.period == 0.13
def test_set_period_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setPeriod')
d.period = 1.953
m.assert_called_once_with(1953000000)
def test_set_period_time_less_than_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setPeriod')
with pytest.raises(ValueError):
d.period = -7
def test_get_online(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getOnline')
d.online
m.assert_called_once_with()
def test_set_online(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setOnline')
d.online = True
m.assert_called_once_with(True)
def test_last_client_ip_no_detector(d):
assert d.last_client_ip == ''
def test_last_cliten_ip_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getLastClientIP')
d.last_client_ip
m.assert_called_once_with()
#-------------------------------------------------------------Rate correction
def test_get_rate_correction(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getRateCorrection')
m.return_value = [132,129]
assert d.rate_correction == [132,129]
def test_set_rate_correction(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
mock_n.return_value = 3
d.rate_correction = [123,90,50]
m.assert_called_once_with([123,90,50])
def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
mock_n.return_value = 4
with pytest.raises(ValueError):
d.rate_correction = [123,90,50]
#----------------------------------------------------------------Readout clock
def test_get_readout_clock_0(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed')
m.return_value = 0
assert d.readout_clock == 'Full Speed'
def test_get_readout_clock_1(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed')
m.return_value = 1
assert d.readout_clock == 'Half Speed'
def test_get_readout_clock_2(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed')
m.return_value = 2
assert d.readout_clock == 'Quarter Speed'
def test_get_readout_clock_3(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed')
m.return_value = 3
assert d.readout_clock == 'Super Slow Speed'
def test_set_readout_clock_0(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Full Speed'
m.assert_called_once_with(0)
def test_set_readout_clock_1(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Half Speed'
m.assert_called_once_with(1)
def test_set_readout_clock_2(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Quarter Speed'
m.assert_called_once_with(2)
def test_set_readout_clock_3(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Super Slow Speed'
m.assert_called_once_with(3)
#----------------------------------------------------------------rx_datastream
def test_get_rx_datastream(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getRxDataStreamStatus')
m.return_value = False
assert d.rx_datastream == False
def test_set_rx_datastream(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setRxDataStreamStatus')
d.rx_datastream = True
m.assert_called_once_with(True)
def test_get_rx_zmqip(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
d.rx_zmqip
m.assert_called_once_with('rx_zmqip')
def test_get_rx_zmqport_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
d.rx_zmqport
m.assert_called_once_with('rx_zmqport')
def test_get_rx_zmqport_decode(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
m.return_value = ['30001', '30003']
assert d.rx_zmqport == [30001, 30003]
def test_get_rx_zmqport_empty(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
m.return_value = ''
assert d.rx_zmqport == []
#--------------------------------------------------------------------status
def test_status_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getRunStatus')
d.status
m.assert_called_once_with()
def test_start_detecor(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.startAcquisition')
d.start_detector()
m.assert_called_once_with()
def test_stop_acq_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.stopAcquisition')
d.stop_detector()
m.assert_called_once_with()
#------------------------------------------------------------------timing mode
def test_get_timing_mode(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getTimingMode')
d.timing_mode
m.assert_called_once_with()
def test_set_timing_mode(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setTimingMode')
d.timing_mode = 'auto'
m.assert_called_once_with('auto')
#----------------------------------------------------------------vthreshold
def test_get_vthreshold(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDac')
d.vthreshold
m.assert_called_once_with('vthreshold', -1)
def test_set_vthreshold(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDac')
d.vthreshold = 1675
m.assert_called_once_with('vthreshold', -1, 1675)
def test_counters_multi(d, mocker):
m = mocker.patch('sls_detector.Detector.getCounterMask')
m.return_value = [7, 9]
assert(d.counters == [[0,1,2],[0,3]])
def test_set_counters_single(d, mocker):
m = mocker.patch('sls_detector.Detector.setCounterMask')
d.counters = [0,2]
m.assert_called_once_with(5)
# def test_busy_call(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getAcquiringFlag')
# m.return_value = False
# assert d.busy == False
# def test_set_busy(d):
# d.busy = True
# assert d.busy == True
# assert d._api.getAcquiringFlag() == True
# d.busy = False
# assert d.busy == False
# assert d._api.getAcquiringFlag() == False
# def test_error_mask(d):
# d._api.setErrorMask(1)
# assert d.error_mask == 1
# d.clear_errors()
# def test_error_handling(d):
# with pytest.raises(DetectorError):
# d._provoke_error()
# def test_assign_to_detector_type(d):
# with pytest.raises(AttributeError):
# d.detector_type = 'Eiger'
# def test_det_type(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getDetectorType')
# m.return_value = 'Eiger'
# assert d.detector_type == 'Eiger'
# def test_get_exposure_time(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getExposureTime')
# m.return_value = 100000000
# assert d.exposure_time == 0.1
# def test_set_exposure_time(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setExposureTime')
# d.exposure_time = 1.5
# m.assert_called_once_with(1500000000)
# def test_set_exposure_time_less_than_zero(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setExposureTime')
# with pytest.raises(DetectorValueError):
# d.exposure_time = -7
# def test_get_file_index(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getFileIndex')
# m.return_value = 8
# assert d.file_index == 8
# def test_set_file_index(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setFileIndex')
# d.file_index = 9
# m.assert_called_with(9)
# def file_index_with_no_detector(d):
# assert d.file_index == -100
# def dr_with_no_detector(d):
# assert d.dynamic_range == -100
# def test_set_file_index_raises_on_neg(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setFileIndex')
# with pytest.raises(ValueError):
# d.file_index = -9
# def test_get_file_name(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getFileName')
# d.file_name
# m.assert_called_once_with()
# def test_set_file_name(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setFileName')
# d.file_name = 'hej'
# m.assert_called_once_with('hej')
# def test_get_file_path(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getFilePath')
# d.file_path
# m.assert_called_once_with()
# def test_set_file_path_when_path_exists(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setFilePath')
# #To avoid raising an exception because path is not there
# mock_os = mocker.patch('os.path.exists')
# mock_os.return_value = True
# d.file_path = '/path/to/something/'
# m.assert_called_once_with('/path/to/something/')
# def test_set_file_path_raises_when_not_exists(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setFilePath')
# mock_os = mocker.patch('os.path.exists')
# mock_os.return_value = False
# with pytest.raises(FileNotFoundError):
# d.file_path = '/path/to/something/'
# def test_get_file_write(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getFileWrite')
# m.return_value = False
# assert d.file_write == False
# def test_set_file_write(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setFileWrite')
# d.file_write = True
# m.assert_called_once_with(True)
# def test_get_firmware_version(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getFirmwareVersion')
# m.return_value = 20
# assert d.firmware_version == 20
# def test_cannot_set_fw_version(d):
# with pytest.raises(AttributeError):
# d.firmware_version = 20
# def test_get_high_voltage_call_signature(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getDac')
# d.high_voltage
# m.assert_called_once_with('vhighvoltage', -1)
# def test_get_high_voltage(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getDac')
# m.return_value = 80
# assert d.high_voltage == 80
# #self._api.setDac('vhighvoltage', -1, voltage)
# def test_set_high_voltage(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setDac')
# d.high_voltage = 80
# m.assert_called_once_with('vhighvoltage', -1, 80)
# def test_decode_hostname_two_names(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getHostname')
# m.return_value = 'beb059+beb048+'
# assert d.hostname == ['beb059', 'beb048']
# def test_decode_hostname_four_names(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getHostname')
# m.return_value = 'beb059+beb048+beb120+beb153+'
# assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153']
# def test_decode_hostname_blank(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getHostname')
# m.return_value = ''
# assert d.hostname == []
# def test_get_image_size_gives_correct_size(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getImageSize')
# m.return_value = (512,1024)
# im_size = d.image_size
# assert im_size.rows == 512
# assert im_size.cols == 1024
# def test_load_config(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
# #To avoid raising an exception because path is not there
# mock_os = mocker.patch('os.path.isfile')
# mock_os.return_value = True
# d.load_config('/path/to/my/file.config')
# m.assert_called_once_with('/path/to/my/file.config')
# def test_load_config_raises_when_file_is_not_found(d, mocker):
# mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
# mock_os = mocker.patch('os.path.isfile')
# mock_os.return_value = False
# with pytest.raises(FileNotFoundError):
# d.load_config('/path/to/my/file.config')
# def test_load_parameters(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.readParametersFile')
# #To avoid raising an exception because path is not there
# mock_os = mocker.patch('os.path.isfile')
# mock_os.return_value = True
# d.load_parameters('/path/to/my/file.par')
# m.assert_called_once_with('/path/to/my/file.par')
# def test_load_parameters_raises_when_file_is_not_found(d, mocker):
# mocker.patch('_slsdet.DetectorApi.readParametersFile')
# mock_os = mocker.patch('os.path.isfile')
# mock_os.return_value = False
# with pytest.raises(FileNotFoundError):
# d.load_parameters('/path/to/my/file.par')
# #getDetectorGeometry
# def test_get_module_geometry_gives_correct_size(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
# m.return_value = (13,7)
# g = d.module_geometry
# assert g.vertical == 7
# assert g.horizontal == 13
# def test_get_module_geometry_access(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
# m.return_value = (12,3)
# assert d.module_geometry[0] == 12
# assert d.module_geometry[1] == 3
# assert d.module_geometry.vertical == 3
# assert d.module_geometry.horizontal == 12
# def test_module_geometry_without_detectors(d):
# t = d.module_geometry
# assert t.horizontal == 0
# assert t.vertical == 0
# def test_get_n_frames(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getNumberOfFrames')
# m.return_value = 3
# assert d.n_frames == 3
# def test_set_n_frames(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
# d.n_frames = 9
# m.assert_called_once_with(9)
# def test_nframes_without_detector(d):
# assert d.n_frames == -100
# def test_set_n_frames_raises_on_neg(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
# with pytest.raises(DetectorValueError):
# d.n_frames = -1
# def test_set_n_frames_raises_on_zero(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
# with pytest.raises(DetectorValueError):
# d.n_frames = 0
# def test_n_cycles_without_detector(d):
# assert d.n_cycles == -100
# def test_set_n_cycles_raises_on_zero(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setCycles')
# with pytest.raises(DetectorValueError):
# d.n_cycles = 0
# def test_set_n_cycles(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setCycles')
# d.n_cycles = 56
# m.assert_called_once_with(56)
# def test_n_measurements_without_detector(d):
# assert d.n_measurements == -100
# def test_set_n_measurements_raises_on_zero(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setNumberOfMeasurements')
# with pytest.raises(DetectorValueError):
# d.n_measurements = 0
# def test_set_n_measurements(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setNumberOfMeasurements')
# d.n_measurements = 560
# m.assert_called_once_with(560)
# def test_get_n_modules_no_detector(d):
# assert d.n_modules == 0
# def test_get_n_modules(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
# m.return_value = 12
# assert d.n_modules == 12
# def test_get_period_time(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getPeriod')
# m.return_value = 130000000
# assert d.period == 0.13
# def test_set_period_time(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setPeriod')
# d.period = 1.953
# m.assert_called_once_with(1953000000)
# def test_set_period_time_less_than_zero(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setPeriod')
# with pytest.raises(ValueError):
# d.period = -7
# def test_get_online(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getOnline')
# d.online
# m.assert_called_once_with()
# def test_set_online(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setOnline')
# d.online = True
# m.assert_called_once_with(True)
# def test_last_client_ip_no_detector(d):
# assert d.last_client_ip == ''
# def test_last_cliten_ip_call(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getLastClientIP')
# d.last_client_ip
# m.assert_called_once_with()
# #-------------------------------------------------------------Rate correction
# def test_get_rate_correction(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getRateCorrection')
# m.return_value = [132,129]
# assert d.rate_correction == [132,129]
# def test_set_rate_correction(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setRateCorrection')
# mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
# mock_n.return_value = 3
# d.rate_correction = [123,90,50]
# m.assert_called_once_with([123,90,50])
# def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setRateCorrection')
# mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
# mock_n.return_value = 4
# with pytest.raises(ValueError):
# d.rate_correction = [123,90,50]
# #----------------------------------------------------------------Readout clock
# def test_get_readout_clock_0(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
# m.return_value = 0
# assert d.readout_clock == 'Full Speed'
# def test_get_readout_clock_1(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
# m.return_value = 1
# assert d.readout_clock == 'Half Speed'
# def test_get_readout_clock_2(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
# m.return_value = 2
# assert d.readout_clock == 'Quarter Speed'
# def test_get_readout_clock_3(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
# m.return_value = 3
# assert d.readout_clock == 'Super Slow Speed'
# def test_set_readout_clock_0(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Full Speed'
# m.assert_called_once_with(0)
# def test_set_readout_clock_1(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Half Speed'
# m.assert_called_once_with(1)
# def test_set_readout_clock_2(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Quarter Speed'
# m.assert_called_once_with(2)
# def test_set_readout_clock_3(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Super Slow Speed'
# m.assert_called_once_with(3)
# #----------------------------------------------------------------rx_datastream
# def test_get_rx_datastream(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getRxDataStreamStatus')
# m.return_value = False
# assert d.rx_datastream == False
# def test_set_rx_datastream(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setRxDataStreamStatus')
# d.rx_datastream = True
# m.assert_called_once_with(True)
# def test_get_rx_zmqip(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# d.rx_zmqip
# m.assert_called_once_with('rx_zmqip')
# def test_get_rx_zmqport_call(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# d.rx_zmqport
# m.assert_called_once_with('rx_zmqport')
# def test_get_rx_zmqport_decode(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# m.return_value = ['30001', '30003']
# assert d.rx_zmqport == [30001, 30003]
# def test_get_rx_zmqport_empty(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# m.return_value = ''
# assert d.rx_zmqport == []
# #--------------------------------------------------------------------status
# def test_status_call(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getRunStatus')
# d.status
# m.assert_called_once_with()
# def test_start_detecor(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.startAcquisition')
# d.start_detector()
# m.assert_called_once_with()
# def test_stop_acq_call(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.stopAcquisition')
# d.stop_detector()
# m.assert_called_once_with()
# #------------------------------------------------------------------timing mode
# def test_get_timing_mode(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getTimingMode')
# d.timing_mode
# m.assert_called_once_with()
# def test_set_timing_mode(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setTimingMode')
# d.timing_mode = 'auto'
# m.assert_called_once_with('auto')
# #----------------------------------------------------------------vthreshold
# def test_get_vthreshold(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getDac')
# d.vthreshold
# m.assert_called_once_with('vthreshold', -1)
# def test_set_vthreshold(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setDac')
# d.vthreshold = 1675
# m.assert_called_once_with('vthreshold', -1, 1675)

View File

@ -1,12 +1,33 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Testing parameters and methods of the Detector class using mocks
Testing functions from utils.py
"""
import pytest
from sls_detector.utils import eiger_register_to_time
from sls_detector.utils import all_equal, element_if_equal
from slsdet.utils import *
import datetime as dt
def test_iterable():
assert is_iterable(5) == False
assert is_iterable('abc') == True
assert is_iterable([]) == True
assert is_iterable(5.9) == False
def test_reduce_time_to_single_value_from_list():
t = 3*[dt.timedelta(seconds = 1)]
assert reduce_time(t) == 1
def test_reduce_time_to_single_value_from_list_of_lists():
t = 3*[dt.timedelta(seconds = 3.3)]
tt = 5*t
assert reduce_time(tt) == 3.3
def test_reduce_time_when_sublist_is_different():
t = [dt.timedelta(seconds = 1), dt.timedelta(seconds = 2), dt.timedelta(seconds = 1)]
tt = [t for i in range(4)]
assert reduce_time(tt) == [1,2,1]
def test_convert_zero():
assert eiger_register_to_time(0) == 0
@ -47,4 +68,29 @@ def test_element_if_equal_str():
assert element_if_equal('hhh') == 'h'
def test_element_if_equal_int_fails():
assert element_if_equal([5, 6, 7]) == [5, 6, 7]
assert element_if_equal([5, 6, 7]) == [5, 6, 7]
def test_get_set_bits():
assert(get_set_bits(0) == [])
assert get_set_bits(7) == [0, 1, 2]
def test_list_to_mask():
assert(list_to_bitmask([0,1,2]) == 7)
assert(list_to_bitmask([]) == 0)
assert(list_to_bitmask([0]) == 1)
assert(list_to_bitmask([1]) == 2)
assert(list_to_bitmask([3]) == 8)
assert(list_to_bitmask([1,1,1]) == 2)
def test_make_timedelta_from_double():
t = 1.7
r = make_timedelta(t)
assert t == r.total_seconds()
assert r == dt.timedelta(seconds=t)
def test_make_timedelta_from_timedelta():
t = dt.timedelta(minutes=1)
r = make_timedelta(t)
assert 60 == r.total_seconds()
assert r == dt.timedelta(minutes=1)

View File

@ -1,21 +1,35 @@
add_executable(a api.cpp)
target_link_libraries(a
slsDetectorShared
add_executable(using_logger using_logger.cpp)
target_link_libraries(using_logger
slsSupportLib
pthread
rt
)
set_target_properties(a PROPERTIES
set_target_properties(using_logger PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
add_executable(result useResult.cpp)
target_link_libraries(result
slsDetectorShared
)
# add_executable(result useResult.cpp)
# target_link_libraries(result
# slsDetectorShared
# )
# set_target_properties(result PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
# )
# add_executable(udp udp.cpp)
# target_link_libraries(udp
# slsDetectorShared
# slsSupportLib
# pthread
# rt
# fmt
# )
# set_target_properties(udp PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
# )
set_target_properties(result PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)

65
sample/udp.cpp Normal file
View File

@ -0,0 +1,65 @@
#include "UdpRxSocket.h"
#include "sls_detector_defs.h"
#include <chrono>
#include <fmt/format.h>
#include <iostream>
#include <thread>
#include "network_utils.h"
// Assume packages arrive in order
// Assume frame nr starts from 0
using header_t = slsDetectorDefs::sls_detector_header;
int main() {
fmt::print("Hej!\n");
constexpr ssize_t packet_size = 4144;
constexpr ssize_t payload_size = packet_size - sizeof(header_t);
int port = 50012;
char * buffer = new char[packet_size];
sls::UdpRxSocket s(port, packet_size, "10.1.1.107");
int n = 0;
while(true){
// s.ReceiveDataOnly(buffer);
if (s.ReceivePacket())
std::cout << n++ << std::endl;
}
// auto header = reinterpret_cast<header_t *>(s.buffer());
// char *data = s.buffer() + sizeof(header_t);
// fmt::print("buffer start: {}\nheader: {}\ndata: {}\n", fmt::ptr(s.buffer()),
// fmt::ptr(header), fmt::ptr(data));
// int n = 0;
// fmt::print("Buffer size: {}\n", s.buffer_size());
// std::vector<uint16_t> image(n_pixels);
// char *image_data = (char *)image.data();
// uint64_t frame_nr = 0;
// while (true) {
// if (s.ReceivePacket()) {
// // fmt::print("frame: {} pkt: {} dst: {}\n", header->frameNumber,
// // header->packetNumber, header->packetNumber*payload_size);
// if (header->frameNumber != frame_nr) {
// // dispatch frame
// fmt::print("frame {} done! got: {} pkgs\n", frame_nr, n);
// frame_nr = header->frameNumber;
// n = 0;
// std::this_thread::sleep_for(std::chrono::milliseconds(1));
// }
// ++n;
// memcpy(image_data + header->packetNumber * payload_size, data,
// payload_size);
// } else {
// std::cout << "timeout\n";
// }
// }
}

42
sample/using_logger.cpp Normal file
View File

@ -0,0 +1,42 @@
#include "logger.h"
#include <iostream>
#include <chrono>
int main() {
//compare old and new
std::cout << "Compare output between old and new:\n";
LOG(logINFO) << "Some info message";
LOG(logERROR) << "This is an error";
LOG(logWARNING) << "While this is only a warning";
//Logging level can be configure at runtime
std::cout << "\n\n";
std::cout << "The default macro controlled level is: "
<< sls::Logger::ToString(LOG_MAX_REPORTING_LEVEL) << '\n';
sls::Logger::ReportingLevel() = logERROR;
LOG(logINFO) << "Now this is not written";
LOG(logWARNING) << "and also not this";
sls::Logger::ReportingLevel() = logINFO;
LOG(logINFO) << "But now we can see it";
//The output can be redirected to another buffer
std::ostringstream local;
auto clog_buff = std::clog.rdbuf();
std::clog.rdbuf(local.rdbuf());
LOG(logINFOBLUE) << "A message";
LOG(logWARNING) << "And another one";
std::clog.rdbuf(clog_buff); // restore
std::cout << "local buf:\n" << local.str();
LOG(logINFO) << "After reset we should print directly";
LOG(logINFOBLUE) << "some infoBLUE text";
LOG(logINFOGREEN) << "some infoGREEN text";
LOG(logINFORED) << "some infoRED text";
}

Binary file not shown.

View File

@ -14,27 +14,27 @@ class MovingStat
/** constructor
\param nn number of samples parameter to be used
*/
MovingStat(int nn=1000) : n(nn), m_n(0) {}
MovingStat(int nn) : n(nn), m_n(0), m_newM(0),m_newM2(0) {}
// void setPointers(double *me, double *va) {mean=me; var=va;}
/**
clears the moving average number of samples parameter, mean and standard deviation
*/
void Clear()
{
void Clear()
{
m_n = 0;
m_newM=0;
m_newM2=0;
}
}
/**
clears the moving average number of samples parameter, mean and standard deviation
*/
void Set(double val, double rms=0, int m=-1)
{
if (m>0) m_n = m; else m_n = n;
if (m>=0) m_n = m; else m_n = n;
m_newM=val*m_n;
// cout << "set " << val << " " << m << " " << m_n << " " << m_newM << endl;
SetRMS(rms);
// cout << "set " << val << " " << m << " " << m_n << " " << m_newM << endl;
}
/**
clears the moving average number of samples parameter, mean and standard deviation
@ -42,12 +42,15 @@ class MovingStat
void SetRMS(double rms)
{
if (rms<=0) {
m_newM2=m_newM*m_newM/n;
if (m_n>0)
m_newM2=m_newM*m_newM/m_n;
else
m_newM2=0;
//m_n=0;
} else {
if (m_n>0)
if (m_n>0) {
m_newM2=(m_n*rms*rms+m_newM*m_newM/m_n);
else {
} else {
m_newM2=(m_n*rms*rms+m_newM*m_newM/n);
m_n=0;
}
@ -102,13 +105,14 @@ class MovingStat
m_newM = x;
m_newM2 = x*x;
m_n++;
} else {
m_newM = m_newM + x - m_newM/m_n;
m_newM2 = m_newM2 + x*x - m_newM2/m_n;
}
}
else {
m_newM = m_newM + x - m_newM/m_n;
m_newM2 = m_newM2 + x*x - m_newM2/m_n;
}
}
/** returns the current number of elements of the moving average
\returns returns the current number of elements of the moving average
*/
@ -122,7 +126,9 @@ class MovingStat
inline double Mean() const
{
// cout << "get " << m_n << " " << m_newM << " " << m_newM/m_n << endl;
return (m_n > 0) ? m_newM/m_n : 0.0;
return (m_n > 0) ? m_newM/m_n : 0.0;
}
/** returns the squared mean, 0 if no elements are inside
@ -138,7 +144,7 @@ class MovingStat
*/
inline double Variance() const
{
return ( (m_n > 1) ? (M2()-Mean()*Mean()) : 0.0 );
return (m_n > 0) ? m_newM2/m_n-m_newM/m_n*m_newM/m_n : 0.0;
}
/** returns the standard deviation, 0 if no elements are inside
@ -146,7 +152,8 @@ class MovingStat
*/
inline double StandardDeviation() const
{
return ( (Variance() > 0) ? sqrt( Variance() ) : -1 );
return sqrt(Variance());//
}
private:

View File

@ -68,10 +68,15 @@ template <class dataType> class analogDetector {
det->getDetectorSize(nx,ny);
stat=new pedestalSubtraction*[ny];
/* pedMean=new double*[ny]; */
/* pedVariance=new double*[ny]; */
for (int i=0; i<ny; i++) {
stat[i]=new pedestalSubtraction[nx];
for (int ix=0; ix<nx; ix++) {
/* pedMean[i]=new double[nx]; */
/* pedVariance[i]=new double[nx]; */
for (ix=0; ix<nx; ++ix) {
stat[i][ix].SetNPedestals(nped);
/* stat[i][ix].setPointers(&(pedMean[iy][ix]),&(pedVariance[iy][ix])); */
}
}
image=new int[nx*ny];
@ -95,7 +100,16 @@ template <class dataType> class analogDetector {
/**
destructor. Deletes the pdestalSubtraction array and the image
*/
virtual ~analogDetector() {for (int i=0; i<ny; i++) delete [] stat[i]; delete [] stat; delete [] image;
virtual ~analogDetector() {
for (int i=0; i<ny; i++) {
delete [] stat[i];
/* delete [] pedMean[i]; */
/* delete [] pedVariance[i]; */
};
/* delete [] pedMean; */
/* delete [] pedVariance; */
delete [] stat;
delete [] image;
#ifdef ROOTSPECTRUM
delete hs;
#ifdef ROOTCLUST
@ -132,16 +146,23 @@ template <class dataType> class analogDetector {
stat=new pedestalSubtraction*[ny];
/* pedMean=new double*[ny]; */
/* pedVariance=new double*[ny]; */
for (int i=0; i<ny; i++) {
stat[i]=new pedestalSubtraction[nx];
/* pedMean[i]=new double[nx]; */
/* pedVariance[i]=new double[nx]; */
}
int nped=orig->SetNPedestals();
//cout << nped << " " << orig->getPedestal(ix,iy) << orig->getPedestalRMS(ix,iy) << endl;
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
for (iy=0; iy<ny; ++iy) {
for (ix=0; ix<nx; ++ix) {
//stat[iy][ix].setPointers(&(pedMean[iy][ix]),&(pedVariance[iy][ix]));
stat[iy][ix].SetNPedestals(nped);
setPedestal(ix,iy,orig->getPedestal(ix,iy),orig->getPedestalRMS(ix,iy),orig->GetNPedestals(ix,iy));
/* if (ix==50 && iy==50) */
/* cout << "clone ped " << " " << ix << " " << iy << " " << getPedestal(ix,iy) << " " << getPedestalRMS(ix,iy)<< " " << GetNPedestals(ix,iy) << endl; */
}
}
image=new int[nx*ny];
@ -199,7 +220,7 @@ template <class dataType> class analogDetector {
\param nns reference to number of subpixels for interpolating detector, will always be 1 in this case
\returns number of pixels of the detector image
*/
virtual int getImageSize(int &nnx, int &nny, int &nns){nnx=nx; nny=ny; nns=1; return nx*ny;};
virtual int getImageSize(int &nnx, int &nny, int &nnsx, int &nnsy){nnx=nx; nny=ny; nnsx=1; nnsy=1; return nx*ny;};
/**
Returns data size of the detector image matrix
\param nnx reference to pixel size in x
@ -231,8 +252,8 @@ template <class dataType> class analogDetector {
if (gm) {
if (gmap) delete [] gmap;
gmap=new double[nnx*nny];
for (int iy=0; iy<nny; iy++) {
for (int ix=0; ix<nnx; ix++) {
for (iy=0; iy<nny; ++iy) {
for (ix=0; ix<nnx; ++ix) {
gmap[iy*nnx+ix]=gm[iy*nnx+ix];
// cout << gmap[iy*nnx+ix] << " " ;
}
@ -251,8 +272,8 @@ template <class dataType> class analogDetector {
void *ret;
if (gmap) {
gm=new float[nx*ny];
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
for (iy=0; iy<ny; ++iy) {
for (ix=0; ix<nx; ++ix) {
gm[iy*nx+ix]=gmap[iy*nx+ix];
}
}
@ -267,8 +288,8 @@ template <class dataType> class analogDetector {
virtual void newDataSet(){
iframe=-1;
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++) {
for (iy=0; iy<ny; ++iy)
for (ix=0; ix<nx; ++ix) {
stat[iy][ix].Clear();
image[iy*nx+ix]=0;
}
@ -285,15 +306,17 @@ template <class dataType> class analogDetector {
};
/** resets the commonModeSubtraction and increases the frame index */
virtual void newFrame(){iframe++; if (cmSub) cmSub->newFrame();};
virtual void newFrame(){iframe++; if (cmSub) cmSub->newFrame(); det->newFrame();};
/** resets the commonModeSubtraction and increases the frame index */
virtual void newFrame(char *data){
iframe++;
if (cmSub) cmSub->newFrame();
det->newFrame();
// det->getData(data);
calcGhost(data);
// cout << getId() << " Calc ghost " << getGhost(15,15) << endl;
};
};
/** sets the commonModeSubtraction algorithm to be used
@ -359,8 +382,8 @@ template <class dataType> class analogDetector {
// cout << "+"<< getId() << endl;
if (cmSub) {
//cout << "*" << endl;
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
for (iy=ymin; iy<ymax; ++iy) {
for (ix=xmin; ix<xmax; ++ix) {
// if (getNumpedestals(ix,iy)>0)
// if (det->isGood(ix,iy)) {
addToCommonMode(data, ix, iy);
@ -403,8 +426,10 @@ template <class dataType> class analogDetector {
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
if (cmSub && cm>0) {
return stat[iy][ix].getPedestal()+getCommonMode(ix,iy);
} else return stat[iy][ix].getPedestal();
//return pedMean[iy][ix]+getCommonMode(ix,iy);
}
//return pedMean[iy][ix];
return stat[iy][ix].getPedestal();
} else return -1;
};
@ -422,7 +447,7 @@ template <class dataType> class analogDetector {
g=gmap[iy*nx+ix];
if (g==0) g=-1.;
}
// return sqrt(pedVariance[iy][ix])/g;
return stat[iy][ix].getPedestalRMS()/g;//divide by gain?
}
return -1;
@ -441,10 +466,11 @@ template <class dataType> class analogDetector {
\returns pedestal value
*/
virtual double* getPedestal(double *ped){
if (ped==NULL)
if (ped==NULL) {
ped=new double[nx*ny];
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
}
for (iy=0; iy<ny; ++iy) {
for (ix=0; ix<nx; ++ix) {
ped[iy*nx+ix]=stat[iy][ix].getPedestal();
//cout << ped[iy*nx+ix] << " " ;
}
@ -459,10 +485,11 @@ template <class dataType> class analogDetector {
\returns pedestal rms
*/
virtual double* getPedestalRMS(double *ped=NULL){
if (ped==NULL)
if (ped==NULL) {
ped=new double[nx*ny];
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
}
for (iy=0; iy<ny; ++iy) {
for (ix=0; ix<nx; ++ix) {
ped[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
}
}
@ -501,8 +528,8 @@ template <class dataType> class analogDetector {
*/
virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){
double rr=0;
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
for (iy=ymin; iy<ymax; ++iy) {
for (ix=xmin; ix<xmax; ++ix) {
if (rms) rr=rms[iy*nx+ix];
stat[iy][ix].setPedestal(ped[iy*nx+ix],rr, m);
// cout << ix << " " << iy << " " << ped[iy*nx+ix] << " " << stat[iy][ix].getPedestal() << endl;
@ -531,8 +558,8 @@ template <class dataType> class analogDetector {
\param rms pointer to array of pedestal rms
*/
virtual void setPedestalRMS(double *rms){
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
for (iy=ymin; iy<ymax; ++iy) {
for (ix=xmin; ix<xmax; ++ix) {
stat[iy][ix].setPedestalRMS(rms[iy*nx+ix]);
};
};
@ -572,8 +599,8 @@ template <class dataType> class analogDetector {
#endif
gm=new float[nx*ny];
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
for (iy=0; iy<ny; ++iy) {
for (ix=0; ix<nx; ++ix) {
gm[iy*nx+ix]=image[iy*nx+ix];
#ifdef ROOTSPECTRUM
hmap->SetBinContent(ix+1, iy+1,image[iy*nx+ix]);
@ -620,8 +647,8 @@ template <class dataType> class analogDetector {
TH2F *hmap=new TH2F("hmap","hmap",nx, -0.5,nx-0.5, ny, -0.5, ny-0.5);
#endif
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
for (iy=0; iy<ny; ++iy) {
for (ix=0; ix<nx; ++ix) {
/* if (cmSub) */
/* gm[iy*nx+ix]=stat[iy][ix].getPedestal()-cmSub->getCommonMode(); */
/* else */
@ -667,15 +694,15 @@ template <class dataType> class analogDetector {
if (gm) {
for (int iy=0; iy<nny; iy++) {
for (int ix=0; ix<nnx; ix++) {
for (iy=0; iy<nny; ++iy) {
for (ix=0; ix<nnx; ++ix) {
stat[iy][ix].setPedestal(gm[iy*nx+ix],-1,-1);
}
}
delete [] gm;
return 1;
}
return NULL;
return 0;
}
/**
@ -692,15 +719,15 @@ template <class dataType> class analogDetector {
if (gm) {
for (int iy=0; iy<nny; iy++) {
for (int ix=0; ix<nnx; ix++) {
for (iy=0; iy<nny; ++iy) {
for (ix=0; ix<nnx; ++ix) {
image[iy*nx+ix]=gm[iy*nx+ix];
}
}
delete [] gm;
return 1;
}
return NULL;
return 0;
}
@ -718,9 +745,9 @@ template <class dataType> class analogDetector {
float *gm=NULL;
void *ret;
gm=new float[nx*ny];
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
gm[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
for (iy=0; iy<ny; ++iy) {
for (ix=0; ix<nx; ++ix) {
gm[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
}
}
ret=WriteToTiff(gm, imgname, ny, nx);
@ -740,8 +767,8 @@ template <class dataType> class analogDetector {
if (nnx>nx) nnx=nx;
if (nny>ny) nny=ny;
if (gm) {
for (int iy=0; iy<nny; iy++) {
for (int ix=0; ix<nnx; ix++) {
for (iy=0; iy<nny; ++iy) {
for (ix=0; ix<nnx; ++ix) {
stat[iy][ix].setPedestalRMS(gm[iy*nx+ix]);
}
}
@ -777,11 +804,13 @@ template <class dataType> class analogDetector {
//cout << xmin << " " << xmax << endl;
// cout << ymin << " " << ymax << endl;
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
for (iy=ymin; iy<ymax; ++iy) {
for (ix=xmin; ix<xmax; ++ix) {
if (det->isGood(ix,iy)) {
// addToPedestal(data,ix,iy,1);
addToPedestal(data,ix,iy,cm);
/* if (ix==50 && iy==50) */
/* cout<< "*ped* " << id << " " << ix << " " << iy << " " << det->getChannel(data,ix,iy) << " " << stat[iy][ix].getPedestal() << " " << stat[iy][ix].getPedestalRMS() <<" " << stat[iy][ix]. GetNPedestals() << endl; */
//if (ix==10 && iy==10)
// cout <<ix << " " << iy << " " << getPedestal(ix,iy)<< endl;
#ifdef ROOTSPECTRUM
@ -905,8 +934,8 @@ template <class dataType> class analogDetector {
//calcGhost(data);
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
for (iy=ymin; iy<ymax; ++iy) {
for (ix=xmin; ix<xmax; ++ix) {
if (det->isGood(ix,iy))
val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm);
}
@ -952,8 +981,8 @@ template <class dataType> class analogDetector {
hs->Fill(val,(iy-ymin)*(xmax-xmin)+(ix-xmin));
#ifdef ROOTCLUST
double v3=0,v5=0,v7=0,v9=0;
for (int iix=-4; iix<5; iix++)
for (int iiy=-4; iiy<5; iiy++) {
for (int iix=-4; iix<5; i++ix)
for (int iiy=-4; iiy<5; i++iy) {
if (det)
val= (dataSign*det->getValue(data, ix+iix, iy+iiy)-getPedestal(ix+iix,iy+iiy,cm))/g;
else
@ -1047,8 +1076,8 @@ template <class dataType> class analogDetector {
//calcGhost(data);
addToCommonMode(data);
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
for (iy=ymin; iy<ymax; ++iy) {
for (ix=xmin; ix<xmax; ++ix) {
if (det->isGood(ix,iy))
nph[iy*nx+ix]+=getNPhotons(data, ix, iy);
}
@ -1062,8 +1091,8 @@ template <class dataType> class analogDetector {
*/
virtual void clearImage(){
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
for (iy=0; iy<ny; ++iy) {
for (ix=0; ix<nx; ++ix) {
image[iy*nx+ix]=0;
}
}
@ -1093,8 +1122,8 @@ template <class dataType> class analogDetector {
int SetNPedestals(int i=-1) {
int ix=0, iy=0;
if (i>0)
for (iy=0; iy<ny; iy++)
for (ix=0; ix<nx; ix++)
for (iy=0; iy<ny; ++iy)
for (ix=0; ix<nx; ++ix)
stat[iy][ix].SetNPedestals(i);
return stat[0][0].SetNPedestals();
};
@ -1129,8 +1158,8 @@ template <class dataType> class analogDetector {
newFrame(data);
//calcGhost(data);
addToCommonMode(data);
for (int iy=ymi; iy<yma; iy++)
for (int ix=xmi; ix<xma; ix++)
for (iy=ymi; iy<yma; ++iy)
for (ix=xmi; ix<xma; ++ix)
if (det->isGood(ix,iy)) {
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
val+=getNPhotons(data, ix, iy);
@ -1233,6 +1262,8 @@ FILE *getFilePointer(){return myFile;};
int nx; /**< Size of the detector in x direction */
int ny; /**< Size of the detector in y direction */
pedestalSubtraction **stat; /**< pedestalSubtraction class */
/* double **pedMean; /\**< pedestalSubtraction class *\/ */
/* double **pedVariance; /\**< pedestalSubtraction class *\/ */
commonModeSubtraction *cmSub;/**< commonModeSubtraction class */
int dataSign; /**< sign of the data i.e. 1 if photon is positive, -1 if negative */
int iframe; /**< frame number (not from file but incremented within the dataset every time newFrame is called */
@ -1250,6 +1281,7 @@ FILE *getFilePointer(){return myFile;};
frameMode fMode; /**< current detector frame mode */
detectorMode dMode; /**< current detector frame mode */
FILE *myFile; /**< file pointer to write to */
int ix, iy;
#ifdef ROOTSPECTRUM
TH2F *hs;
#ifdef ROOTCLUST

View File

@ -1,6 +1,7 @@
#ifndef DESERIALIZER_H
#define DESERIALIZER_H
#include <vector>
#include "slsDetectorData.h"
class deserializer : public slsDetectorData<int> {
@ -52,7 +53,13 @@ class deserializer : public slsDetectorData<int> {
static int* deserializeAll(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) {
// off=0;
//int iarg;
int64_t word, *wp;
cout <<"** deserializer: " << endl;
cout << "** Number of chans:\t" << nch << endl;
cout << "** Serial Offset:\t" << off << endl;
cout << "** Dynamic range:\t" << dr << endl;
int64_t word, *wp, ww,one=1, bit ;
int* val=new int[nch];
int ioff=0;
int idr=0;
@ -66,39 +73,62 @@ class deserializer : public slsDetectorData<int> {
val[ib]=0;
}
wp=(int64_t*)ptr;
int nw=nch/nb;
cout << "** Number of bits:\t" << nb << endl;
cout << "** Samples:\t" << nw << endl;
for (ib=0; ib<nb; ib++) {
cout << dbl[ib] << " " ;
}
cout << endl;
for (iw=0; iw<nch/nb; iw) {
for (ib=0; ib<nch; ib++) {
val[ib]=0;
}
for (iw=0; iw<nw; iw) {
word=*wp;;
if (ioff<off) {
ioff++;
// cout <<"*";
} else {
//if (idr<16) {
ib=0;
for (const auto &bit : dbl) {
ich=iw+nch/nb*(ib);
if (word&(1<<bit) && ich<nch) {
//ib=0;
// cout << hex << "*************" << word << endl;
for (ib=0; ib<nb; ib++) {
// for (const auto &bit : dbl) {
ich=iw+nch*ib/nb;
/* if (ich>1060) */
/* cout << iw << " " << idr << " " << ib << " " << bit << " " << ich << " " << val[ich] << " ** " ; */
bit=dbl[ib];
ww=one<<bit;
if (word&(ww) && ich<nch) {
//cout << "+" ;
val[ich]|=(1<<idr);
} //else {
}
/* if (ich>1060) */
/* cout << val[ich] << " " << hex << word << " " << ww << " " << (word&(ww)) << dec <<endl; */
/* //else { */
//cout << "-" ;
//}
ib++;
//ib++;
}
idr++;
}
idr++;
if (idr==dr) {
idr=0;
// cout << dec << " " << iw << " " << val[iw] << " " << val[iw+nch/2] << endl;
cout <<dec << iw<<endl;
// cout <<dec << iw<<endl;
iw++;
}//end if()
//end else()
wp+=1;
ii++;
// ii++;
}//end for
@ -117,7 +147,7 @@ class deserializer : public slsDetectorData<int> {
int ii=0;
int ich;
int nb=dbl.size();
int bit;
char *dval;
idr=0;
@ -127,8 +157,13 @@ class deserializer : public slsDetectorData<int> {
dval=ptr;
ib=0;
ich=0;
for (const auto &bit : dbl) {
ich=0;
for (ib=0; ib<nb; ib++) {
// for (const auto &bit : dbl) {
/* if (ich>1060) */
/* cout << iw << " " << idr << " " << ib << " " << bit << " " << ich << " " << val[ich] << " ** " ; */
bit=dbl[ib];
//ioff=off;
idr=0;
for (iw=0; iw<(nch*dr/nb)/8; iw++) {
@ -141,7 +176,7 @@ class deserializer : public slsDetectorData<int> {
}
}
ii++;
ib++;
// ib++;
}//end for

View File

@ -0,0 +1,125 @@
#ifndef IMAGEZMQ16BIT_H
#define IMAGEZMQ16BIT_H
#include "slsDetectorData.h"
class imageZmq16bit : public slsDetectorData<uint16_t> {
private:
// int iframe;
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
(160x160 pixels, 40 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
// moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
imageZmq16bit(int nnx=400, int nny=400): slsDetectorData<uint16_t>(nnx, nny, 2*nnx*nny) {
cout << "* " << nx << " " << ny << endl;
int is=0;
for (int row=0; row<ny; row++){
for(int col=0;col<nx;col++){
dataMap[row][col]=is*2;
is++;
}
}
};
virtual double getValue(char *data, int ix, int iy=0) {
cout << ix << " " << ix << dataMap[iy][ix] << 2*nx*ny << " "<< endl;
uint16_t val=getChannel(data, ix, iy)&0x3fff;
return val;
};
int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;};
int getPacketNumber(char *buff){return 0;}//((*(((int*)(buff+4))))&0xff)+1;};
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[2*nx*ny];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
//char *retval=0;
// int nd;
//int fnum = -1;
np=0;
// int pn;
// if (ff>=0)
// fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, 2*nx*ny) ){
// iframe++;
//ff=iframe;
return data;
}
}
return NULL;
};
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize<2*nx*ny) ndata=dsize;
else ndata=2*nx*ny;
return data;
}
// virtual int setFrameNumber(int ff){iframe=ff};
int getPacketNumber(int x, int y) {return 0;};
};
#endif

View File

@ -0,0 +1,125 @@
#ifndef IMAGEZMQ32BIT_H
#define IMAGEZMQ32BIT_H
#include "slsDetectorData.h"
class imageZmq32bit : public slsDetectorData<uint16_t> {
private:
// int iframe;
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
(160x160 pixels, 40 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
// moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
imageZmq32bit(int nnx=400, int nny=400): slsDetectorData<uint16_t>(nnx, nny, sizeof(uint32_t)*nnx*nny) {
cout << "* " << nx << " " << ny << endl;
int is=0;
for (int row=0; row<ny; row++){
for(int col=0;col<nx;col++){
dataMap[row][col]=is*sizeof(uint32_t);
is++;
}
}
};
/* virtual double getValue(char *data, int ix, int iy=0) { */
/* //cout << ix << " " << ix << dataMap[iy][ix] << 2*nx*ny << " "<< endl; */
/* uint16_t val=getChannel(data, ix, iy); */
/* return val; */
/* }; */
int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;};
int getPacketNumber(char *buff){return 0;}//((*(((int*)(buff+4))))&0xff)+1;};
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[2*nx*ny];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
//char *retval=0;
// int nd;
//int fnum = -1;
np=0;
// int pn;
// if (ff>=0)
// fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, 2*nx*ny) ){
// iframe++;
//ff=iframe;
return data;
}
}
return NULL;
};
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize<2*nx*ny) ndata=dsize;
else ndata=2*nx*ny;
return data;
}
// virtual int setFrameNumber(int ff){iframe=ff};
int getPacketNumber(int x, int y) {return 0;};
};
#endif

View File

@ -28,7 +28,8 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
\param c crosstalk parameter for the output buffer
*/
moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
// moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
moench03T1ZmqDataNew(int ns=5000, int oo=0): slsDetectorData<uint16_t>(400, 400, ns*32*2+oo), nSamples(ns), offset(oo), xtalk(0.00021) {
int nadc=32;
int sc_width=25;
@ -137,6 +138,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
/* vout+=0.0008*val-6224; */
/* return vout; //(double)getChannel(data, ix, iy);
*/
// cout << ix << " "<< iy << " " << dataMap[iy][ix] << endl;
return ((double)getChannel(data, ix, iy))+xtalk*getGhost(iy,iy);
};

View File

@ -44,6 +44,28 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
int adc_nr[32]={9, 8,11,10,13,12,15,14,1,0,3,2,5,4,7,6,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24 };
/*
iadc=ptr%32
isample=ptr/32
col=(adc_nr[iadc]%16)*25+isample%25
if (adc_nr[iadc]<16)
row=199-isample/25;
else
row=200+isample/25
adc0 col(9*25..10*25-1) row(199..0)
adc1 col(8*25..9*25-1) row(199..0)
adc2 col(11*25..12*25-1) row(199..0)
adc3 col(10*25..11*25-1) row(199..0)
adc4 col(13*25..14*25-1) row(199..0)
adc5 col(12*25..13*25-1) row(199..0)
adc6 col(15*25..16*25-1) row(199..0)
adc7 col(14*25..15*25-1) row(199..0)
adc8 col(1*25..2*25-1) row(199..0)
*/
int row, col;
//int isample;
@ -134,7 +156,7 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
if (dSamples>isample) {
ptr=data+32*(isample+1)+8*isample;
sample=*((uint64_t*)ptr);
cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
// cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
if (sample & (1<<ibit[isc]))
return 1;
else

Some files were not shown because too many files have changed in this diff Show More