Compare commits

...

213 Commits

Author SHA1 Message Date
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
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
95030bc55f Merge branch 'developer' into gotthard2 2020-01-16 16:52:08 +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
b6d9015ed0 rearranging 2020-01-15 15:08:01 +01:00
266 changed files with 17581 additions and 13554 deletions

View File

@ -17,7 +17,8 @@ Checks: '*,
-google-runtime-references,
-google-readability-todo,
-google-readability-braces-around-statements,
-modernize-use-trailing-return-type'
-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,39 +4,25 @@ language: cpp
os: linux
env:
matrix:
- CONDA_PY=3.6
- CONDA_PY=3.7
- CONDA_PY=3.8
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:
@ -45,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,8 +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)
@ -44,6 +44,9 @@ 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)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@ -111,6 +114,11 @@ if(SLS_USE_SANITIZER)
# 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
@ -126,7 +134,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)
@ -159,7 +167,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()
@ -174,6 +182,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)

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)

4
cmk.sh
View File

@ -187,8 +187,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

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

@ -1,13 +1,14 @@
package:
name: sls_detector_software
version: "developer"
version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
source:
- path: ..
build:
number: 1
number: 2
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
@ -51,70 +51,46 @@ requirements:
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.4
host:
- python
- pybind11 2.4
- 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,13 +1636,13 @@ 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));
// }
}
@ -1977,20 +2102,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 +2131,7 @@ void ctbAcquisition::ChangeDynamicRange(){
};
void ctbAcquisition::ChangeNumberOfChannels(){
changeDetector();
// if (dataStructure) {
// cout << cbDetType->GetSelected()<< endl;
// if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){
@ -2017,6 +2145,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

@ -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

@ -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 0
#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,61 @@
#initialchecks 0
#############################################
### edit with hostname or IP address of your detector
############################################
hostname bchip181+
#############################################
### 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 33410
#############################################
### edit with 10 Gbs IP of your server
############################################
#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.136
#zmqport 40001
#############################################
### edit with hostname or 1Gbs IP address of your server
############################################
rx_hostname mpc2011
tengiga 1
rx_datastream 1
frames 1
period 0.001
#############################################
### edit with directory you want to write to
############################################
fpath /mnt/moench_data/scratch/
fwrite 0
rx_datastream 1
rx_jsonpara frameMode newpedestal
rx_jsonpara detectorMode analog
rx_discardpolicy discardpartial
adcpipeline 15
powerchip 1
vhighvoltage 90
adcreg 14 40

View File

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

View File

@ -3,8 +3,8 @@
#include "ClientSocket.h"
#include "logger.h"
#include "multiSlsDetector.h"
#include "slsDetector.h"
#include "DetectorImpl.h"
#include "Module.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,7 +73,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);
CHECK(d.getStopPort() == DEFAULT_PORTNO + 1);
d.freeSharedMemory();
@ -86,11 +86,11 @@ TEST_CASE("single EIGER detector no receiver basic set and get",
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);
@ -133,7 +133,7 @@ TEST_CASE("single EIGER detector no receiver basic set and get",
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
@ -155,7 +155,7 @@ TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
}
TEST_CASE("Set settings", "[.integration][.single]"){
slsDetector d(test::type);
Module d(test::type);
d.setHostname(test::hostname);
CHECK(d.setSettings(defs::STANDARD) == defs::STANDARD);
}
@ -185,7 +185,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
@ -226,8 +226,8 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
// 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 +252,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 +302,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);
@ -387,7 +387,7 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
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);
@ -457,7 +457,7 @@ TEST_CASE("Eiger or Jungfrau startingfnum", "[.eigerintegration][.jungfrauintegr
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)));
@ -495,7 +495,7 @@ 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));

View File

@ -1,5 +1,5 @@
#include "catch.hpp"
#include "multiSlsDetector.h"
#include "DetectorImpl.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);
@ -28,7 +28,7 @@ TEST_CASE("Initialize a multi detector", "[.integration][.multi]") {
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

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,20 +1,22 @@
pybind11_add_module(_sls_detector
# find_package (Python COMPONENTS Interpreter Development)
pybind11_add_module(_slsdet
src/main.cpp
src/enums.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
)
@ -32,13 +34,14 @@ set( PYTHON_FILES
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

@ -3,13 +3,13 @@ import sys
import numpy as np
sys.path.append(os.path.join(os.getcwd(), 'bin'))
from sls_detector import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb
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()
c = Ctb()
# j = Jungfrau()
m = Mythen3()
# m = Mythen3()

View File

@ -4,13 +4,14 @@ out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.ge
cmd = out.stdout.splitlines()
cmd.pop(0)
from sls_detector import Detector, Eiger, Ctb
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_restore', 'vref_cds',
'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'

View File

@ -9,19 +9,7 @@ enums.cpp
import re
import subprocess
# 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)
from parse import remove_comments
def extract_enums(lines):
line_iter = iter(lines)

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

@ -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,32 @@ 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/detector.cpp',
'src/network.cpp'],
include_dirs=[
# Path to pybind11 headers
get_pybind_include(),
get_pybind_include(user=True),
# get_pybind_include(),
# get_pybind_include(user=True),
os.path.join('../libs/pybind11/include'),
os.path.join(get_conda_path(), 'include/slsDetectorPackage'),
],
@ -109,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,22 +0,0 @@
# 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 _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
IpAddr = _sls_detector.IpAddr
MacAddr = _sls_detector.MacAddr

View File

@ -1,121 +0,0 @@
from .detector import Detector
from .utils import element_if_equal
from .dacs import DetectorDacs
import _sls_detector
dacIndex = _sls_detector.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
@property
@element
def v_a(self):
return self.getDAC(dacIndex.V_POWER_A, True)
@v_a.setter
def v_a(self, value):
self.setDAC(dacIndex.V_POWER_A, value, True)
@property
@element
def v_b(self):
return self.getDAC(dacIndex.V_POWER_B, True)
@v_b.setter
def v_b(self, value):
self.setDAC(dacIndex.V_POWER_B, value, True)
@property
@element
def v_c(self):
return self.getDAC(dacIndex.V_POWER_C, True)
@v_c.setter
def v_c(self, value):
self.setDAC(dacIndex.V_POWER_C, value, True)
@property
@element
def v_d(self):
return self.getDAC(dacIndex.V_POWER_D, True)
@v_d.setter
def v_d(self, value):
self.setDAC(dacIndex.V_POWER_D, value, True)
@property
@element
def v_io(self):
return self.getDAC(dacIndex.V_POWER_IO, True)
@v_io.setter
def v_io(self, value):
self.setDAC(dacIndex.V_POWER_IO, value, True)
@property
@element
def v_limit(self):
return self.getDAC(dacIndex.V_LIMIT, True)
@v_limit.setter
def v_limit(self, value):
self.setDAC(dacIndex.V_LIMIT, value, True)
@property
@element
def im_a(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_A)
@property
@element
def im_b(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_B)
@property
@element
def im_c(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_C)
@property
@element
def im_d(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_D)
@property
@element
def im_io(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)

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,9 +1,9 @@
from .detector_property import DetectorProperty
from functools import partial
import numpy as np
import _sls_detector
import _slsdet
from .detector import freeze
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
dacIndex = _slsdet.slsDetectorDefs.dacIndex
class Dac(DetectorProperty):
"""
This class represents a dac on the detector. One instance handles all

View File

@ -1,33 +1,18 @@
from _sls_detector import CppDetectorApi
from _sls_detector import slsDetectorDefs
from _slsdet import CppDetectorApi
from _slsdet import slsDetectorDefs
runStatus = slsDetectorDefs.runStatus
speedLevel = slsDetectorDefs.speedLevel
dacIndex = slsDetectorDefs.dacIndex
from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask
from .utils import Geometry, to_geo
from .utils import Geometry, to_geo, element
from .registers import Register, Adc_register
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
@ -774,6 +759,22 @@ class Detector(CppDetectorApi):
CTB stuff
"""
@property
def runclk(self):
return element_if_equal(self.getRUNClock())
@runclk.setter
def runclk(self, freq):
self.setRUNClock(freq)
@property
def romode(self):
return element_if_equal(self.getReadoutMode())
@romode.setter
def romode(self, mode):
self.setReadoutMode(mode)
@property
def asamples(self):
return element_if_equal(self.getNumberOfAnalogSamples())
@ -839,9 +840,249 @@ class Detector(CppDetectorApi):
return element_if_equal(self.getMaxADCPhaseShift())
@property
def maxclkphaseshift(self):
return element_if_equal(self.getMaxClockPhaseShift())
def adcphase(self):
return element_if_equal(self.getADCPhase())
@adcphase.setter
def adcphase(self, value):
self.setADCPhase(value)
@property
def adcphase(self):
return element_if_equal()
def adcpipeline(self):
return element_if_equal(self.getADCPipeline())
@adcpipeline.setter
def adcpipeline(self, value):
self.setADCPipeline(value)
@property
def adcclk(self):
return element_if_equal(self.getADCClock())
@adcclk.setter
def adcclk(self, value):
self.setADCClock(value)
@property
def syncclk(self):
return element_if_equal(self.getSYNCClock())
@property
def pattern(self):
#TODO! Clean fix
print("Set only")
return 0
@property
def patclkctrl(self):
return element_if_equal(self.getPatternClockControl())
@patclkctrl.setter
def patclkctrl(self, mask):
self.setPatternClockControl(mask)
# patioctrl
@property
def patioctrl(self):
return element_if_equal(self.getPatternIOControl())
@patioctrl.setter
def patioctrl(self, mask):
self.setPatternIOControl(mask)
@property
def patlimits(self):
return element_if_equal(self.getPatternLoopAddresses(-1))
@patlimits.setter
def patlimits(self, lim):
self.setPatternLoopAddresses(-1, lim[0], lim[1])
@property
def patmask(self):
return element_if_equal(self.getPatternMask())
@patmask.setter
def patmask(self, mask):
self.setPatternMask(mask)
@pattern.setter
def pattern(self, fname):
self.setPattern(fname)
@property
def patwait0(self):
return element_if_equal(self.getPatternWaitAddr(0))
@patwait0.setter
def patwait0(self, addr):
self.setPatternWaitAddr(0, addr)
@property
def patwait1(self):
return element_if_equal(self.getPatternWaitAddr(1))
@patwait1.setter
def patwait1(self, addr):
self.setPatternWaitAddr(1, addr)
@property
def patwait2(self):
return element_if_equal(self.getPatternWaitAddr(2))
@patwait2.setter
def patwait2(self, addr):
self.setPatternWaitAddr(2, addr)
@property
def patwaittime0(self):
return element_if_equal(self.getPatternWaitTime(0))
@patwaittime0.setter
def patwaittime0(self, nclk):
self.setPatternWaitTime(0, nclk)
@property
def patwaittime1(self):
return element_if_equal(self.getPatternWaitTime(1))
@patwaittime1.setter
def patwaittime1(self, nclk):
self.setPatternWaitTime(1, nclk)
@property
def patwaittime2(self):
return element_if_equal(self.getPatternWaitTime(2))
@patwaittime2.setter
def patwaittime2(self, nclk):
self.setPatternWaitTime(2, nclk)
@property
def patloop0(self):
return element_if_equal(self.getPatternLoopAddresses(0))
@patloop0.setter
def patloop0(self, addr):
self.setPatternLoopAddresses(0, addr[0], addr[1])
@property
def patloop1(self):
return element_if_equal(self.getPatternLoopAddresses(1))
@patloop1.setter
def patloop1(self, addr):
self.setPatternLoopAddresses(1, addr[0], addr[1])
@property
def patloop2(self):
return element_if_equal(self.getPatternLoopAddresses(2))
@patloop2.setter
def patloop2(self, addr):
self.setPatternLoopAddresses(2, addr[0], addr[1])
@property
def patnloop0(self):
return element_if_equal(self.getPatternLoopCycles(0))
@patnloop0.setter
def patnloop0(self, n):
self.setPatternLoopCycles(0, n)
@property
def patnloop1(self):
return element_if_equal(self.getPatternLoopCycles(1))
@patnloop1.setter
def patnloop1(self, n):
self.setPatternLoopCycles(1, n)
@property
def patnloop2(self):
return element_if_equal(self.getPatternLoopCycles(2))
@patnloop2.setter
def patnloop2(self, n):
self.setPatternLoopCycles(2, n)
@property
@element
def v_a(self):
return self.getDAC(dacIndex.V_POWER_A, True)
@v_a.setter
def v_a(self, value):
self.setDAC(dacIndex.V_POWER_A, value, True)
@property
@element
def v_b(self):
return self.getDAC(dacIndex.V_POWER_B, True)
@v_b.setter
def v_b(self, value):
self.setDAC(dacIndex.V_POWER_B, value, True)
@property
@element
def v_c(self):
return self.getDAC(dacIndex.V_POWER_C, True)
@v_c.setter
def v_c(self, value):
self.setDAC(dacIndex.V_POWER_C, value, True)
@property
@element
def v_d(self):
return self.getDAC(dacIndex.V_POWER_D, True)
@v_d.setter
def v_d(self, value):
self.setDAC(dacIndex.V_POWER_D, value, True)
@property
@element
def v_io(self):
return self.getDAC(dacIndex.V_POWER_IO, True)
@v_io.setter
def v_io(self, value):
self.setDAC(dacIndex.V_POWER_IO, value, True)
@property
@element
def v_limit(self):
return self.getDAC(dacIndex.V_LIMIT, True)
@v_limit.setter
def v_limit(self, value):
self.setDAC(dacIndex.V_LIMIT, value, True)
@property
@element
def im_a(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_A)
@property
@element
def im_b(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_B)
@property
@element
def im_c(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_C)
@property
@element
def im_d(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_D)
@property
@element
def im_io(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)

View File

@ -11,8 +11,8 @@ from .detector import Detector
# from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs
import _sls_detector
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
import _slsdet
dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
# from .utils import element_if_equal
# from sls_detector.errors import DetectorValueError, DetectorError

View File

@ -9,8 +9,8 @@ from .detector import Detector, freeze
# from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs
import _sls_detector
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
import _slsdet
dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
# @freeze

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()]

View File

@ -9,8 +9,8 @@ from .detector import Detector, freeze
# from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs
import _sls_detector
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
import _slsdet
dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
# vcassh 1200,

View File

@ -2,10 +2,13 @@
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
import _slsdet #C++ lib
import functools
Geometry = namedtuple('Geometry', ['x', 'y'])
def get_set_bits(mask):
@ -26,7 +29,7 @@ def list_to_bitmask(values):
return mask
def to_geo(value):
if isinstance(value, _sls_detector.xy):
if isinstance(value, _slsdet.xy):
return Geometry(x = value.x, y = value.y)
else:
raise ValueError("Can only convert sls_detector.xy")
@ -65,3 +68,4 @@ def eiger_register_to_time(register):
clocks = register >> 3
exponent = register & 0b111
return clocks*10**exponent / 100e6

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.

View File

@ -74,9 +74,12 @@ void init_det(py::module &m) {
py::arg() = Positions{})
.def("getNumberOfTriggersLeft", &Detector::getNumberOfTriggersLeft,
py::arg() = Positions{})
.def("getPeriodLeft", &Detector::getPeriodLeft, py::arg() = Positions{})
.def("getDelayAfterTriggerLeft", &Detector::getDelayAfterTriggerLeft,
py::arg() = Positions{})
.def("getPeriodLeft", &Detector::getPeriodLeft, py::arg() = Positions{})
.def("getTimingMode", &Detector::getTimingMode, py::arg() = Positions{})
.def("setTimingMode", &Detector::setTimingMode, py::arg(),
py::arg() = Positions{})
.def("getSpeed", &Detector::getSpeed, py::arg() = Positions{})
.def("setSpeed", &Detector::setSpeed, py::arg(),
py::arg() = Positions{})
@ -109,6 +112,9 @@ void init_det(py::module &m) {
py::arg(), py::arg() = Positions{})
.def("getHighVoltage", &Detector::getHighVoltage,
py::arg() = Positions{})
.def("getPowerChip", &Detector::getPowerChip, py::arg() = Positions{})
.def("setPowerChip", &Detector::setPowerChip, py::arg(),
py::arg() = Positions{})
.def("setHighVoltage", &Detector::setHighVoltage, py::arg(),
py::arg() = Positions{})
.def("getTemperature", &Detector::getTemperature, py::arg(),
@ -121,9 +127,6 @@ void init_det(py::module &m) {
py::arg() = Positions{})
.def("setOnChipDAC", &Detector::setOnChipDAC, 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{})
.def("acquire", &Detector::acquire)
.def("clearAcquiringFlag", &Detector::clearAcquiringFlag)
.def("startReceiver", &Detector::startReceiver)
@ -395,9 +398,6 @@ void init_det(py::module &m) {
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(),
@ -428,6 +428,13 @@ void init_det(py::module &m) {
py::arg() = Positions{})
.def("setImageTestMode", &Detector::setImageTestMode, py::arg(),
py::arg() = Positions{})
.def("getNumberOfBursts", &Detector::getNumberOfBursts,
py::arg() = Positions{})
.def("setNumberOfBursts", &Detector::setNumberOfBursts, py::arg())
.def("getBurstPeriod", &Detector::getBurstPeriod,
py::arg() = Positions{})
.def("setBurstPeriod", &Detector::setBurstPeriod, py::arg(),
py::arg() = Positions{})
.def("getInjectChannel", &Detector::getInjectChannel,
py::arg() = Positions{})
.def("setInjectChannel", &Detector::setInjectChannel, py::arg(),
@ -438,9 +445,17 @@ void init_det(py::module &m) {
py::arg(), py::arg(), py::arg() = Positions{})
.def("setVetoReference", &Detector::setVetoReference, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getBurstMode", &Detector::getBurstMode, py::arg() = Positions{})
.def("setBurstMode", &Detector::setBurstMode, py::arg(),
py::arg() = Positions{})
.def("getBurstMode", &Detector::getBurstMode, py::arg() = Positions{})
.def("getCurrentSource", &Detector::getCurrentSource,
py::arg() = Positions{})
.def("setCurrentSource", &Detector::setCurrentSource, py::arg(),
py::arg() = Positions{})
.def("getTimingSource", &Detector::getTimingSource,
py::arg() = Positions{})
.def("setTimingSource", &Detector::setTimingSource, py::arg(),
py::arg() = Positions{})
.def("getCounterMask", &Detector::getCounterMask,
py::arg() = Positions{})
.def("setCounterMask", &Detector::setCounterMask, py::arg(),
@ -610,6 +625,8 @@ void init_det(py::module &m) {
py::arg() = Positions{})
.def("writeAdcRegister", &Detector::writeAdcRegister, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getInitialChecks", &Detector::getInitialChecks)
.def("setInitialChecks", &Detector::setInitialChecks, py::arg())
.def("getControlPort", &Detector::getControlPort,
py::arg() = Positions{})
.def("setControlPort", &Detector::setControlPort, py::arg(),

View File

@ -169,7 +169,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)
@ -278,4 +278,17 @@ 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)
.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

@ -19,7 +19,7 @@ void init_enums(py::module &);
void init_experimental(py::module &);
void init_det(py::module &);
void init_network(py::module &);
PYBIND11_MODULE(_sls_detector, m) {
PYBIND11_MODULE(_slsdet, m) {
m.doc() = R"pbdoc(
C/C++ API
-----------------------

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

@ -15,7 +15,7 @@ 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
@ -47,7 +47,7 @@ def test_set_counters_single(d, mocker):
# 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
@ -73,34 +73,34 @@ def test_set_counters_single(d, mocker):
# 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_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(DetectorValueError):
# 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)
@ -112,28 +112,28 @@ def test_set_counters_single(d, mocker):
# assert d.dynamic_range == -100
# 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
@ -141,25 +141,25 @@ def test_set_counters_single(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
@ -168,38 +168,38 @@ def test_set_counters_single(d, mocker):
# 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
@ -208,7 +208,7 @@ def test_set_counters_single(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
@ -216,14 +216,14 @@ def test_set_counters_single(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
@ -231,7 +231,7 @@ def test_set_counters_single(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):
@ -239,14 +239,14 @@ def test_set_counters_single(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
@ -259,12 +259,12 @@ def test_set_counters_single(d, mocker):
# assert t.vertical == 0
# 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)
@ -272,12 +272,12 @@ def test_set_counters_single(d, mocker):
# assert d.n_frames == -100
# def test_set_n_frames_raises_on_neg(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames')
# 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('_sls_detector.DetectorApi.setNumberOfFrames')
# mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
# with pytest.raises(DetectorValueError):
# d.n_frames = 0
@ -285,12 +285,12 @@ def test_set_counters_single(d, mocker):
# assert d.n_cycles == -100
# def test_set_n_cycles_raises_on_zero(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setCycles')
# mocker.patch('_slsdet.DetectorApi.setCycles')
# with pytest.raises(DetectorValueError):
# d.n_cycles = 0
# def test_set_n_cycles(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setCycles')
# m = mocker.patch('_slsdet.DetectorApi.setCycles')
# d.n_cycles = 56
# m.assert_called_once_with(56)
@ -300,12 +300,12 @@ def test_set_counters_single(d, mocker):
# assert d.n_measurements == -100
# def test_set_n_measurements_raises_on_zero(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setNumberOfMeasurements')
# mocker.patch('_slsdet.DetectorApi.setNumberOfMeasurements')
# with pytest.raises(DetectorValueError):
# d.n_measurements = 0
# def test_set_n_measurements(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setNumberOfMeasurements')
# m = mocker.patch('_slsdet.DetectorApi.setNumberOfMeasurements')
# d.n_measurements = 560
# m.assert_called_once_with(560)
@ -313,33 +313,33 @@ def test_set_counters_single(d, mocker):
# assert d.n_modules == 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_get_online(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getOnline')
# m = mocker.patch('_slsdet.DetectorApi.getOnline')
# d.online
# m.assert_called_once_with()
# def test_set_online(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setOnline')
# m = mocker.patch('_slsdet.DetectorApi.setOnline')
# d.online = True
# m.assert_called_once_with(True)
@ -347,116 +347,116 @@ def test_set_counters_single(d, mocker):
# assert d.last_client_ip == ''
# def test_last_cliten_ip_call(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getLastClientIP')
# 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('_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, 30003]
# 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_detecor(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.startAcquisition')
# m = mocker.patch('_slsdet.DetectorApi.startAcquisition')
# d.start_detector()
# 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_detector()
# m.assert_called_once_with()
@ -464,23 +464,23 @@ def test_set_counters_single(d, mocker):
# #------------------------------------------------------------------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)

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";
}

View File

@ -423,7 +423,7 @@ template <class dataType> class analogDetector {
if (g==0) g=-1.;
}
return stat[iy][ix].getPedestalRMS()/g;//divide by gain?
return stat[iy][ix].getPedestalRMS();//divide by gain?
}
return -1;
};

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

@ -1,15 +1,19 @@
INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/
INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -g -std=c++11 -Wall
#-L../../bin -lhdf5 -L.
#DESTDIR?=../bin
all: moenchZmqProcess
all: moenchZmqProcess moenchZmqProcessCtbGui
moenchZmqProcess: moenchZmqProcess.cpp clean
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
moenchZmqProcessCtbGui: moenchZmqProcess.cpp clean
g++ -o moenchZmqProcessCtbGui moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DCTBGUI
clean:
rm -f moenchZmqProcess

View File

@ -149,6 +149,7 @@ int main(int argc, char *argv[]) {
if (argc>=9) {
nframes=atoi(argv[8]);
}
int xmin=0, xmax=nx, ymin=0, ymax=ny;
if (argc>=13) {
xmin=atoi(argv[9]);
@ -185,6 +186,7 @@ int main(int argc, char *argv[]) {
cout << "pedestal file is " << pedfile << endl;
if (thr>0)
cout << "threshold is " << thr << endl;
cout << "Nframes is " << nframes << endl;
uint32 nnx, nny;
double *gmap;

View File

@ -74,6 +74,14 @@ int main(int argc, char *argv[]) {
// high_resolution_clock::time_point t1;
// high_resolution_clock::time_point t2 ;
time_t begin,end,finished;
int rms=0;
int nped=1000, nped0=100;
#ifdef PTC
nped=10000;
nped0=10000;
#endif
if (argc > 4) {
@ -111,7 +119,7 @@ int main(int argc, char *argv[]) {
}
//slsDetectorData *det=new moench03T1ZmqDataNew();
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew(5000,sizeof(int));
cout << endl << " det" <<endl;
int npx, npy;
det->getDetectorSize(npx, npy);
@ -129,8 +137,15 @@ int main(int argc, char *argv[]) {
int ncol_cm=CM_ROWS;
double xt_ghost=C_GHOST;
moench03CommonMode *cm=new moench03CommonMode(ncol_cm);
moench03GhostSummation *gs=new moench03GhostSummation(det, xt_ghost);
moench03CommonMode *cm=NULL;
moench03GhostSummation *gs=NULL;
#ifdef CORR
cm=new moench03CommonMode(ncol_cm);
gs=new moench03GhostSummation(det, xt_ghost);
#endif
double *gainmap=NULL;
float *gm;
double *gmap=NULL;
@ -158,7 +173,7 @@ int main(int argc, char *argv[]) {
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
#ifndef INTERP
singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, nped, nped0, -1, -1, gainmap, gs);
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
@ -169,7 +184,7 @@ int main(int argc, char *argv[]) {
if (etafname) interp->readFlatField(etafname);
interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, nped, nped0, -1, -1, gainmap, gs);
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
#endif
@ -293,7 +308,8 @@ int main(int argc, char *argv[]) {
uint8_t detType = 0;
uint8_t version = 0;
// int* flippedData = 0;
char* additionalJsonHeader = 0;
string* additionalJsonHeader = 0;
//char* additionalJsonHeader = 0;
int32_t threshold=0;
@ -356,6 +372,11 @@ int main(int argc, char *argv[]) {
sprintf(ofname,"%s_%ld_ped.tiff",fname,fileindex);
mt->writePedestal(ofname);
cout << "Writing pedestal to " << ofname << endl;
if (rms) {
sprintf(ofname,"%s_%ld_var.tiff",fname,fileindex);
mt->writePedestalRMS(ofname);
cout << "Writing pedestal variance to " << ofname << endl;
}
}
#ifdef INTERP
else if (fMode==eFlat) {
@ -388,7 +409,7 @@ int main(int argc, char *argv[]) {
dout[ix]=ped[ix];
// if (ix<100*400)
// cout << ix << " " << ped[ix] << endl;
// cout << ix << " " << ped[ix] << " "<< dout[ix] << endl;
}
}
@ -426,9 +447,9 @@ int main(int argc, char *argv[]) {
// }
// }
dout[ix]=detimage[ix];
if (dout[ix]<0) dout[ix]=0;
// cout << ix << " " << dout[ix] << endl;
dout[ix]=detimage[ix];
if (dout[ix]<0) dout[ix]=0;
//cout << ix << " " << dout[ix] << endl;
// }
}
}
@ -448,44 +469,21 @@ int main(int argc, char *argv[]) {
// cout << "Sending image size " << nnx << " " << nny << endl;
#ifndef DEVELOPER
#ifndef MOENCH_BRANCH
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 0,0, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
#endif
#endif
#ifdef DEVELOPER
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
#endif
#ifdef MOENCH_BRANCH
/*
int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0,
uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0,
uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL,
uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0,
uint64_t bunchId = 0, uint64_t timestamp = 0,
uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0,
uint32_t debug = 0, uint16_t roundRNumber = 0,
uint8_t detType = 0, uint8_t version = 0, int* flippedData = 0,
char* additionalJsonHeader = 0) {
int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEADER_VERSION , uint32_t dr, uint64_t fileindex, uint32_t 0, uint32_t 0, uint32_t, uint64_t, uint64_t, char*, uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, int*, char*)
*/
//zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version);//, 0,additionalJsonHeader);
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
/* old
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
*/
/*
// #ifndef DEVELOPER
// #ifndef MOENCH_BRANCH
// zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 1,1, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
// #endif
// #endif
new
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,additionalJsonHeader);
*/
#endif
// #ifdef DEVELOPER
// #ifdef CTBGUI
// zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
// #endif
// #ifndef CTBGUI
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
//#endif
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
cprintf(GREEN, "Sent Data\n");
@ -577,6 +575,7 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
/* Analog detector commands */
//isPedestal=0;
//isFlat=0;
rms=0;
fMode=eFrame;
frameMode_s="frame";
cprintf(MAGENTA, "Frame mode: ");
@ -586,11 +585,17 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
if (frameMode_s == "pedestal"){
fMode=ePedestal;
//isPedestal=1;
} else if (frameMode_s == "newPedestal"){
} else if (frameMode_s == "newpedestal"){
mt->newDataSet(); //resets pedestal
// cprintf(MAGENTA, "Resetting pedestal\n");
fMode=ePedestal;
//isPedestal=1;
} else if (frameMode_s == "variance"){
mt->newDataSet(); //resets pedestal
// cprintf(MAGENTA, "Resetting pedestal\n");
fMode=ePedestal;
rms=1;
//isPedestal=1;
}
#ifdef INTERP
else if (frameMode_s == "flatfield") {
@ -611,11 +616,13 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
frameMode_s="frame";
}
}
}
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
} else
cprintf(RED, "%s\n" , frameMode_s.c_str());
mt->setFrameMode(fMode);
// threshold=0;
threshold=0;
cprintf(MAGENTA, "Threshold: ");
if (doc.HasMember("threshold")) {
if (doc["threshold"].IsInt()) {
@ -683,10 +690,11 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
}
}
}
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
} else
cprintf(RED, "%s\n" , frameMode_s.c_str());
mt->setDetectorMode(dMode);
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
// cout << "done " << endl;
@ -737,7 +745,7 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
// cout << "file" << endl;
// cout << "data " << endl;
if (of==NULL) {
if (of==NULL && dMode!=eAnalog && fMode!=ePedestal && threshold<=0) {
#ifdef WRITE_QUAD
sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex);
#endif
@ -772,15 +780,13 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
mt->pushData(buff);
mt->nextThread();
mt->popFree(buff);
cprintf(GREEN, "Frame\n");
} else {
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
//length =
zmqsocket->ReceiveData(0, dummybuff, size);
}
iframe++;
} // exiting infinite loop

View File

@ -17,7 +17,7 @@
#include <pthread.h>
#include "analogDetector.h"
#include "circularFifo.h"
#include "CircularFifo.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@ -461,6 +461,50 @@ public:
return ped;
};
virtual double *getPedestalRMS(){
int nx, ny;
dets[0]->getDetectorSize(nx,ny);
// if (ped) delete [] ped;
double *rms=new double[nx*ny];
double *p0=new double[nx*ny];
for (int i=0; i<nThreads; i++) {
//inte=(slsInterpolation*)dets[i]->getInterpolation(nb,emi,ema);
// cout << i << endl;
p0=dets[i]->getPedestalRMS(p0);
if (p0) {
if (i==0) {
for (int ib=0; ib<nx*ny; ib++) {
rms[ib]=p0[ib]*p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
} else {
for (int ib=0; ib<nx*ny; ib++) {
rms[ib]+=p0[ib]*p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
}
}
}
delete [] p0;
/* for (int ib=0; ib<nx*ny; ib++) { */
/* if (rms[ib]>0) */
/* rms[ib]=sqrt(ped[ib]); */
/* else */
/* rms[ib]=0; */
/* } */
return rms;
};
virtual double *setPedestal(double *h=NULL){
//int nb=0;
@ -498,6 +542,27 @@ public:
};
virtual void *writePedestalRMS(const char * imgname){
int nx, ny;
dets[0]->getDetectorSize(nx,ny);
double *rms=getPedestalRMS();
float *gm=new float[nx*ny];
if (gm) {
for (int ix=0; ix<nx*ny; ix++) {
gm[ix]=rms[ix];
}
WriteToTiff(gm,imgname ,nx, ny);
delete [] gm;
delete [] rms;
} else cout << "Could not allocate float image " << endl;
return NULL;
};
virtual void *readPedestal(const char * imgname, int nb=-1, double emin=1, double emax=0){
int nx, ny;

View File

@ -1,10 +1,13 @@
set(CMAKE_AUTOMOC ON)
find_package(PNG REQUIRED)
find_package(ZLIB REQUIRED)
set(SOURCES
slsDetectorPlotting/src/SlsQt1DPlot.cxx
slsDetectorPlotting/src/SlsQt1DZoomer.cxx
slsDetectorPlotting/src/SlsQt2DHist.cxx
slsDetectorPlotting/src/SlsQt2DPlot.cxx
slsDetectorPlotting/src/SlsQt1DPlot.cpp
slsDetectorPlotting/src/SlsQt1DZoomer.cpp
slsDetectorPlotting/src/SlsQt2DHist.cpp
slsDetectorPlotting/src/SlsQt2DPlot.cpp
src/qDetectorMain.cpp
src/qDrawPlot.cpp
src/qCloneWidget.cpp
@ -89,8 +92,8 @@ target_link_libraries(slsDetectorGui PUBLIC
${QT_QTCORE_LIBRARIES}
${QT_QTGUI_LIBRARIES}
${QWT_LIBRARIES}
png
z
PNG::PNG
ZLIB::ZLIB
Qt4::QtOpenGL
Qt4::QtSvg
)

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>350</height>
<width>376</width>
<height>425</height>
</rect>
</property>
<property name="minimumSize">
@ -240,7 +240,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<width>376</width>
<height>28</height>
</rect>
</property>

View File

@ -145,6 +145,10 @@
<property name="windowTitle">
<string>SLS Detector GUI</string>
</property>
<property name="windowIcon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/mountain.png</normaloff>:/icons/images/mountain.png</iconset>
</property>
<property name="inputMethodHints">
<set>Qt::ImhNone</set>
</property>
@ -371,101 +375,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</widget>
<action name="actionOpenSetup">
<property name="text">
<string>&amp;Load &amp;Setup</string>
</property>
<property name="font">
<font/>
</property>
</action>
<action name="actionSaveSetup">
<property name="text">
<string>&amp;Save &amp;Setup</string>
</property>
<property name="font">
<font/>
</property>
</action>
<action name="actionMeasurementWizard">
<property name="text">
<string>&amp;Measurement Wizard</string>
</property>
</action>
<action name="actionOpenConfiguration">
<property name="text">
<string>&amp;Load &amp;Configuration</string>
</property>
</action>
<action name="actionSaveConfiguration">
<property name="text">
<string>&amp;Save &amp;Configuration</string>
</property>
</action>
<action name="actionEnergyCalibration">
<property name="text">
<string>&amp;Energy Calibration</string>
</property>
</action>
<action name="actionAngularCalibration">
<property name="text">
<string>&amp;Angular Calibration</string>
</property>
</action>
<action name="actionDebug">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Debug</string>
</property>
</action>
<action name="actionBeamline">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Beamline</string>
</property>
</action>
<action name="actionExpert">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Expert</string>
</property>
</action>
<action name="actionConfiguration">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Configuration</string>
</property>
</action>
<action name="actionVersion">
<property name="text">
<string>&amp;Version</string>
</property>
</action>
<action name="actionAbout">
<property name="text">
<string>&amp;About</string>
</property>
</action>
<action name="actionLoadConfiguration">
<property name="text">
<string>Load Configuration</string>
@ -476,6 +385,11 @@ p, li { white-space: pre-wrap; }
<string>Load Trimbits</string>
</property>
</action>
<action name="actionLoadParameters">
<property name="text">
<string>Load Parameters</string>
</property>
</action>
<action name="actionDebug">
<property name="checkable">
<bool>true</bool>
@ -500,12 +414,14 @@ p, li { white-space: pre-wrap; }
<string>Dockable Windows</string>
</property>
</action>
<action name="actionLoadParameters">
<action name="actionAbout">
<property name="text">
<string>Load Parameters</string>
<string>&amp;About</string>
</property>
</action>
</widget>
<resources/>
<resources>
<include location="../include/icons.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -432,19 +432,6 @@
<property name="verticalSpacing">
<number>4</number>
</property>
<item row="5" column="0">
<widget class="QLabel" name="lblNumTriggers">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Triggers:</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QComboBox" name="comboPeriodUnit">
<property name="enabled">
@ -666,108 +653,6 @@ Frame period between exposures.
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="lblDelay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="text">
<string>Delay After Trigger:</string>
</property>
</widget>
</item>
<item row="5" column="2" colspan="2">
<widget class="QSpinBox" name="spinNumTriggers">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>Number of Triggers to be expected.
#triggers#</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>2000000000</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QDoubleSpinBox" name="spinDelay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QDoubleSpinBox" name="spinExpTime">
<property name="enabled">
@ -903,65 +788,6 @@ Exposure Time of a frame.
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QComboBox" name="comboDelayUnit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>hr</string>
</property>
</item>
<item>
<property name="text">
<string>min</string>
</property>
</item>
<item>
<property name="text">
<string>s</string>
</property>
</item>
<item>
<property name="text">
<string>ms</string>
</property>
</item>
<item>
<property name="text">
<string>us</string>
</property>
</item>
<item>
<property name="text">
<string>ns</string>
</property>
</item>
</widget>
</item>
<item row="3" column="3">
<widget class="QComboBox" name="comboExpUnit">
<property name="enabled">
@ -1084,6 +910,577 @@ Frame period between exposures.
</property>
</spacer>
</item>
<item row="5" column="0">
<widget class="QStackedWidget" name="stackedLblTriggerBurst">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageLblTrigger">
<layout class="QGridLayout" name="gridLblTrigger">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblNumTriggers">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Triggers:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageLblBurst">
<layout class="QGridLayout" name="gridLblBurst">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblNumBursts">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Bursts:</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="5" column="2">
<widget class="QStackedWidget" name="stackedSpinTriggerBurst">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>208</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>208</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageSpinTrigger">
<layout class="QGridLayout" name="gridSpinTrigger">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QSpinBox" name="spinNumTriggers">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>Number of Triggers to be expected.
#triggers#</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>2000000000</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageSpinBurst">
<layout class="QGridLayout" name="gridSpinBurst">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QSpinBox" name="spinNumBursts">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>Number of Triggers to be expected.
#triggers#</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>2000000000</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="6" column="0">
<widget class="QStackedWidget" name="stackedLblDelayBurstPeriod">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageLblDelay">
<layout class="QGridLayout" name="gridLblDelay">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblDelay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Delay After Trigger:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageLblBurstPeriod">
<layout class="QGridLayout" name="gridLblBurstPeriod">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QLabel" name="lblBurstPeriod">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Burst Period:</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="6" column="2">
<widget class="QStackedWidget" name="stackedSpinDelayBurstPeriod">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>152</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>152</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageSpinDelay">
<layout class="QGridLayout" name="gridSpinDelay">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="spinDelay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageSpinBurstPeriod">
<layout class="QGridLayout" name="gridSpinBurstPeriod">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="spinBurstPeriod">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="6" column="3">
<widget class="QStackedWidget" name="stackedComboDelayBurstPeriod">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageComboDelay">
<layout class="QGridLayout" name="gridComboDelay">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QComboBox" name="comboDelayUnit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>hr</string>
</property>
</item>
<item>
<property name="text">
<string>min</string>
</property>
</item>
<item>
<property name="text">
<string>s</string>
</property>
</item>
<item>
<property name="text">
<string>ms</string>
</property>
</item>
<item>
<property name="text">
<string>us</string>
</property>
</item>
<item>
<property name="text">
<string>ns</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageComboBurstPeriod">
<layout class="QGridLayout" name="gridComboBurstPeriod">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QComboBox" name="comboBurstPeriodUnit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>hr</string>
</property>
</item>
<item>
<property name="text">
<string>min</string>
</property>
</item>
<item>
<property name="text">
<string>s</string>
</property>
</item>
<item>
<property name="text">
<string>ms</string>
</property>
</item>
<item>
<property name="text">
<string>us</string>
</property>
</item>
<item>
<property name="text">
<string>ns</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
@ -1116,9 +1513,6 @@ Frame period between exposures.
<tabstop>comboExpUnit</tabstop>
<tabstop>spinPeriod</tabstop>
<tabstop>comboPeriodUnit</tabstop>
<tabstop>spinNumTriggers</tabstop>
<tabstop>spinDelay</tabstop>
<tabstop>comboDelayUnit</tabstop>
<tabstop>spinNumSamples</tabstop>
</tabstops>
<resources>

View File

@ -822,7 +822,7 @@ Displays minimum, maximum and sum of values for each plot.
<item row="0" column="1">
<widget class="QStackedWidget" name="stackedWidget1D">
<property name="currentIndex">
<number>3</number>
<number>5</number>
</property>
<widget class="QWidget" name="pageSuperImpose">
<layout class="QHBoxLayout" name="horizontalLayout_2">
@ -1360,6 +1360,27 @@ Displays minimum, maximum and sum of values for each plot.
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="chkGainPlot1D">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Displays minimum, maximum and sum of values for each plot.
&lt;nobr&gt;</string>
</property>
<property name="text">
<string>Gain Plot</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
@ -2347,7 +2368,6 @@ Displays minimum, maximum and sum of values for each plot.
<zorder>box1D</zorder>
<zorder>boxFrequency</zorder>
<zorder>box2D</zorder>
<zorder>horizontalSpacer_6</zorder>
<zorder>boxPlotAxis</zorder>
<zorder>boxSave</zorder>
</widget>

View File

@ -214,6 +214,46 @@
<string>Very Low Gain</string>
</property>
</item>
<item>
<property name="text">
<string>G1_HG</string>
</property>
</item>
<item>
<property name="text">
<string>G1_LG</string>
</property>
</item>
<item>
<property name="text">
<string>G2_HC_HG</string>
</property>
</item>
<item>
<property name="text">
<string>G2_HC_LG</string>
</property>
</item>
<item>
<property name="text">
<string>G2_LC_HG</string>
</property>
</item>
<item>
<property name="text">
<string>G2_LC_LG</string>
</property>
</item>
<item>
<property name="text">
<string>G4_HG</string>
</property>
</item>
<item>
<property name="text">
<string>G4_LG</string>
</property>
</item>
<item>
<property name="text">
<string>Undefined</string>

20
slsDetectorGui/include/qCloneWidget.h Executable file → Normal file
View File

@ -1,25 +1,20 @@
#pragma once
#include "ui_form_cloneplot.h"
#include <QMainWindow>
#include <QString>
class SlsQtH1D;
class SlsQt1DPlot;
class SlsQt2DPlot;
#include <QMainWindow>
#include <QString>
#include <iostream>
#include <string>
class qCloneWidget : public QMainWindow, private Ui::ClonePlotObject {
Q_OBJECT
public:
qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2, SlsQt2DPlot *gp,
QString title, QString filePath, QString fileName,
int64_t aIndex, bool displayStats, QString min, QString max,
QString sum);
qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2,
SlsQt1DPlot *gp1, SlsQt2DPlot *gp, QString title,
QString filePath, QString fileName, int64_t aIndex,
bool displayStats, QString min, QString max, QString sum);
~qCloneWidget();
@ -28,7 +23,7 @@ class qCloneWidget : public QMainWindow, private Ui::ClonePlotObject {
protected:
void resizeEvent(QResizeEvent *event);
private:
void SetupWidgetWindow(QString title);
void DisplayStats(bool enable, QString min, QString max, QString sum);
@ -37,6 +32,7 @@ class qCloneWidget : public QMainWindow, private Ui::ClonePlotObject {
int id;
SlsQt1DPlot *plot1d{nullptr};
SlsQt2DPlot *plot2d{nullptr};
SlsQt1DPlot *gainplot1d{nullptr};
SlsQt2DPlot *gainplot2d{nullptr};
QString filePath{"/"};
QString fileName{"run"};

41
slsDetectorGui/include/qDacWidget.h Executable file → Normal file
View File

@ -1,33 +1,30 @@
#pragma once
#include "ui_form_dac.h"
#include "Detector.h"
#include "sls_detector_defs.h"
#include <string>
class qDacWidget:public QWidget, private Ui::WidgetDacObject {
Q_OBJECT
class qDacWidget : public QWidget, private Ui::WidgetDacObject {
Q_OBJECT
public:
qDacWidget(QWidget *parent, sls::Detector* detector, bool d, std::string n, slsDetectorDefs::dacIndex i);
~qDacWidget();
void SetDetectorIndex(int id);
public:
qDacWidget(QWidget *parent, sls::Detector *detector, bool d, std::string n,
slsDetectorDefs::dacIndex i);
~qDacWidget();
void SetDetectorIndex(int id);
private slots:
void SetDac();
private slots:
void SetDac();
private:
void SetupWidgetWindow(std::string name);
void Initialization();
void GetDac();
void GetAdc();
void Refresh();
private:
void SetupWidgetWindow(std::string name);
void Initialization();
void GetDac();
void GetAdc();
void Refresh();
sls::Detector *det;
bool isDac{true};
slsDetectorDefs::dacIndex index;
int detectorIndex{-1};
sls::Detector *det;
bool isDac{true};
slsDetectorDefs::dacIndex index;
int detectorIndex{-1};
};

85
slsDetectorGui/include/qDefs.h Executable file → Normal file
View File

@ -5,22 +5,29 @@
#include <QAbstractButton>
#include <QMessageBox>
#include <chrono>
#include <iostream>
#include <ostream>
#include <stdint.h>
#include <cstdint>
#include <string>
#include <chrono>
using std::chrono::duration;
using std::chrono::duration_cast;
using std::chrono::nanoseconds;
using std::chrono::hours;
using std::chrono::microseconds;
using std::chrono::milliseconds;
using std::chrono::seconds;
using std::chrono::minutes;
using std::chrono::hours;
using std::chrono::nanoseconds;
using std::chrono::seconds;
#define CATCH_DISPLAY(m, s) catch(...) { qDefs::DisplayExceptions(m, s); }
#define CATCH_HANDLE(...) catch(...) { qDefs::HandleExceptions(__VA_ARGS__); }
#define CATCH_DISPLAY(m, s) \
catch (...) { \
qDefs::DisplayExceptions(m, s); \
}
#define CATCH_HANDLE(...) \
catch (...) { \
qDefs::HandleExceptions(__VA_ARGS__); \
}
class qDefs : public QWidget {
public:
@ -29,8 +36,9 @@ class qDefs : public QWidget {
*/
qDefs(){};
static const int Q_FONT_SIZE=9;
static const int DATA_GAIN_PLOT_RATIO=5;
static const int Q_FONT_SIZE = 9;
static const int DATA_GAIN_PLOT_RATIO = 5;
static const int MIN_HEIGHT_GAIN_PLOT_1D = 75;
static void DisplayExceptions(std::string emsg, std::string src) {
try {
@ -46,8 +54,8 @@ class qDefs : public QWidget {
template <class CT> struct NonDeduced { using type = CT; };
template <class S, typename RT, typename... CT>
static void HandleExceptions(const std::string emsg, const std::string src, S* s,
RT (S::*somefunc)(CT...),
static void HandleExceptions(const std::string emsg, const std::string src,
S *s, RT (S::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) {
try {
throw;
@ -71,15 +79,22 @@ class qDefs : public QWidget {
QF_NUM_FUNCTIONS
};
static const char* getQFunctionNameFromEnum(enum qFuncNames func) {
static const char *getQFunctionNameFromEnum(enum qFuncNames func) {
switch (func) {
case QF_GET_DETECTOR_STATUS: return "QF_GET_DETECTOR_STATUS";
case QF_START_ACQUISITION: return "QF_START_ACQUISITION";
case QF_STOP_ACQUISITION: return "QF_STOP_ACQUISITION";
case QF_START_AND_READ_ALL: return "QF_START_AND_READ_ALL";
case QF_EXIT_SERVER: return "QF_EXIT_SERVER";
case QF_NUM_FUNCTIONS: return "QF_NUM_FUNCTIONS";
default: return "Unknown Function";
case QF_GET_DETECTOR_STATUS:
return "QF_GET_DETECTOR_STATUS";
case QF_START_ACQUISITION:
return "QF_START_ACQUISITION";
case QF_STOP_ACQUISITION:
return "QF_STOP_ACQUISITION";
case QF_START_AND_READ_ALL:
return "QF_START_AND_READ_ALL";
case QF_EXIT_SERVER:
return "QF_EXIT_SERVER";
case QF_NUM_FUNCTIONS:
return "QF_NUM_FUNCTIONS";
default:
return "Unknown Function";
}
};
@ -110,11 +125,16 @@ class qDefs : public QWidget {
static std::string getRangeAsString(enum range r) {
switch (r) {
case XMIN: return "XMIN";
case XMAX: return "XMAX";
case YMIN: return "YMIN";
case YMAX: return "YMAX";
default: return "Unknown";
case XMIN:
return "XMIN";
case XMAX:
return "XMAX";
case YMIN:
return "YMIN";
case YMAX:
return "YMAX";
default:
return "Unknown";
}
};
@ -189,7 +209,8 @@ class qDefs : public QWidget {
MINUTES);
}
return std::make_pair(
duration_cast<duration<double, std::ratio<3600>>>(tns).count(), HOURS);
duration_cast<duration<double, std::ratio<3600>>>(tns).count(),
HOURS);
}
/** returns the value in ns */
@ -295,10 +316,12 @@ class qDefs : public QWidget {
/**
* Wrap exception message
*/
static int ExceptionMessage(std::string message,
std::string exceptionMessage,
std::string source) {
return Message(qDefs::WARNING, message + std::string("\nCaught exception:\n") + exceptionMessage, source);
}
static int ExceptionMessage(std::string message,
std::string exceptionMessage,
std::string source) {
return Message(qDefs::WARNING,
message + std::string("\nCaught exception:\n") +
exceptionMessage,
source);
}
};

43
slsDetectorGui/include/qDetectorMain.h Executable file → Normal file
View File

@ -1,8 +1,9 @@
#pragma once
#include "ui_form_detectormain.h"
#include "qDefs.h"
#include "Detector.h"
#include <QTabWidget>
class qDrawPlot;
class qTabMeasurement;
class qTabDataOutput;
@ -12,17 +13,15 @@ class qTabSettings;
class qTabDebugging;
class qTabDeveloper;
class qTabMessages;
#include "Detector.h"
#include <QTabWidget>
class QScrollArea;
class QResizeEvent;
/** To Over-ride the QTabWidget class to get the tabBar */
/** To Over-ride the QTabWidget class to get the tabBar protected
* methodTabWidget */
class MyTabWidget : public QTabWidget {
public:
MyTabWidget(QWidget *parent = 0) { setParent(parent); }
/** Overridden method from QTabWidget */
/** Overridden protected method from QTabWidget */
QTabBar *tabBar() { return QTabWidget::tabBar(); }
};
@ -30,8 +29,7 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
Q_OBJECT
public:
qDetectorMain(int argc, char **argv, QApplication *app,
QWidget *parent = 0);
qDetectorMain(int multiId, const std::string& fname, bool isDevel);
~qDetectorMain();
private slots:
@ -53,9 +51,9 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
private:
void SetUpWidgetWindow();
void SetUpDetector(const std::string fName, int multiID);
void SetUpDetector(const std::string& config_file, int multiID);
void Initialization();
void LoadConfigFile(const std::string fName);
void LoadConfigFile(const std::string& config_file);
/** enumeration of the tabs */
enum {
@ -71,16 +69,17 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
};
slsDetectorDefs::detectorType detType;
std::unique_ptr<sls::Detector> det;
std::unique_ptr<qDrawPlot> plot;
std::unique_ptr<MyTabWidget> tabs;
std::unique_ptr<qTabMeasurement> tabMeasurement;
std::unique_ptr<qTabDataOutput> tabDataOutput;
std::unique_ptr<qTabPlot> tabPlot;
std::unique_ptr<qTabSettings> tabSettings;
std::unique_ptr<qTabAdvanced> tabAdvanced;
std::unique_ptr<qTabDebugging> tabDebugging;
std::unique_ptr<qTabDeveloper> tabDeveloper;
std::unique_ptr<qTabMessages> tabMessages;
qDrawPlot *plot;
MyTabWidget* tabs;
std::unique_ptr<QScrollArea> scroll[NumberOfTabs];
qTabMeasurement *tabMeasurement;
qTabDataOutput *tabDataOutput;
qTabPlot *tabPlot;
qTabSettings *tabSettings;
qTabAdvanced *tabAdvanced;
qTabDebugging *tabDebugging;
qTabDeveloper *tabDeveloper;
qTabMessages *tabMessages;
int isDeveloper;
int heightPlotWindow;
int heightCentralWidget;

70
slsDetectorGui/include/qDrawPlot.h Executable file → Normal file
View File

@ -1,26 +1,21 @@
#pragma once
#include "ui_form_plot.h"
#include "qDefs.h"
#include "Detector.h"
#include <mutex>
class SlsQt1DPlot;
class SlsQtH1D;
class SlsQt2DPlot;
class qCloneWidget;
class detectorData;
#include "Detector.h"
class QResizeEvent;
#include <QFutureWatcher>
#include <mutex>
class qDrawPlot : public QWidget, private Ui::PlotObject {
Q_OBJECT
public:
qDrawPlot(QWidget *parent, sls::Detector *detector);
qDrawPlot(QWidget *parent, sls::Detector *detector);
~qDrawPlot();
bool GetIsRunning();
void SetRunning(bool enable);
@ -31,8 +26,8 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void SetXAxisTitle(QString title);
void SetYAxisTitle(QString title);
void SetZAxisTitle(QString title);
void SetXYRangeChanged(bool disable, double* xy, bool* isXY);
void SetZRange(double* z, bool* isZ);
void SetXYRangeChanged(bool disable, double *xy, bool *isXY);
void SetZRange(double *z, bool *isZ);
double GetXMinimum();
double GetXMaximum();
double GetYMinimum();
@ -57,18 +52,18 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void SetNumDiscardBits(int value);
void EnableGainPlot(bool enable);
void ClonePlot();
void SavePlot();
void SavePlot();
protected:
void resizeEvent(QResizeEvent *event);
private slots:
void SetSaveFileName(QString val);
void AcquireFinished();
void AcquireThread();
void UpdatePlot();
signals:
void StartAcquireSignal();
void AcquireFinishedSignal();
void AbortSignal();
void UpdateSignal();
@ -76,40 +71,45 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
private:
void SetupWidgetWindow();
void Initialization();
void SetupPlots();
void SetupPlots();
void GetStatistics(double &min, double &max, double &sum);
void DetachHists();
static void GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer);
static void GetDataCallBack(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex, void *this_pointer);
std::string AcquireThread();
static void GetAcquisitionFinishedCallBack(double currentProgress,
int detectorStatus,
void *this_pointer);
static void GetDataCallBack(detectorData *data, uint64_t frameIndex,
uint32_t subFrameIndex, void *this_pointer);
void AcquisitionFinished(double currentProgress, int detectorStatus);
void GetData(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex);
void toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest = NULL);
void Get1dData(double* rawData);
void Get2dData(double* rawData);
void GetData(detectorData *data, uint64_t frameIndex,
uint32_t subFrameIndex);
void toDoublePixelData(double *dest, char *source, int size, int databytes,
int dr, double *gaindest = NULL);
void Get1dData(double *rawData);
void Get2dData(double *rawData);
void Update1dPlot();
void Update2dPlot();
void Update1dXYRange();
void Update2dXYRange();
static const int NUM_PEDESTAL_FRAMES = 20;
static const int NUM_PEDESTAL_FRAMES = 20;
sls::Detector *det;
slsDetectorDefs::detectorType detType;
SlsQt1DPlot *plot1d{nullptr};
QVector<SlsQtH1D *> hists1d;
QVector<SlsQtH1D *> hists1d;
SlsQt1DPlot *gainplot1d{nullptr};
SlsQtH1D *gainhist1d{nullptr};
SlsQt2DPlot *plot2d{nullptr};
SlsQt2DPlot *gainplot2d{nullptr};
QFutureWatcher<std::string> *acqResultWatcher;
bool is1d{true};
bool isRunning{false};
// titles
// titles
QString plotTitlePrefix{""};
QString xTitle1d{"Channel Number"};
QString yTitle1d{"Counts"};
QString xTitle2d{"Pixel"};
QString xTitle2d{"Pixel"};
QString yTitle2d{"Pixel"};
QString zTitle2d{"Intensity"};
QString plotTitle{""};
@ -120,16 +120,17 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
double zRange[2]{0, 1};
bool isZRange[2]{false, false};
// data
// data
int nHists{1};
double *datax1d{nullptr};
std::vector<double *> datay1d;
double *gainDatay1d{nullptr};
double *data2d{nullptr};
double *gainData{nullptr};
//options
// options
bool isPlot{true};
bool isBinary{false};
bool isBinary{false};
int binaryFrom{0};
int binaryTo{0};
int persistency{0};
@ -158,6 +159,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
unsigned int nPixelsX{0};
unsigned int nPixelsY{0};
const static int npixelsx_jctb = 400;
int npixelsy_jctb{0};
uint32_t pixelMask{0};
uint32_t gainMask{0};
int gainOffset{0};
};

110
slsDetectorGui/include/qTabAdvanced.h Executable file → Normal file
View File

@ -1,69 +1,65 @@
#pragma once
#include "ui_form_tab_advanced.h"
#include "Detector.h"
class qDrawPlot;
#include "Detector.h"
class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject {
Q_OBJECT
class qTabAdvanced:public QWidget, private Ui::TabAdvancedObject{
Q_OBJECT
public:
qTabAdvanced(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
~qTabAdvanced();
public:
qTabAdvanced(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
~qTabAdvanced();
public slots:
void Refresh();
public slots:
void Refresh();
private slots:
void SetDetector();
void SetControlPort(int port);
void SetStopPort(int port);
void SetDetectorUDPIP();
void SetDetectorUDPMAC();
void SetCltZMQPort(int port);
void SetCltZMQIP();
void SetRxrHostname();
void SetRxrTCPPort(int port);
void SetRxrUDPPort(int port);
void SetRxrUDPIP();
void SetRxrUDPMAC();
void SetRxrZMQPort(int port);
void SetRxrZMQIP();
void GetROI();
void ClearROI();
void SetROI();
void SetAllTrimbits();
void SetNumStoragecells(int value);
void SetSubExposureTime();
void SetSubDeadTime();
private slots:
void SetDetector();
void SetControlPort(int port);
void SetStopPort(int port);
void SetDetectorUDPIP();
void SetDetectorUDPMAC();
void SetCltZMQPort(int port);
void SetCltZMQIP();
void SetRxrHostname();
void SetRxrTCPPort(int port);
void SetRxrUDPPort(int port);
void SetRxrUDPIP();
void SetRxrUDPMAC();
void SetRxrZMQPort(int port);
void SetRxrZMQIP();
void GetROI();
void ClearROI();
void SetROI();
void SetAllTrimbits();
void SetNumStoragecells(int value);
void SetSubExposureTime();
void SetSubDeadTime();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
void GetControlPort();
void GetStopPort();
void GetDetectorUDPIP();
void GetDetectorUDPMAC();
void GetCltZMQPort();
void GetCltZMQIP();
void GetRxrHostname();
void GetRxrTCPPort();
void GetRxrUDPPort();
void GetRxrUDPIP();
void GetRxrUDPMAC();
void GetRxrZMQPort();
void GetRxrZMQIP();
void GetAllTrimbits();
void GetNumStoragecells();
void GetSubExposureTime();
void GetSubDeadTime();
void GetControlPort();
void GetStopPort();
void GetDetectorUDPIP();
void GetDetectorUDPMAC();
void GetCltZMQPort();
void GetCltZMQIP();
void GetRxrHostname();
void GetRxrTCPPort();
void GetRxrUDPPort();
void GetRxrUDPIP();
void GetRxrUDPMAC();
void GetRxrZMQPort();
void GetRxrZMQIP();
void GetAllTrimbits();
void GetNumStoragecells();
void GetSubExposureTime();
void GetSubDeadTime();
sls::Detector *det;
qDrawPlot *plot;
sls::Detector *det;
qDrawPlot *plot;
};

76
slsDetectorGui/include/qTabDataOutput.h Executable file → Normal file
View File

@ -1,50 +1,44 @@
#pragma once
#include "ui_form_tab_dataoutput.h"
#include "Detector.h"
class qTabDataOutput:public QWidget, private Ui::TabDataOutputObject{
Q_OBJECT
class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
Q_OBJECT
public:
qTabDataOutput(QWidget *parent, sls::Detector* detector);
~qTabDataOutput();
void Refresh();
public:
qTabDataOutput(QWidget *parent, sls::Detector *detector);
~qTabDataOutput();
void Refresh();
private slots:
void GetOutputDir();
void BrowseOutputDir();
void SetOutputDir();
void SetFileFormat(int format);
void SetOverwriteEnable(bool enable);
void SetTenGigaEnable(bool enable);
void EnableRateCorrection();
void SetRateCorrection();
void SetSpeed(int speed);
void SetFlags();
private slots:
void GetOutputDir();
void BrowseOutputDir();
void SetOutputDir();
void SetFileFormat(int format);
void SetOverwriteEnable(bool enable);
void SetTenGigaEnable(bool enable);
void EnableRateCorrection();
void SetRateCorrection();
void SetSpeed(int speed);
void SetFlags();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
void EnableBrowse();
void GetFileWrite();
void GetFileName();
void GetFileFormat();
void GetFileOverwrite();
void GetTenGigaEnable();
void GetRateCorrection();
void GetSpeed();
void GetFlags();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
void EnableBrowse();
void GetFileWrite();
void GetFileName();
void GetFileFormat();
void GetFileOverwrite();
void GetTenGigaEnable();
void GetRateCorrection();
void GetSpeed();
void GetFlags();
sls::Detector *det;
// Button group for radiobuttons for rate
QButtonGroup *btnGroupRate;
// enum for the Eiger Parallel flag
enum {
PARALLEL,
NONPARALLEL
};
sls::Detector *det;
// Button group for radiobuttons for rate
QButtonGroup *btnGroupRate;
// enum for the Eiger Parallel flag
enum { PARALLEL, NONPARALLEL };
};

45
slsDetectorGui/include/qTabDebugging.h Executable file → Normal file
View File

@ -1,36 +1,33 @@
#pragma once
#include "ui_form_tab_debugging.h"
#include "Detector.h"
class QTreeWidget;
class QTreeWidgetItem;
class qTabDebugging:public QWidget, private Ui::TabDebuggingObject{
Q_OBJECT
class qTabDebugging : public QWidget, private Ui::TabDebuggingObject {
Q_OBJECT
public:
qTabDebugging(QWidget *parent, sls::Detector* detector);
~qTabDebugging();
void Refresh();
public:
qTabDebugging(QWidget *parent, sls::Detector *detector);
~qTabDebugging();
void Refresh();
private slots:
void GetDetectorStatus();
void GetInfo();
void SetParameters(QTreeWidgetItem *item);
void TestDetector();
private slots:
void GetDetectorStatus();
void GetInfo();
void SetParameters(QTreeWidgetItem *item);
void TestDetector();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
sls::Detector *det;
/** Tree Widget displaying the detectors, modules */
QTreeWidget *treeDet;
QLabel *lblDetectorHostname;
QLabel *lblDetectorFirmware;
QLabel *lblDetectorSoftware;
sls::Detector *det;
/** Tree Widget displaying the detectors, modules */
QTreeWidget *treeDet;
QLabel *lblDetectorHostname;
QLabel *lblDetectorFirmware;
QLabel *lblDetectorSoftware;
};

63
slsDetectorGui/include/qTabDeveloper.h Executable file → Normal file
View File

@ -1,49 +1,38 @@
#pragma once
#include "ui_form_tab_developer.h"
class qDacWidget;
#include "Detector.h"
#include "sls_detector_defs.h"
#include <string>
#include <vector>
class qTabDeveloper:public QWidget, private Ui::TabDeveloperObject {
Q_OBJECT
class qDacWidget;
public:
qTabDeveloper(QWidget *parent, sls::Detector* detector);
~qTabDeveloper();
class qTabDeveloper : public QWidget, private Ui::TabDeveloperObject {
Q_OBJECT
public slots:
void Refresh();
public:
qTabDeveloper(QWidget *parent, sls::Detector *detector);
~qTabDeveloper();
private slots:
void SetHighVoltage();
public slots:
void Refresh();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
void GetHighVoltage();
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType, int index);
private slots:
void SetHighVoltage();
sls::Detector *det;
std::vector<qDacWidget*> dacWidgets;
std::vector<qDacWidget*> adcWidgets;
enum hvVals {
HV_0,
HV_90,
HV_110,
HV_120,
HV_150,
HV_180,
HV_200
};
int hvmin;
static const int HV_MIN = 60;
static const int HV_MAX = 200;
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
void GetHighVoltage();
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType,
int index);
sls::Detector *det;
std::vector<qDacWidget *> dacWidgets;
std::vector<qDacWidget *> adcWidgets;
enum hvVals { HV_0, HV_90, HV_110, HV_120, HV_150, HV_180, HV_200 };
int hvmin;
static const int HV_MIN = 60;
static const int HV_MAX = 200;
};

149
slsDetectorGui/include/qTabMeasurement.h Executable file → Normal file
View File

@ -1,90 +1,91 @@
#pragma once
#include "ui_form_tab_measurement.h"
class qDrawPlot;
#include "Detector.h"
class qDrawPlot;
class QStandardItemModel;
class qTabMeasurement:public QWidget, private Ui::TabMeasurementObject{
Q_OBJECT
class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
Q_OBJECT
public:
qTabMeasurement(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
~qTabMeasurement();
public:
qTabMeasurement(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
~qTabMeasurement();
void Refresh();
void Refresh();
public slots:
void AcquireFinished();
void AbortAcquire();
public slots:
void AcquireFinished();
void AbortAcquire();
private slots:
void SetTimingMode(int val);
void SetNumMeasurements(int val);
void SetNumFrames(int val);
void SetNumTriggers(int val);
void SetNumSamples(int val);
void SetExposureTime();
void SetAcquisitionPeriod();
void SetDelay();
void SetFileWrite(bool val);
void SetFileName();
void SetRunIndex(int val);
void SetStartingFrameNumber(int val);
void UpdateProgress();
void StartAcquisition();
void StopAcquisition();
private slots:
void SetTimingMode(int val);
void SetNumMeasurements(int val);
void SetNumFrames(int val);
void SetNumTriggers(int val);
void SetNumBursts(int val);
void SetNumSamples(int val);
void SetExposureTime();
void SetAcquisitionPeriod();
void SetDelay();
void SetBurstPeriod();
void SetFileWrite(bool val);
void SetFileName();
void SetRunIndex(int val);
void SetStartingFrameNumber(int val);
void UpdateProgress();
void StartAcquisition();
void StopAcquisition();
private:
void SetupWidgetWindow();
void Initialization();
void SetupTimingMode();
void EnableWidgetsforTimingMode();
private:
void SetupWidgetWindow();
void Initialization();
/** default, show trigger and delay,
* otherwise for gotthard2 in auto timing mode and burst mode,
* show bursts and burst period
*/
void ShowTriggerDelay();
void SetupTimingMode();
void EnableWidgetsforTimingMode();
void GetTimingMode();
void GetNumFrames();
void GetNumTriggers();
void GetNumSamples();
void GetExposureTime();
void GetAcquisitionPeriod();
void CheckAcqPeriodGreaterThanExp();
void GetDelay();
void GetFileWrite();
void GetFileName();
void GetRunIndex();
void GetStartingFrameNumber();
void GetTimingMode();
void GetNumFrames();
void GetNumTriggers();
void GetNumBursts();
void GetNumSamples();
void GetExposureTime();
void GetAcquisitionPeriod();
void CheckAcqPeriodGreaterThanExp();
void GetDelay();
void GetBurstPeriod();
void GetFileWrite();
void GetFileName();
void GetRunIndex();
void GetStartingFrameNumber();
void ResetProgress();
void ResetProgress();
void Enable(bool enable);
int VerifyOutputDirectoryError();
void Enable(bool enable);
int VerifyOutputDirectoryError();
signals:
void EnableTabsSignal(bool);
void FileNameChangedSignal(QString);
private:
sls::Detector *det;
qDrawPlot *plot;
// enum for the timing mode
enum{
AUTO,
TRIGGER,
GATED,
BURST_TRIGGER,
NUMTIMINGMODES
};
QTimer *progressTimer;
//tool tip variables
QString acqPeriodTip;
QString errPeriodTip;
QPalette red;
bool delayImplemented;
bool sampleImplemented;
bool startingFnumImplemented;
bool isAcquisitionStopped{false};
int numMeasurements{1};
int currentMeasurement{0};
signals:
void EnableTabsSignal(bool);
void FileNameChangedSignal(QString);
private:
sls::Detector *det;
qDrawPlot *plot;
// enum for the timing mode
enum { AUTO, TRIGGER, GATED, BURST_TRIGGER, NUMTIMINGMODES };
QTimer *progressTimer;
// tool tip variables
QString acqPeriodTip;
QString errPeriodTip;
QPalette red;
bool delayImplemented;
bool sampleImplemented;
bool startingFnumImplemented;
bool isAcquisitionStopped{false};
int numMeasurements{1};
int currentMeasurement{0};
};

46
slsDetectorGui/include/qTabMessages.h Executable file → Normal file
View File

@ -1,36 +1,34 @@
#pragma once
#include "ui_form_tab_messages.h"
class QProcess;
class QKeyEvent;
class qTabMessages:public QWidget, private Ui::TabMessagesObject {
Q_OBJECT
class qTabMessages : public QWidget, private Ui::TabMessagesObject {
Q_OBJECT
public:
qTabMessages(QWidget* parent);
~qTabMessages();
void Refresh();
public:
qTabMessages(QWidget *parent);
~qTabMessages();
void Refresh();
protected:
void keyPressEvent(QKeyEvent* event);
protected:
void keyPressEvent(QKeyEvent *event);
private slots:
void ExecuteCommand();
void SaveLog();
void ClearLog();
private slots:
void ExecuteCommand();
void SaveLog();
void ClearLog();
private:
void SetupWidgetWindow();
void Initialization();
void PrintNextLine();
void GetLastCommand();
void ClearCommand();
void AppendOutput();
void AppendError();
private:
void SetupWidgetWindow();
void Initialization();
void PrintNextLine();
void GetLastCommand();
void ClearCommand();
void AppendOutput();
void AppendError();
QProcess* process;
QStringList lastCommand;
QProcess *process;
QStringList lastCommand;
};

93
slsDetectorGui/include/qTabPlot.h Executable file → Normal file
View File

@ -1,63 +1,58 @@
#pragma once
#include "ui_form_tab_plot.h"
class qDrawPlot;
#include "Detector.h"
class qDrawPlot;
class QButtonGroup;
class qTabPlot:public QWidget, private Ui::TabPlotObject{
Q_OBJECT
class qTabPlot : public QWidget, private Ui::TabPlotObject {
Q_OBJECT
public:
qTabPlot(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
~qTabPlot();
void SetScanArgument();
void Refresh();
public:
qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
~qTabPlot();
void SetScanArgument();
void Refresh();
private slots:
void SetPlot();
void Set1DPlotOptionsRight();
void Set1DPlotOptionsLeft();
void Set2DPlotOptionsRight();
void Set2DPlotOptionsLeft();
void EnablePersistency(bool enable);
void SetBinary();
void SetGapPixels(bool enable);
void SetTitles();
void SetXRange();
void SetYRange();
void CheckAspectRatio();
void SetZRange();
void SetStreamingFrequency();
private slots:
void SetPlot();
void Set1DPlotOptionsRight();
void Set1DPlotOptionsLeft();
void Set2DPlotOptionsRight();
void Set2DPlotOptionsLeft();
void EnablePersistency(bool enable);
void SetBinary();
void SetGapPixels(bool enable);
void SetTitles();
void SetXRange();
void SetYRange();
void CheckAspectRatio();
void SetZRange();
void SetStreamingFrequency();
signals:
void DisableZoomSignal(bool);
signals:
void DisableZoomSignal(bool);
private:
void SetupWidgetWindow();
void Initialization();
void Select1DPlot(bool enable);
void GetGapPixels();
void GetStreamingFrequency();
void SetXYRange();
void MaintainAspectRatio(int dimension);
private:
void SetupWidgetWindow();
void Initialization();
void Select1DPlot(bool enable);
void GetGapPixels();
void GetStreamingFrequency();
void SetXYRange();
void MaintainAspectRatio(int dimension);
sls::Detector *det;
qDrawPlot *plot;
bool is1d;
sls::Detector *det;
qDrawPlot *plot;
bool is1d;
QButtonGroup *btnGroupPlotType{nullptr};
QButtonGroup *btnGroupPlotType{nullptr};
/** default plot and axis titles */
static QString defaultPlotTitle;
static QString defaultHistXAxisTitle;
static QString defaultHistYAxisTitle;
static QString defaultImageXAxisTitle;
static QString defaultImageYAxisTitle;
static QString defaultImageZAxisTitle;
/** default plot and axis titles */
static QString defaultPlotTitle;
static QString defaultHistXAxisTitle;
static QString defaultHistYAxisTitle;
static QString defaultImageXAxisTitle;
static QString defaultImageYAxisTitle;
static QString defaultImageZAxisTitle;
};

89
slsDetectorGui/include/qTabSettings.h Executable file → Normal file
View File

@ -1,54 +1,55 @@
#pragma once
#include "ui_form_tab_settings.h"
#include "Detector.h"
class qTabSettings: public QWidget, private Ui::TabSettingsObject{
Q_OBJECT
class qTabSettings : public QWidget, private Ui::TabSettingsObject {
Q_OBJECT
public:
qTabSettings(QWidget *parent, sls::Detector* detector);
~qTabSettings();
void Refresh();
public:
qTabSettings(QWidget *parent, sls::Detector *detector);
~qTabSettings();
void Refresh();
private slots:
void SetSettings(int index);
void SetDynamicRange(int index);
void SetThresholdEnergy(int index);
private slots:
void SetSettings(int index);
void SetDynamicRange(int index);
void SetThresholdEnergy(int index);
private:
void SetupWidgetWindow();
void SetupDetectorSettings();
void Initialization();
private:
void SetupWidgetWindow();
void SetupDetectorSettings();
void Initialization();
void GetSettings();
void GetDynamicRange();
void GetThresholdEnergy();
void GetSettings();
void GetDynamicRange();
void GetThresholdEnergy();
sls::Detector *det;
enum {
STANDARD,
FAST,
HIGHGAIN,
DYNAMICGAIN,
LOWGAIN,
MEDIUMGAIN,
VERYHIGHGAIN,
DYNAMICHG0,
FIXGAIN1,
FIXGAIN2,
FORCESWITCHG1,
FORCESWITCHG2,
VERLOWGAIN,
UNDEFINED,
UNINITIALIZED,
NUMSETTINGS
};
enum {
DYNAMICRANGE_32,
DYNAMICRANGE_16,
DYNAMICRANGE_8,
DYNAMICRANGE_4
};
sls::Detector *det;
enum {
STANDARD,
FAST,
HIGHGAIN,
DYNAMICGAIN,
LOWGAIN,
MEDIUMGAIN,
VERYHIGHGAIN,
DYNAMICHG0,
FIXGAIN1,
FIXGAIN2,
FORCESWITCHG1,
FORCESWITCHG2,
VERLOWGAIN,
G1_HIGHGAIN,
G1_LOWGAIN,
G2_HIGHCAP_HIGHGAIN,
G2_HIGHCAP_LOWGAIN,
G2_LOWCAP_HIGHGAIN,
G2_LOWCAP_LOWGAIN,
G4_HIGHGAIN,
G4_LOWGAIN,
UNDEFINED,
UNINITIALIZED,
NUMSETTINGS
};
enum { DYNAMICRANGE_32, DYNAMICRANGE_16, DYNAMICRANGE_8, DYNAMICRANGE_4 };
};

260
slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h Executable file → Normal file
View File

@ -1,181 +1,165 @@
/**
* @author Ian Johnson
* @version 1.0
* Modifications:
* 19.06.2012: {Some functions have been added by Dhanya to enable zooming in and out
* without using mouse control:
* DisableZoom,
* SetXMinMax,SetYMinMax,
* GetXMinimum,GetXMaximum,GetYMinimum,GetYMaximum}
* */
#ifndef SLSQT1DPLOT_H
#define SLSQT1DPLOT_H
typedef double double32_t;
typedef float float32_t;
typedef int int32_t;
#include "ansi.h"
#include "SlsQt1DZoomer.h"
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_marker.h>
#include <qwt_scale_div.h>
#include "SlsQt1DZoomer.h"
#include <iostream>
class QPen;
class SlsQt1DPlot;
class QwtSymbol;
class SlsQtH1D:public QwtPlotCurve{
class SlsQtH1D : public QwtPlotCurve {
public:
SlsQtH1D(QString title, int n, double xmin, double xmax, double* data=0);
SlsQtH1D(QString title, int n, double* data_x, double* data_y);
~SlsQtH1D();
public:
SlsQtH1D(QString title, int n, double xmin, double xmax, double *data = 0);
SlsQtH1D(QString title, int n, double *data_x, double *data_y);
~SlsQtH1D();
void Attach(SlsQt1DPlot* p);
void Detach(SlsQt1DPlot* p);
void Attach(SlsQt1DPlot *p);
void Detach(SlsQt1DPlot *p);
int SetLineColor(int c=-1);
int SetLineWidth(int w=1);
void SetLineStyle(int s=0);
void setStyleLinesorDots(bool isLines);
void setSymbolMarkers(bool isMarker);
int SetLineColor(int c = -1);
int SetLineWidth(int w = 1);
void SetLineStyle(int s = 0);
void setStyleLinesorDots(bool isLines);
void setSymbolMarkers(bool isMarker);
void SetData(int n, double xmin, double xmax, double* d=0);
void SetData(int n, double* dx, double* dy);
void SetData(int n, double xmin, double xmax, double *d = 0);
void SetData(int n, double *dx, double *dy);
double* GetX() {return x;}
double* GetY() {return y;}
int GetNBinsX() {return ndata;}
double *GetX() { return x; }
double *GetY() { return y; }
int GetNBinsX() { return ndata; }
double FillBin(int bx, double v=1);
double Fill(double x, double v=1);
double SetBinContent(int bx,double v);
double SetContent(double x,double v);
int FindBinIndex(double px);
double FillBin(int bx, double v = 1);
double Fill(double x, double v = 1);
double SetBinContent(int bx, double v);
double SetContent(double x, double v);
int FindBinIndex(double px);
double GetXMin() {return x[0];}
double GetFirstXgtZero() {return firstXgt0;}
double GetXMax() {return x[ndata-1];}
double GetYMin() {return ymin;}
double GetFirstYgtZero() {return firstYgt0;}
double GetYMax() {return ymax;}
double GetXMin() { return x[0]; }
double GetFirstXgtZero() { return firstXgt0; }
double GetXMax() { return x[ndata - 1]; }
double GetYMin() { return ymin; }
double GetFirstYgtZero() { return firstYgt0; }
double GetYMax() { return ymax; }
SlsQtH1D* Add(double v);
SlsQtH1D *Add(double v);
private:
int ndata;
int n_array;
double dx;
double *x{nullptr}, *y{nullptr};
double ymin, ymax;
double firstXgt0, firstYgt0;
void Initailize();
int SetUpArrays(int n);
int CheckIndex(int bx);
private:
int ndata;
int n_array;
double dx;
double *x,*y;
double ymin,ymax;
double firstXgt0,firstYgt0;
void Initailize();
int SetUpArrays(int n);
int CheckIndex(int bx);
QPen* pen_ptr;
QPen *pen_ptr{nullptr};
};
class SlsQtH1DList {
public:
SlsQtH1DList(SlsQtH1D *hist = 0);
~SlsQtH1DList();
class SlsQtH1DList{
public:
SlsQtH1DList(SlsQtH1D* hist=0);
~SlsQtH1DList();
SlsQtH1D *Add(SlsQtH1D *h);
void Remove(SlsQtH1D *h);
void Print();
SlsQtH1D* Add(SlsQtH1D* h);
void Remove(SlsQtH1D* h);
void Print();
SlsQtH1D *Hist() { return the_hist; } // if no hist returns 0
SlsQtH1DList *Next() { return the_next; }
SlsQtH1D* Hist() {return the_hist;} //if no hist returns 0
SlsQtH1DList* Next() {return the_next;}
private:
SlsQtH1DList* the_next;
SlsQtH1D* the_hist;
private:
SlsQtH1DList *the_next;
SlsQtH1D *the_hist;
};
class SlsQt1DPlot:public QwtPlot{
Q_OBJECT
class SlsQt1DPlot : public QwtPlot {
Q_OBJECT
public:
SlsQt1DPlot(QWidget* = NULL);
~SlsQt1DPlot();
void SetTitle(QString title);
void SetXTitle(QString title);
void SetYTitle(QString title);
void SetTitleFont(const QFont& f);
void SetXFont(const QFont& f);
void SetYFont(const QFont& f);
void InsertHLine(double y);
void RemoveHLine();
void InsertVLine(double v);
void RemoveVLine();
public:
SlsQt1DPlot(QWidget * = NULL);
~SlsQt1DPlot();
void SetTitle(QString title);
void SetXTitle(QString title);
void SetYTitle(QString title);
void SetTitleFont(const QFont &f);
void SetXFont(const QFont &f);
void SetYFont(const QFont &f);
/** This group of functions have been added by Dhanya on 19.06.2012 to be able to
use zooming functionality without mouse control*/
void DisableZoom(bool disable);
void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);Update();};
void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);Update();};
void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);};
void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);};
double GetXMinimum(){return hist_list->Hist()->GetXMin();};
double GetXMaximum(){return hist_list->Hist()->GetXMax();};
double GetYMinimum(){return hist_list->Hist()->GetYMin();};
double GetYMaximum(){return hist_list->Hist()->GetYMax();};
/**---*/
void InsertHLine(double y);
void RemoveHLine();
void InsertVLine(double v);
void RemoveVLine();
/** This group of functions have been added by Dhanya on 19.06.2012 to be
able to use zooming functionality without mouse control*/
void DisableZoom(bool disable);
void EnableXAutoScaling() {
setAxisAutoScale(QwtPlot::xBottom, true);
Update();
};
void EnableYAutoScaling() {
setAxisAutoScale(QwtPlot::yLeft, true);
Update();
};
void SetYStep(int step) { ystep = step; };
void SetXMinMax(double min, double max) {
setAxisScale(QwtPlot::xBottom, min, max);
};
void SetYMinMax(double min, double max) {
setAxisScale(QwtPlot::yLeft, min, max);
};
double GetXMinimum() { return hist_list->Hist()->GetXMin(); };
double GetXMaximum() { return hist_list->Hist()->GetXMax(); };
double GetYMinimum() { return hist_list->Hist()->GetYMin(); };
double GetYMaximum() { return hist_list->Hist()->GetYMax(); };
/**---*/
void SetZoom(double xmin,double ymin,double x_width,double y_width);
void SetZoomBase(double xmin,double ymin,double x_width, double y_width){ zoomer->SetZoomBase(xmin,ymin,x_width,y_width);}
void SetZoom(double xmin, double ymin, double x_width, double y_width);
void SetZoomBase(double xmin, double ymin, double x_width, double y_width) {
zoomer->SetZoomBase(xmin, ymin, x_width, y_width);
}
void alignScales();
void alignScales();
void SetLogX(bool yes=1);
void SetLogY(bool yes=1);
private:
SlsQtH1DList* hist_list;
SlsQt1DZoomer* zoomer;
QwtPlotPanner* panner;
void SetLogX(bool yes = 1);
void SetLogY(bool yes = 1);
QwtPlotMarker *hline;
QwtPlotMarker *vline;
bool disableZoom{false};
void SetupZoom();
void UnknownStuff();
//void alignScales();
void CalculateNResetZoomBase();
void NewHistogramAttached(SlsQtH1D* h);
void HistogramDetached(SlsQtH1D* h);
private:
SlsQtH1DList *hist_list{nullptr};
SlsQt1DZoomer *zoomer{nullptr};
QwtPlotPanner *panner{nullptr};
void SetLog(int axisId, bool yes);
friend void SlsQtH1D::Attach(SlsQt1DPlot* p);
friend void SlsQtH1D::Detach(SlsQt1DPlot* p);
public slots:
void UnZoom();
void Update();
QwtPlotMarker *hline{nullptr};
QwtPlotMarker *vline{nullptr};
bool disableZoom{false};
int ystep{0};
void SetupZoom();
void UnknownStuff();
// void alignScales();
void CalculateNResetZoomBase();
void NewHistogramAttached(SlsQtH1D *h);
void HistogramDetached(SlsQtH1D *h);
void SetLog(int axisId, bool yes);
friend void SlsQtH1D::Attach(SlsQt1DPlot *p);
friend void SlsQtH1D::Detach(SlsQt1DPlot *p);
public slots:
void UnZoom();
void Update();
};
#endif

View File

@ -1,74 +1,52 @@
/**
* @author Ian Johnson
* @version 1.0
*/
#ifndef SLSQT1DZOOMER_H
#define SLSQT1DZOOMER_H
#include <qwt_plot_zoomer.h>
#include <qwt_plot_panner.h>
#include <qwt_global.h>
#include <qwt_plot_panner.h>
#include <qwt_plot_zoomer.h>
class SlsQtH1D;
class SlsQt1DZoomer:public QwtPlotZoomer{
private:
double x0,x1,y0,y1;
double firstXgt0,firstYgt0;
bool xIsLog,yIsLog;
class SlsQt1DZoomer : public QwtPlotZoomer {
private:
double x0, x1, y0, y1;
double firstXgt0, firstYgt0;
bool xIsLog, yIsLog;
public:
#if QWT_VERSION < 0x060100
SlsQt1DZoomer(QwtPlotCanvas *canvas):QwtPlotZoomer(canvas){
#else
SlsQt1DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
#endif
setTrackerMode(AlwaysOn);
xIsLog=yIsLog=0;
}
public:
SlsQt1DZoomer(QWidget *canvas) : QwtPlotZoomer(canvas) {
setTrackerMode(AlwaysOn);
xIsLog = yIsLog = 0;
}
double x() {return x0;}
double x_firstGreaterThan0() {return firstXgt0;}
double w() {return x1-x0;}
double x() { return x0; }
double x_firstGreaterThan0() { return firstXgt0; }
double w() { return x1 - x0; }
double y() {return y0;}
double y_firstGreaterThan0() {return firstYgt0;}
double h() {return y1-y0;}
double y() { return y0; }
double y_firstGreaterThan0() { return firstYgt0; }
double h() { return y1 - y0; }
void SetZoomBase(double xmin,double ymin,double x_width, double y_width);
void SetZoomBase(SlsQtH1D* h);
void ExtendZoomBase(SlsQtH1D* h);
void ResetZoomBase();
void SetZoomBase(double xmin, double ymin, double x_width, double y_width);
void SetZoomBase(SlsQtH1D *h);
void ExtendZoomBase(SlsQtH1D *h);
void ResetZoomBase();
bool IsLogX(){ return xIsLog;}
bool IsLogY(){ return yIsLog;}
bool SetLogX(bool yes) { return xIsLog=yes;}
bool SetLogY(bool yes) { return yIsLog=yes;}
bool IsLogX() { return xIsLog; }
bool IsLogY() { return yIsLog; }
bool SetLogX(bool yes) { return xIsLog = yes; }
bool SetLogY(bool yes) { return yIsLog = yes; }
#if QWT_VERSION<0x060000
virtual QwtText trackerText(const QwtDoublePoint &pos) const{
#else
using QwtPlotPicker::trackerText;
virtual QwtText trackerText(const QPoint &pos) const{
#endif
QColor bg(Qt::white);
#if QT_VERSION >= 0x040300
bg.setAlpha(200);
#endif
#if QWT_VERSION<0x060000
QwtText text = QwtPlotZoomer::trackerText(pos);
#else
QwtText text = QwtPlotPicker::trackerText(pos);
#endif
text.setBackgroundBrush( QBrush( bg ));
return text;
}
using QwtPlotPicker::trackerText;
virtual QwtText trackerText(const QPoint &pos) const {
QColor bg(Qt::white);
bg.setAlpha(200);
QwtText text = QwtPlotPicker::trackerText(pos);
text.setBackgroundBrush(QBrush(bg));
return text;
}
};
#endif

201
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h Executable file → Normal file
View File

@ -1,137 +1,126 @@
/**
* @author Ian Johnson
* @version 1.0
*/
#ifndef SLSQT2DHIST_H
#define SLSQT2DHIST_H
#if QT_VERSION >= 0x040000
#include <qprintdialog.h>
#endif
#include <qwt_color_map.h>
#include <qwt_plot_spectrogram.h>
#include <qwt_scale_widget.h>
#include <qwt_scale_draw.h>
#include <qwt_scale_widget.h>
class SlsQt2DHist : public QwtRasterData {
class SlsQt2DHist: public QwtRasterData{
private:
private:
double x_min, x_max, y_min, y_max;
double x_width, y_width;
double x_min,x_max,y_min,y_max;
double x_width,y_width;
int nx, ny, nb;
double *data{nullptr};
double z_min, z_mean, z_max;
bool z_mean_has_been_calculated;
int nx,ny,nb;
double *data;
double z_min,z_mean,z_max;
bool z_mean_has_been_calculated;
int nx_array,ny_array;
int nx_array, ny_array;
bool interp;
bool interp;
static double value_between_points(double p1,double v1,double p2,double v2,double p){ //linear extrap
return (v2-v1)/(p2-p1)*(p-p1)+v1;
}
public:
SlsQt2DHist(int nbinsx=10, double xmin=0, double xmax=10, int nbinsy=10, double ymin=0, double ymax=10, double* d=0,double zmin=0,double zmax=-1);
virtual ~SlsQt2DHist();
static double value_between_points(double p1, double v1, double p2,
double v2, double p) { // linear extrap
return (v2 - v1) / (p2 - p1) * (p - p1) + v1;
}
double GetXMin() {return x_min;}
double GetXMax() {return x_max;}
double GetXBinWidth() {return x_width;}
double GetYMin() {return y_min;}
double GetYMax() {return y_max;}
double GetYBinWidth() {return y_width;}
double GetMinimum() {return z_min;}
double GetMaximum() {return z_max;}
double GetMean();
public:
SlsQt2DHist(int nbinsx = 10, double xmin = 0, double xmax = 10,
int nbinsy = 10, double ymin = 0, double ymax = 10,
double *d = 0, double zmin = 0, double zmax = -1);
virtual ~SlsQt2DHist();
int GetNBinsX(){return nx;}
int GetNBinsY(){return ny;}
double GetBinValue(int bx,int by);
int GetBinIndex(int bx,int by);
double* GetDataPtr(){return data;}
double GetXMin() { return x_min; }
double GetXMax() { return x_max; }
double GetXBinWidth() { return x_width; }
double GetYMin() { return y_min; }
double GetYMax() { return y_max; }
double GetYBinWidth() { return y_width; }
double GetMinimum() { return z_min; }
double GetMaximum() { return z_max; }
double GetMean();
void Interpolate(bool on=1) {interp=on;}
void SetBinValue(int bx,int by,double v);
void SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax,double *d,double zmin=0, double zmax=-1);
double SetMinimumToFirstGreaterThanZero();
void SetMinimum(double zmin) {z_min=zmin;}
void SetMaximum(double zmax) {z_max=zmax;}
void SetMinMax(double zmin=0,double zmax=-1);
int GetNBinsX() { return nx; }
int GetNBinsY() { return ny; }
double GetBinValue(int bx, int by);
int GetBinIndex(int bx, int by);
double *GetDataPtr() { return data; }
int FindBinIndex(double x, double y);
void Interpolate(bool on = 1) { interp = on; }
void SetBinValue(int bx, int by, double v);
void SetData(int nbinsx, double xmin, double xmax, int nbinsy, double ymin,
double ymax, double *d, double zmin = 0, double zmax = -1);
double SetMinimumToFirstGreaterThanZero();
void SetMinimum(double zmin) { z_min = zmin; }
void SetMaximum(double zmax) { z_max = zmax; }
void SetMinMax(double zmin = 0, double zmax = -1);
int FindBinIndex(double x, double y);
virtual QwtRasterData *copy() const{
//this function does not create a new SlsQt2DHistData instance,
//just passes a pointer so that data is common to both the copy and the original instance
return (QwtRasterData*) this;
}
virtual QwtRasterData *copy() const {
// this function does not create a new SlsQt2DHistData instance,
// just passes a pointer so that data is common to both the copy and the
// original instance
return (QwtRasterData *)this;
}
#if QWT_VERSION<0x060000
virtual QwtDoubleInterval range() const{ return QwtDoubleInterval(z_min,z_max);}
#else
virtual QwtInterval range() const{ return QwtInterval(z_min,z_max);}
virtual QwtInterval interval(Qt::Axis axis) const {
switch (axis){
case Qt::ZAxis:
return QwtInterval(z_min,z_max);
case Qt::XAxis:
return QwtInterval(x_min,x_max);
case Qt::YAxis:
return QwtInterval(y_min,y_max);
default:
return QwtInterval(z_min,z_max);
virtual QwtInterval range() const { return QwtInterval(z_min, z_max); }
virtual QwtInterval interval(Qt::Axis axis) const {
switch (axis) {
case Qt::ZAxis:
return QwtInterval(z_min, z_max);
case Qt::XAxis:
return QwtInterval(x_min, x_max);
case Qt::YAxis:
return QwtInterval(y_min, y_max);
default:
return QwtInterval(z_min, z_max);
};
};
};
#endif
virtual double value(double x, double y) const {
// if(!interp){ //default is box like plot
int index =
int((x - x_min) / x_width) + int((y - y_min) / y_width) * nx;
if (index < 0 || index > nb)
index = nb;
if (!interp)
return data[index];
//}
int x_int = int((x - x_min) / x_width - 0.5);
if (x_int < 0)
x_int = 0;
else if (x_int > nx - 2)
x_int = nx - 2;
int y_int = int((y - y_min) / y_width - 0.5);
if (y_int < 0)
y_int = 0;
else if (y_int > ny - 2)
y_int = ny - 2;
virtual double value(double x, double y) const{
//if(!interp){ //default is box like plot
int index = int((x-x_min)/x_width) + int((y-y_min)/y_width)*nx;
if(index<0||index>nb) index = nb;
if(!interp) return data[index];
//}
int b00 = x_int * ny + y_int;
int b01 = x_int * ny + y_int + 1;
int b10 = (x_int + 1) * ny + y_int;
int b11 = (x_int + 1) * ny + y_int + 1;
int x_int = int((x-x_min)/x_width-0.5);
if(x_int<0) x_int = 0; else if(x_int>nx-2) x_int = nx-2;
int y_int = int((y-y_min)/y_width-0.5);
if(y_int<0) y_int = 0; else if(y_int>ny-2) y_int = ny-2;
// vertical extrap
double y0 = y_min + (y_int + 0.5) * y_width;
double y1 = y_min + (y_int + 1.5) * y_width;
double left_v = value_between_points(y0, data[b00], y1, data[b01], y);
double right_v = value_between_points(y0, data[b10], y1, data[b11], y);
// horazontal extrap
int b00 = x_int*ny + y_int;
int b01 = x_int*ny + y_int+1;
int b10 = (x_int+1)*ny + y_int;
int b11 = (x_int+1)*ny + y_int+1;
return 0.5;
//vertical extrap
double y0 = y_min+(y_int+0.5)*y_width;
double y1 = y_min+(y_int+1.5)*y_width;
double left_v = value_between_points(y0,data[b00],y1,data[b01],y);
double right_v = value_between_points(y0,data[b10],y1,data[b11],y);
//horazontal extrap
return 0.5;
return value_between_points(x_min+(x_int+0.5)*x_width,left_v,
x_min+(x_int+1.5)*x_width,right_v,x);
}
return value_between_points(x_min + (x_int + 0.5) * x_width, left_v,
x_min + (x_int + 1.5) * x_width, right_v,
x);
}
};
#endif

117
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h Executable file → Normal file
View File

@ -1,98 +1,87 @@
#pragma once
#include <qwt_plot.h>
#include "SlsQt2DHist.h"
#include "SlsQt2DZoomer.h"
#include <qlist.h>
#include <qwt_plot.h>
#include <qwt_plot_spectrogram.h>
#include "SlsQt2DZoomer.h"
#include "SlsQt2DHist.h"
class QwtPlotPanner;
class QwtScaleWidget;
class QwtLinearColorMap;
class QwtPlotPanner;
class QwtScaleWidget;
class QwtLinearColorMap;
class SlsQt2DPlot: public QwtPlot{
class SlsQt2DPlot : public QwtPlot {
Q_OBJECT
public:
public:
SlsQt2DPlot(QWidget * = NULL);
~SlsQt2DPlot();
void SetTitle(QString title);
void SetXTitle(QString title);
void SetYTitle(QString title);
void SetZTitle(QString title);
void SetTitleFont(const QFont& f);
void SetXFont(const QFont& f);
void SetYFont(const QFont& f);
void SetZFont(const QFont& f);
void SetTitleFont(const QFont &f);
void SetXFont(const QFont &f);
void SetYFont(const QFont &f);
void SetZFont(const QFont &f);
void UnZoom(bool replot=true);
void SetZoom(double xmin,double ymin,double x_width,double y_width);
void UnZoom(bool replot = true);
void SetZoom(double xmin, double ymin, double x_width, double y_width);
void DisableZoom(bool disable);
void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);};
void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);};
void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);};
void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);};
double GetXMinimum(){return hist->GetXMin();};
double GetXMaximum(){return hist->GetXMax();};
double GetYMinimum(){return hist->GetYMin();};
double GetYMaximum(){return hist->GetYMax();};
double GetZMinimum(){ return hist->GetMinimum();}
double GetZMaximum(){ return hist->GetMaximum();}
void SetZMinMax(double zmin=0,double zmax=-1);
void SetZMinimumToFirstGreaterThanZero(){hist->SetMinimumToFirstGreaterThanZero();}
double GetZMean() { return hist->GetMean();}
void EnableXAutoScaling() { setAxisAutoScale(QwtPlot::xBottom, true); };
void EnableYAutoScaling() { setAxisAutoScale(QwtPlot::yLeft, true); };
void SetXMinMax(double min, double max) {
setAxisScale(QwtPlot::xBottom, min, max);
};
void SetYMinMax(double min, double max) {
setAxisScale(QwtPlot::yLeft, min, max);
};
double GetXMinimum() { return hist->GetXMin(); };
double GetXMaximum() { return hist->GetXMax(); };
double GetYMinimum() { return hist->GetYMin(); };
double GetYMaximum() { return hist->GetYMax(); };
double GetZMinimum() { return hist->GetMinimum(); }
double GetZMaximum() { return hist->GetMaximum(); }
void SetZMinMax(double zmin = 0, double zmax = -1);
void SetZMinimumToFirstGreaterThanZero() {
hist->SetMinimumToFirstGreaterThanZero();
}
double GetZMean() { return hist->GetMean(); }
void SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax,double *d,double zmin=0, double zmax=-1){
hist->SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d,zmin,zmax);
void SetData(int nbinsx, double xmin, double xmax, int nbinsy, double ymin,
double ymax, double *d, double zmin = 0, double zmax = -1) {
hist->SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d, zmin, zmax);
}
double* GetDataPtr() {return hist->GetDataPtr();}
int GetBinIndex(int bx,int by) {return hist->GetBinIndex(bx,by);}
int FindBinIndex(double x,double y) {return hist->FindBinIndex(x,y);}
void SetBinValue(int bx,int by,double v) { hist->SetBinValue(bx,by,v);}
double GetBinValue(int bx,int by) {return hist->GetBinValue(bx,by);}
void FillTestPlot(int i=0);
double *GetDataPtr() { return hist->GetDataPtr(); }
int GetBinIndex(int bx, int by) { return hist->GetBinIndex(bx, by); }
int FindBinIndex(double x, double y) { return hist->FindBinIndex(x, y); }
void SetBinValue(int bx, int by, double v) { hist->SetBinValue(bx, by, v); }
double GetBinValue(int bx, int by) { return hist->GetBinValue(bx, by); }
void FillTestPlot(int i = 0);
void Update();
void SetInterpolate(bool enable);
void SetContour(bool enable);
void SetLogz(bool enable, bool isMin, bool isMax, double min, double max);
void SetZRange(bool isMin, bool isMax, double min, double max);
void LogZ(bool on=1);
void LogZ(bool on = 1);
public slots:
public slots:
void showSpectrogram(bool on);
private:
private:
void SetupZoom();
void SetupColorMap();
QwtLinearColorMap* myColourMap(QVector<double> colourStops);
QwtLinearColorMap* myColourMap(int log=0);
QwtLinearColorMap *myColourMap(QVector<double> colourStops);
QwtLinearColorMap *myColourMap(int log = 0);
QwtPlotSpectrogram *d_spectrogram;
SlsQt2DHist* hist;
SlsQt2DZoomer* zoomer;
QwtPlotPanner* panner;
QwtScaleWidget *rightAxis;
QwtLinearColorMap* colorMapLinearScale;
QwtLinearColorMap* colorMapLogScale;
#if QWT_VERSION<0x060000
QwtValueList* contourLevelsLinear;
QwtValueList* contourLevelsLog;
#else
QwtPlotSpectrogram *d_spectrogram{nullptr};
SlsQt2DHist *hist{nullptr};
SlsQt2DZoomer *zoomer{nullptr};
QwtPlotPanner *panner{nullptr};
QwtScaleWidget *rightAxis{nullptr};
QList<double> contourLevelsLinear;
QList<double> contourLevelsLog;
#endif
bool disableZoom{false};
int isLog;
};

View File

@ -1,73 +1,41 @@
/**
* @author Ian Johnson
* @version 1.0
* Dhanya-05.12.2012- included an additional header
*/
#ifndef SLSQT2DZOOMER_H
#define SLSQT2DZOOMER_H
/**included by Dhanya on 05.12.2012 to avoid compile time errors with the latest gcc*/
#include <cstdio>
/**end of Change by Dhanya*/
#include <qwt_plot_zoomer.h>
#include <qwt_plot_panner.h>
#include "SlsQt2DHist.h"
#include <qwt_plot_panner.h>
#include <qwt_plot_zoomer.h>
#include <cstdio>
class SlsQt2DZoomer:public QwtPlotZoomer{
private:
SlsQt2DHist* hist;
public:
#if QWT_VERSION < 0x060100
SlsQt2DZoomer(QwtPlotCanvas *canvas):QwtPlotZoomer(canvas){
#else
SlsQt2DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
#endif
setTrackerMode(AlwaysOn);
}
void SetHist(SlsQt2DHist* h){
hist=h;
}
#if QWT_VERSION<0x060000
virtual QwtText trackerText(const QwtDoublePoint &pos) const{
#else
virtual QwtText trackerTextF(const QPointF &pos) const{
#endif
QColor bg(Qt::white);
#if QT_VERSION >= 0x040300
bg.setAlpha(200);
#endif
//QwtText text = QwtPlotZoomer::trackerText(pos);
static QwtText text;
if(hist){
static char t[200];
sprintf(t,"%3.2f, %3.2f, %3.2f",pos.x(),pos.y(),hist->value(pos.x(),pos.y()));
text.setText(t);
}else {
#if QWT_VERSION<0x060000
QwtText text = QwtPlotZoomer::trackerText(pos);
#else
QPoint p=pos.toPoint();
QwtText text = QwtPlotZoomer::trackerText(p);
#endif
class SlsQt2DZoomer : public QwtPlotZoomer {
private:
SlsQt2DHist *hist;
public:
SlsQt2DZoomer(QWidget *canvas) : QwtPlotZoomer(canvas) {
setTrackerMode(AlwaysOn);
}
void SetHist(SlsQt2DHist *h) { hist = h; }
virtual QwtText trackerTextF(const QPointF &pos) const {
QColor bg(Qt::white);
bg.setAlpha(200);
// QwtText text = QwtPlotZoomer::trackerText(pos);
static QwtText text;
if (hist) {
static char t[200];
sprintf(t, "%3.2f, %3.2f, %3.2f", pos.x(), pos.y(),
hist->value(pos.x(), pos.y()));
text.setText(t);
} else {
QPoint p = pos.toPoint();
QwtText text = QwtPlotZoomer::trackerText(p);
}
text.setBackgroundBrush(QBrush(bg));
return text;
}
text.setBackgroundBrush( QBrush( bg ));
return text;
}
};
#endif

View File

@ -1,11 +1,7 @@
/**
* @author Ian Johnson
* @version 1.0
*/
/* TODO! short description */
#include "SlsQt1DPlot.h"
#include <iostream>
#include <qwt_symbol.h>
#include <qwt_legend.h>
#include <qwt_math.h>
#include <qwt_painter.h>
@ -14,33 +10,36 @@
#include <qwt_scale_draw.h>
#include <qwt_scale_engine.h>
#include <qwt_scale_widget.h>
#include "qwt_symbol.h"
#include <stdlib.h>
#include <iostream>
#if QWT_VERSION >= 0x060100
#define QwtLog10ScaleEngine QwtLogScaleEngine
#endif
#define QwtLog10ScaleEngine QwtLogScaleEngine // hmm
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title) {
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data)
: QwtPlotCurve(title), x(nullptr), y(nullptr), pen_ptr(nullptr) {
Initailize();
SetData(n, min, max, data);
}
SlsQtH1D::SlsQtH1D(QString title, int n, double *data_x, double *data_y) : QwtPlotCurve(title) {
SlsQtH1D::SlsQtH1D(QString title, int n, double *data_x, double *data_y)
: QwtPlotCurve(title) {
Initailize();
SetData(n, data_x, data_y);
}
void SlsQtH1D::Initailize() {
ndata = n_array = 0;
x = y = 0;
x = y = nullptr;
pen_ptr = new QPen();
SetLineColor();
}
SlsQtH1D::~SlsQtH1D() {
delete x;
delete y;
delete[] x;
delete[] y;
delete pen_ptr;
}
@ -125,21 +124,17 @@ void SlsQtH1D::SetLineStyle(int s) {
setPen(*pen_ptr);
}
void SlsQtH1D::setStyleLinesorDots(bool isLines) {
void SlsQtH1D::setStyleLinesorDots(bool isLines) {
setStyle(isLines ? QwtPlotCurve::Lines : QwtPlotCurve::Dots);
}
void SlsQtH1D::setSymbolMarkers(bool isMarker) {
QwtSymbol* marker = new QwtSymbol();
void SlsQtH1D::setSymbolMarkers(bool isMarker) {
QwtSymbol *marker = new QwtSymbol();
if (isMarker) {
marker->setStyle(QwtSymbol::Cross);
marker->setSize(5, 5);
}
#if QWT_VERSION < 0x060000
setSymbol(*marker);
#else
setSymbol(marker);
#endif
}
void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data) {
@ -170,11 +165,7 @@ void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data) {
firstYgt0 = y[i];
}
#if QWT_VERSION < 0x060000
setRawData(x, y, ndata);
#else
setRawSamples(x, y, ndata);
#endif
}
void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
@ -183,7 +174,7 @@ void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
n = SetUpArrays(n);
ndata = n;
dx = -1; //signifies not regular intervals
dx = -1; // signifies not regular intervals
ymin = ymax = data_y ? data_y[0] : 0;
@ -203,23 +194,18 @@ void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
if (y[b] > 0 && (firstYgt0 < 0 || firstYgt0 > y[b]))
firstYgt0 = y[b];
}
// #if QWT_VERSION<0x060000
// setRawData(x,y,ndata);
// #else
setRawSamples(x, y, ndata);
// #endif
}
int SlsQtH1D::SetUpArrays(int n) {
n = n < 1 ? 1 : n; //overflow bin
n = n < 1 ? 1 : n; // overflow bin
if (n + 1 > n_array) {
n_array = n + 1;
if (x)
delete x;
if (y)
delete y;
delete x;
delete y;
x = new double[n_array];
y = new double[n_array];
}
@ -231,7 +217,9 @@ double SlsQtH1D::FillBin(int bx, double v) {
bx = CheckIndex(bx);
return SetBinContent(bx, y[bx] + v);
}
double SlsQtH1D::Fill(double x, double v) { return FillBin(FindBinIndex(x), v); }
double SlsQtH1D::Fill(double x, double v) {
return FillBin(FindBinIndex(x), v);
}
double SlsQtH1D::SetBinContent(int bx, double v) {
bx = CheckIndex(bx);
@ -247,13 +235,15 @@ double SlsQtH1D::SetBinContent(int bx, double v) {
return y[bx];
}
double SlsQtH1D::SetContent(double x, double v) { return SetBinContent(FindBinIndex(x), v); }
double SlsQtH1D::SetContent(double x, double v) {
return SetBinContent(FindBinIndex(x), v);
}
int SlsQtH1D::FindBinIndex(double px) {
if (dx > 0)
CheckIndex(int((px - x[0]) / dx));
//find closest bin
// find closest bin
int b = 0;
for (; b < ndata; b++)
if (x[b] > px)
@ -267,7 +257,9 @@ int SlsQtH1D::FindBinIndex(double px) {
return b;
}
int SlsQtH1D::CheckIndex(int bx) { return (bx < 0 || bx > ndata) ? ndata : bx; } //ndata is the overflow bin
int SlsQtH1D::CheckIndex(int bx) {
return (bx < 0 || bx > ndata) ? ndata : bx;
} // ndata is the overflow bin
SlsQtH1D *SlsQtH1D::Add(double v) {
for (int bx = 0; bx < ndata; bx++)
@ -275,23 +267,20 @@ SlsQtH1D *SlsQtH1D::Add(double v) {
return this;
}
//1d hist list stuff
// 1d hist list stuff
SlsQtH1DList::SlsQtH1DList(SlsQtH1D *hist) {
the_hist = hist;
the_next = 0;
the_next = nullptr;
}
SlsQtH1DList::~SlsQtH1DList() {
if (the_next)
delete the_next;
}
SlsQtH1DList::~SlsQtH1DList() { delete the_next; }
SlsQtH1D *SlsQtH1DList::Add(SlsQtH1D *hist) {
SlsQtH1DList *hl = this;
while (hl) {
if (hist == hl->the_hist)
return hist; //already added
return hist; // already added
if (!hl->the_next)
break;
hl = hl->the_next;
@ -310,7 +299,8 @@ void SlsQtH1DList::Print() {
SlsQtH1DList *hl = this;
int i = 0;
while (hl) {
std::cout << " " << i++ << ") " << hl << " " << hl->the_hist << " " << hl->the_next << '\n';
std::cout << " " << i++ << ") " << hl << " " << hl->the_hist << " "
<< hl->the_next << '\n';
hl = hl->the_next;
if (i > 10)
break;
@ -319,27 +309,27 @@ void SlsQtH1DList::Print() {
void SlsQtH1DList::Remove(SlsQtH1D *hist) {
SlsQtH1DList *hl = this;
while (hl) { //every match will be removed
while (hl) { // every match will be removed
if (hl->the_hist != hist)
hl = hl->the_next;
else { //match
else { // match
if (!hl->the_next)
hl->the_hist = 0; // first the_hist is zero when there's no next
hl->the_hist = nullptr; // first the_hist is zero when there's no next
else {
SlsQtH1DList *t = hl->the_next;
hl->the_hist = t->the_hist;
hl->the_next = t->the_next;
t->the_next = 0;
t->the_next = nullptr;
delete t;
}
}
}
}
//1d plot stuff
// 1d plot stuff
SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
// n_histograms_attached=0;
hline = vline = 0;
hline = vline = nullptr;
hist_list = new SlsQtH1DList();
UnknownStuff();
@ -358,12 +348,16 @@ SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
}
SlsQt1DPlot::~SlsQt1DPlot() {
delete hist_list;
if (hline)
delete hline;
if (vline)
delete vline;
delete hline;
delete vline;
delete zoomer;
delete panner;
}
void SlsQt1DPlot::CalculateNResetZoomBase() {
@ -380,8 +374,8 @@ void SlsQt1DPlot::CalculateNResetZoomBase() {
void SlsQt1DPlot::NewHistogramAttached(SlsQtH1D *h) {
hist_list->Add(h);
CalculateNResetZoomBase();
//commented out by dhanya to take off zooming every hist in 1d plots
//if(!hist_list->Next()) UnZoom();
// commented out by dhanya to take off zooming every hist in 1d plots
// if(!hist_list->Next()) UnZoom();
Update();
}
@ -391,13 +385,9 @@ void SlsQt1DPlot::HistogramDetached(SlsQtH1D *h) {
Update();
}
void SlsQt1DPlot::Update() {
replot();
}
void SlsQt1DPlot::Update() { replot(); }
void SlsQt1DPlot::SetTitle(QString title) {
setTitle(title);
}
void SlsQt1DPlot::SetTitle(QString title) { setTitle(title); }
void SlsQt1DPlot::SetXTitle(QString title) {
setAxisTitle(QwtPlot::xBottom, title);
@ -407,20 +397,20 @@ void SlsQt1DPlot::SetYTitle(QString title) {
setAxisTitle(QwtPlot::yLeft, title);
}
void SlsQt1DPlot::SetTitleFont(const QFont& f) {
void SlsQt1DPlot::SetTitleFont(const QFont &f) {
QwtText t("");
t.setFont(f);
t.setRenderFlags( Qt::AlignLeft | Qt::AlignVCenter);
t.setRenderFlags(Qt::AlignLeft | Qt::AlignVCenter);
setTitle(t);
}
void SlsQt1DPlot::SetXFont(const QFont& f) {
void SlsQt1DPlot::SetXFont(const QFont &f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::xBottom, t);
}
void SlsQt1DPlot::SetYFont(const QFont& f) {
void SlsQt1DPlot::SetYFont(const QFont &f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::yLeft, t);
@ -434,9 +424,10 @@ void SlsQt1DPlot::SetLog(int axisId, bool yes) {
if (axisId == QwtPlot::yLeft)
zoomer->SetLogY(yes);
zoomer->ResetZoomBase(); //needs to be done before setting Engine
zoomer->ResetZoomBase(); // needs to be done before setting Engine
//the old ones are deleted by in the setAxisScaleFunction() function see: 128 of file qwt_plot_axis.cpp
// the old ones are deleted by in the setAxisScaleFunction() function see:
// 128 of file qwt_plot_axis.cpp
if (yes)
setAxisScaleEngine(axisId, new QwtLog10ScaleEngine());
else
@ -452,11 +443,13 @@ void SlsQt1DPlot::UnZoom() {
setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w());
setAxisScale(QwtPlot::yLeft, zoomer->y(), zoomer->y() + zoomer->h());
zoomer->setZoomBase(); //Call replot for the attached plot before initializing the zoomer with its scales.
zoomer->setZoomBase(); // Call replot for the attached plot before
// initializing the zoomer with its scales.
Update();
}
void SlsQt1DPlot::SetZoom(double xmin, double ymin, double x_width, double y_width) {
void SlsQt1DPlot::SetZoom(double xmin, double ymin, double x_width,
double y_width) {
setAxisScale(QwtPlot::xBottom, xmin, xmin + x_width);
setAxisScale(QwtPlot::yLeft, ymin, ymin + y_width);
Update();
@ -466,7 +459,7 @@ void SlsQt1DPlot::RemoveHLine() {
if (hline)
hline->detach();
delete hline;
hline = 0;
hline = nullptr;
}
void SlsQt1DPlot::InsertHLine(double y) {
@ -483,7 +476,7 @@ void SlsQt1DPlot::RemoveVLine() {
if (vline)
vline->detach();
delete vline;
vline = 0;
vline = nullptr;
}
void SlsQt1DPlot::InsertVLine(double x) {
@ -503,12 +496,9 @@ void SlsQt1DPlot::SetupZoom() {
// Ctrl+RighButton: zoom out to full size
zoomer = new SlsQt1DZoomer(canvas());
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
Qt::ControlModifier);
#if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
panner = new QwtPlotPanner((QwtPlotCanvas *)canvas());
@ -547,58 +537,40 @@ void SlsQt1DPlot::alignScales() {
}
void SlsQt1DPlot::UnknownStuff() {
#if QWT_VERSION < 0x060000
// Disable polygon clipping
//not supported for version 6
QwtPainter::setDeviceClipping(false);
canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
#else
// We don't need the cache here
((QwtPlotCanvas *)canvas())->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
#endif
#if QT_VERSION >= 0x040000
((QwtPlotCanvas *)canvas())
->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
#ifdef Q_WS_X11
// Qt::WA_PaintOnScreen is only supported for X11, but leads
// to substantial bugs with Qt 4.2.x/Windows
canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif
#endif
}
//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set
// Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range
// has been set
void SlsQt1DPlot::DisableZoom(bool disable) {
if (disableZoom != disable) {
disableZoom = disable;
#ifdef VERBOSE
if (disable)
std::cout << "Disabling zoom\n";
else
std::cout << "Enabling zoom\n";
#endif
if (disable) {
if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
#if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
Qt::NoButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::NoButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::NoButton);
}
if (panner)
panner->setMouseButton(Qt::NoButton);
} else {
if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
#if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
Qt::LeftButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
}
if (panner)
panner->setMouseButton(Qt::MidButton);

View File

@ -0,0 +1,93 @@
/* TODO! short description */
#include "SlsQt1DZoomer.h"
#include "SlsQt1DPlot.h"
#include <qwt_plot.h>
#include <qwt_scale_div.h>
#include <iostream>
void SlsQt1DZoomer::ResetZoomBase() {
SetZoomBase(x0, y0, x1 - x0,
y1 - y0); // for going between log and nonlog plots
}
void SlsQt1DZoomer::SetZoomBase(double xmin, double ymin, double x_width,
double y_width) {
if (xIsLog && xmin <= 0) {
double xmax = xmin + x_width;
xmin = firstXgt0 * 0.98;
if (xmax <= xmin)
x_width = firstXgt0;
else
x_width = xmax - xmin;
}
if (yIsLog && ymin <= 0) {
double ymax = ymin + y_width;
ymin = firstYgt0 * 0.98;
if (ymax <= ymin)
y_width = firstYgt0;
else
y_width = ymax - ymin;
}
if (plot()) {
if (xIsLog) {
double xmin_curr =
plot()->axisScaleDiv(QwtPlot::xBottom).lowerBound();
double xmax_curr =
plot()->axisScaleDiv(QwtPlot::xBottom).upperBound();
if (xmin_curr < xmin)
xmin_curr = xmin;
if (xmax_curr > xmin + x_width)
xmax_curr = xmin + x_width;
plot()->setAxisScale(QwtPlot::xBottom, xmin_curr, xmax_curr);
}
if (yIsLog) {
double ymin_curr =
plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound();
double ymax_curr =
plot()->axisScaleDiv(QwtPlot::yLeft).upperBound();
if (ymin_curr < ymin)
ymin_curr = ymin;
if (ymax_curr > ymin + y_width)
ymax_curr = ymin + y_width;
plot()->setAxisScale(QwtPlot::yLeft, ymin_curr, ymax_curr);
}
plot()->replot();
}
setZoomBase(QRectF(xmin, ymin, x_width, y_width));
}
void SlsQt1DZoomer::SetZoomBase(SlsQtH1D *h) {
x0 = h->GetXMin() < 0 ? h->GetXMin() * 1.02 : h->GetXMin() / 1.02;
x1 = h->GetXMax() < 0 ? h->GetXMax() / 1.02 : h->GetXMax() * 1.02;
y0 = h->GetYMin() < 0 ? h->GetYMin() * 1.02 : h->GetYMin() / 1.02;
y1 = h->GetYMax() < 0 ? h->GetYMax() / 1.02 : h->GetYMax() * 1.02;
firstXgt0 = h->GetFirstXgtZero(); // for log plots
firstYgt0 = h->GetFirstYgtZero(); // for log plots
ResetZoomBase();
}
void SlsQt1DZoomer::ExtendZoomBase(SlsQtH1D *h) {
double h_x0 = h->GetXMin() < 0 ? h->GetXMin() * 1.02 : h->GetXMin() / 1.02;
double h_x1 = h->GetXMax() < 0 ? h->GetXMax() / 1.02 : h->GetXMax() * 1.02;
double h_y0 = h->GetYMin() < 0 ? h->GetYMin() * 1.02 : h->GetYMin() / 1.02;
double h_y1 = h->GetYMax() < 0 ? h->GetYMax() / 1.02 : h->GetYMax() * 1.02;
if (h_x0 < x0)
x0 = h_x0;
if (h_x1 > x1)
x1 = h_x1;
if (h_y0 < y0)
y0 = h_y0;
if (h_y1 > y1)
y1 = h_y1;
if (h->GetFirstXgtZero() < firstXgt0)
firstXgt0 = h->GetFirstXgtZero();
if (h->GetFirstYgtZero() < firstYgt0)
firstYgt0 = h->GetFirstYgtZero();
ResetZoomBase();
}

View File

@ -1,106 +0,0 @@
/**
* @author Ian Johnson
* @version 1.0
*/
#include <iostream>
#include <qwt_plot.h>
#include <qwt_scale_div.h>
#include "SlsQt1DPlot.h"
#include "SlsQt1DZoomer.h"
void SlsQt1DZoomer::ResetZoomBase(){
SetZoomBase(x0,y0,x1-x0,y1-y0); //for going between log and nonlog plots
}
void SlsQt1DZoomer::SetZoomBase(double xmin,double ymin,double x_width, double y_width){
if(xIsLog&&xmin<=0){
double xmax = xmin+x_width;
xmin = firstXgt0*0.98;
if(xmax<=xmin) x_width=firstXgt0;
else x_width=xmax-xmin;
}
if(yIsLog&&ymin<=0){
double ymax = ymin+y_width;
ymin = firstYgt0*0.98;
if(ymax<=ymin) y_width=firstYgt0;
else y_width=ymax-ymin;
}
if(plot()){
if(xIsLog){
#if QWT_VERSION < 0x50200
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->lBound();
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->hBound();
#elif QWT_VERSION < 0x060100
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->lowerBound();
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->upperBound();
#else
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom).lowerBound();
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom).upperBound();
#endif
if(xmin_curr<xmin) xmin_curr=xmin;
if(xmax_curr>xmin+x_width) xmax_curr=xmin+x_width;
plot()->setAxisScale(QwtPlot::xBottom,xmin_curr,xmax_curr);
}
if(yIsLog){
#if QWT_VERSION < 0x50200
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->lBound();
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->hBound();
#elif QWT_VERSION < 0x060100
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->lowerBound();
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->upperBound();
#else
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound();
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft).upperBound();
#endif
if(ymin_curr<ymin) ymin_curr=ymin;
if(ymax_curr>ymin+y_width) ymax_curr=ymin+y_width;
plot()->setAxisScale(QwtPlot::yLeft,ymin_curr,ymax_curr);
}
plot()->replot();
}
#if QWT_VERSION<0x060000
setZoomBase(QwtDoubleRect(xmin,ymin,x_width,y_width));
#else
setZoomBase(QRectF(xmin,ymin,x_width,y_width));
#endif
}
void SlsQt1DZoomer::SetZoomBase(SlsQtH1D* h){
x0 = h->GetXMin()<0 ? h->GetXMin()*1.02 : h->GetXMin()/1.02;
x1 = h->GetXMax()<0 ? h->GetXMax()/1.02 : h->GetXMax()*1.02;
y0 = h->GetYMin()<0 ? h->GetYMin()*1.02 : h->GetYMin()/1.02;
y1 = h->GetYMax()<0 ? h->GetYMax()/1.02 : h->GetYMax()*1.02;
firstXgt0 = h->GetFirstXgtZero(); //for log plots
firstYgt0 = h->GetFirstYgtZero(); //for log plots
ResetZoomBase();
}
void SlsQt1DZoomer::ExtendZoomBase(SlsQtH1D* h){
double h_x0 = h->GetXMin()<0 ? h->GetXMin()*1.02 : h->GetXMin()/1.02;
double h_x1 = h->GetXMax()<0 ? h->GetXMax()/1.02 : h->GetXMax()*1.02;
double h_y0 = h->GetYMin()<0 ? h->GetYMin()*1.02 : h->GetYMin()/1.02;
double h_y1 = h->GetYMax()<0 ? h->GetYMax()/1.02 : h->GetYMax()*1.02;
if(h_x0<x0) x0 = h_x0;
if(h_x1>x1) x1 = h_x1;
if(h_y0<y0) y0 = h_y0;
if(h_y1>y1) y1 = h_y1;
if(h->GetFirstXgtZero()<firstXgt0) firstXgt0 = h->GetFirstXgtZero();
if(h->GetFirstYgtZero()<firstYgt0) firstYgt0 = h->GetFirstYgtZero();
ResetZoomBase();
}

View File

@ -0,0 +1,143 @@
/* TODO! short description */
#include "SlsQt2DHist.h"
#include "ansi.h"
#include <cmath>
#include <iostream>
using std::cout;
using std::endl;
SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy,
double ymin, double ymax, double *d, double zmin,
double zmax)
: QwtRasterData() {
x_min = 0;
x_max = 0;
y_min = 0;
y_max = 0;
interp = 0;
nx_array = ny_array = 0;
data = nullptr;
SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d, zmin, zmax);
}
SlsQt2DHist::~SlsQt2DHist() { delete[] data; }
int SlsQt2DHist::GetBinIndex(int bx, int by) {
int b = bx * ny + by;
if (b < 0 || b >= nb) {
cout << "GetBinIndex:: Incorrect indicies bx and by returning overflow "
"bin;"
<< endl;
return nb;
}
return b;
}
int SlsQt2DHist::FindBinIndex(double x, double y) {
return GetBinIndex(int((x - x_min) / x_width), int((y - y_min) / y_width));
}
double SlsQt2DHist::GetBinValue(int bx, int by) {
return data[GetBinIndex(bx, by)];
}
void SlsQt2DHist::SetBinValue(int bx, int by, double v) {
z_mean_has_been_calculated = 0;
data[GetBinIndex(bx, by)] = v;
}
void SlsQt2DHist::SetData(int nbinsx, double xmin, double xmax, int nbinsy,
double ymin, double ymax, double *d, double zmin,
double zmax) {
z_mean_has_been_calculated = 0;
if (xmax < xmin || ymax < ymin)
cout << "Warning input range invalid." << endl;
x_width = (xmax - xmin) / nbinsx;
y_width = (ymax - ymin) / nbinsy;
if (x_min != xmin || x_max != xmax || y_min != ymin || y_max != ymax) {
x_min = xmin;
x_max = xmax;
y_min = ymin;
y_max = ymax;
setInterval(Qt::XAxis, QwtInterval(xmin, xmax));
setInterval(Qt::YAxis, QwtInterval(ymin, ymax));
}
if (nbinsx * nbinsy < 1) {
cout << "Exitting: SlsQt2DHist::SetData() number of bins must be "
"greater than zero."
<< endl;
exit(1);
}
if (nbinsx * nbinsy > nx_array * ny_array) {
delete[] data;
data = new double[nbinsx * nbinsy + 1]; // one for under/overflow bin
nx_array = nbinsx;
ny_array = nbinsy;
}
nx = nbinsx;
ny = nbinsy;
nb = nx * ny;
data[nb] = 0; // set over flow to zero
if (d) {
memcpy(data, d, nb * sizeof(double));
SetMinMax(zmin, zmax);
}
}
void SlsQt2DHist::SetMinMax(double zmin, double zmax) {
/* if(zmin<zmax){ edited out to test*/
if (zmax != -1) {
z_min = zmin;
z_max = zmax;
} else {
z_mean_has_been_calculated = 1;
z_min = data[0];
z_mean = 0;
z_max = data[0];
for (int i = 0; i < nb; i++) {
if (data[i] < z_min)
z_min = data[i];
if (data[i] > z_max)
z_max = data[i];
z_mean += data[i];
}
z_mean /= nb;
if (z_min > 0)
z_min /= 1.02;
else
z_min *= 1.02;
if (z_max > 0)
z_max *= 1.02;
else
z_max /= 1.02;
}
setInterval(Qt::ZAxis, QwtInterval(z_min, z_max));
}
double SlsQt2DHist::GetMean() {
if (!z_mean_has_been_calculated) {
z_mean_has_been_calculated = 1;
z_mean = 0;
for (int i = 0; i < nb; i++)
z_mean += data[i];
z_mean /= nb;
}
return z_mean;
}
double SlsQt2DHist::SetMinimumToFirstGreaterThanZero() {
z_min = fabs(z_max) + 1;
for (int i = 0; i < nb; i++) {
if (data[i] > 0 && data[i] < z_min)
z_min = data[i];
}
setInterval(Qt::ZAxis, QwtInterval(z_min, z_max));
return z_min;
}

View File

@ -1,144 +0,0 @@
/**
* @author Ian Johnson
* @version 1.0
*/
#include "ansi.h"
#include <iostream>
#include <cmath>
#include "SlsQt2DHist.h"
using std::cout;
using std::endl;
SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double* d,double zmin,double zmax):QwtRasterData(){
x_min=0;x_max=0;y_min=0;y_max=0;
interp=0;
nx_array=ny_array=0;data=0;
SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d,zmin,zmax);
}
SlsQt2DHist::~SlsQt2DHist(){if(data) delete [] data;}
int SlsQt2DHist::GetBinIndex(int bx, int by){
int b = bx*ny+by;
if(b<0 || b>=nb){
cout<<"GetBinIndex:: Incorrect indicies bx and by returning overflow bin;"<<endl;
return nb;
}
return b;
}
int SlsQt2DHist::FindBinIndex(double x, double y){
return GetBinIndex(int((x-x_min)/x_width),int((y-y_min)/y_width));
}
double SlsQt2DHist::GetBinValue(int bx,int by){
return data[GetBinIndex(bx,by)];
}
void SlsQt2DHist::SetBinValue(int bx,int by,double v){
z_mean_has_been_calculated = 0;
data[GetBinIndex(bx,by)] = v;
}
void SlsQt2DHist::SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax, double *d,double zmin,double zmax){
z_mean_has_been_calculated = 0;
if(xmax<xmin||ymax<ymin) cout<<"Warning input range invalid."<<endl;
x_width = (xmax - xmin)/nbinsx;
y_width = (ymax - ymin)/nbinsy;
if(x_min!=xmin||x_max!=xmax||y_min!=ymin||y_max!=ymax){
x_min=xmin;x_max=xmax;
y_min=ymin;y_max=ymax;
#if QWT_VERSION<0x060000
setBoundingRect(QRectF(xmin,ymin,x_max-x_min,y_max-y_min));
#else
setInterval( Qt::XAxis,QwtInterval(xmin,xmax));
setInterval( Qt::YAxis,QwtInterval(ymin,ymax));
// setInterval( Qt::ZAxis,QwtInterval(zmin,zmax));
//setInterval( Qt::ZAxis,QwtInterval(0.,1.));
#endif
}
if(nbinsx*nbinsy<1){
cout<<"Exitting: SlsQt2DHist::SetData() number of bins must be greater than zero."<<endl;
exit(1);
}
if(nbinsx*nbinsy>nx_array*ny_array){
if(data) delete [] data;
data = new double [nbinsx*nbinsy+1]; //one for under/overflow bin
nx_array = nbinsx;
ny_array = nbinsy;
}
nx=nbinsx;
ny=nbinsy;
nb=nx*ny;
data[nb]=0;//set over flow to zero
if(d){
memcpy(data,d,nb*sizeof(double));
SetMinMax(zmin,zmax);
}
}
void SlsQt2DHist::SetMinMax(double zmin,double zmax){
/* if(zmin<zmax){ edited out to test*/
if(zmax != -1){
z_min=zmin;
z_max=zmax;
}else{
z_mean_has_been_calculated = 1;
z_min=data[0];
z_mean=0;
z_max=data[0];
for(int i=0;i<nb;i++){
if(data[i]<z_min) z_min=data[i];
if(data[i]>z_max) z_max=data[i];
z_mean+=data[i];
}
z_mean/=nb;
if(z_min>0) z_min/=1.02; else z_min*=1.02;
if(z_max>0) z_max*=1.02; else z_max/=1.02;
}
#if QWT_VERSION<0x060000
;
#else
setInterval( Qt::ZAxis,QwtInterval(z_min,z_max));
#endif
}
double SlsQt2DHist::GetMean(){
if(!z_mean_has_been_calculated){
z_mean_has_been_calculated = 1;
z_mean=0;
for(int i=0;i<nb;i++) z_mean+=data[i];
z_mean/=nb;
}
return z_mean;
}
double SlsQt2DHist::SetMinimumToFirstGreaterThanZero(){
z_min=fabs(z_max)+1;
for(int i=0;i<nb;i++){
if(data[i]>0 && data[i]<z_min) z_min=data[i];
}
#if QWT_VERSION<0x060000
;
#else
setInterval( Qt::ZAxis,QwtInterval(z_min,z_max));
#endif
return z_min;
}

View File

@ -1,15 +1,9 @@
#include "SlsQt2DPlot.h"
#include "ansi.h"
#include <cmath>
#include <iostream>
#include <qlist.h>
#include <qprinter.h>
#include <qtoolbutton.h>
#if QT_VERSION >= 0x040000
#include <qprintdialog.h>
#endif
#include <qwt_color_map.h>
#include <qwt_plot_layout.h>
#include <qwt_plot_panner.h>
@ -19,115 +13,73 @@
#include <qwt_scale_engine.h>
#include <qwt_scale_widget.h>
#if QWT_VERSION >= 0x060100
#define QwtLog10ScaleEngine QwtLogScaleEngine
#endif
#include <cmath>
#include <iostream>
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
isLog = 0;
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);
d_spectrogram = new QwtPlotSpectrogram();
hist = new SlsQt2DHist();
SetupZoom();
SetupColorMap();
#if QWT_VERSION < 0x060000
d_spectrogram->setData(*hist);
#else
d_spectrogram->setData(hist);
#endif
d_spectrogram->attach(this);
plotLayout()->setAlignCanvasToScales(true);
FillTestPlot();
Update();
}
SlsQt2DPlot::~SlsQt2DPlot() = default;
void SlsQt2DPlot::SetTitle(QString title) {
setTitle(title);
}
void SlsQt2DPlot::SetTitle(QString title) { setTitle(title); }
void SlsQt2DPlot::SetXTitle(QString title) {
setAxisTitle(QwtPlot::xBottom, title);
setAxisTitle(QwtPlot::xBottom, title);
}
void SlsQt2DPlot::SetYTitle(QString title) {
setAxisTitle(QwtPlot::yLeft, title);
setAxisTitle(QwtPlot::yLeft, title);
}
void SlsQt2DPlot::SetZTitle(QString title) {
setAxisTitle(QwtPlot::yRight, title);
setAxisTitle(QwtPlot::yRight, title);
}
void SlsQt2DPlot::SetTitleFont(const QFont& f) {
void SlsQt2DPlot::SetTitleFont(const QFont &f) {
QwtText t("");
t.setFont(f);
t.setRenderFlags( Qt::AlignLeft | Qt::AlignVCenter);
t.setRenderFlags(Qt::AlignLeft | Qt::AlignVCenter);
setTitle(t);
}
void SlsQt2DPlot::SetXFont(const QFont& f) {
void SlsQt2DPlot::SetXFont(const QFont &f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::xBottom, t);
}
void SlsQt2DPlot::SetYFont(const QFont& f) {
void SlsQt2DPlot::SetYFont(const QFont &f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::yLeft, t);
}
void SlsQt2DPlot::SetZFont(const QFont& f) {
void SlsQt2DPlot::SetZFont(const QFont &f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::yRight, t);
}
void SlsQt2DPlot::SetupColorMap() {
colorMapLinearScale = myColourMap(0);
#if QWT_VERSION < 0x060000
d_spectrogram->setColorMap(*colorMapLinearScale);
#else
d_spectrogram->setColorMap(colorMapLinearScale);
#endif
colorMapLogScale = myColourMap(1);
#if QWT_VERSION < 0x060000
contourLevelsLinear = new QwtValueList();
for (double level = 0.5; level < 10.0; level += 1.0)
(*contourLevelsLinear) += level;
d_spectrogram->setContourLevels(*contourLevelsLinear);
#else
;
d_spectrogram->setColorMap(myColourMap(0));
for (double level = 0.5; level < 10.0; level += 1.0)
(contourLevelsLinear) += level;
d_spectrogram->setContourLevels(contourLevelsLinear);
#endif
//
#if QWT_VERSION < 0x060000
contourLevelsLog = new QwtValueList();
for (double level = 0.5; level < 10.0; level += 1.0)
(*contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10;
#else
;
for (double level = 0.5; level < 10.0; level += 1.0)
(contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10;
#endif
// A color bar on the right axis
rightAxis = axisWidget(QwtPlot::yRight);
@ -140,14 +92,15 @@ void SlsQt2DPlot::SetupColorMap() {
void SlsQt2DPlot::FillTestPlot(int mode) {
static int nx = 50;
static int ny = 50;
static double *the_data = 0;
if (the_data == 0)
static double *the_data = nullptr;
if (the_data == nullptr)
the_data = new double[nx * ny];
double dmax = sqrt(pow(nx / 2.0 - 0.5, 2) + pow(ny / 2.0 - 0.5, 2));
for (int i = 0; i < nx; i++) {
for (int j = 0; j < ny; j++) {
double d = sqrt(pow(nx / 2.0 - (i + 0.5), 2) + pow(ny / 2.0 - (j + 0.5), 2));
double d = sqrt(pow(nx / 2.0 - (i + 0.5), 2) +
pow(ny / 2.0 - (j + 0.5), 2));
if (mode % 3)
the_data[i + j * nx] = 10 * d / dmax;
@ -167,14 +120,9 @@ void SlsQt2DPlot::SetupZoom() {
zoomer = new SlsQt2DZoomer(canvas());
zoomer->SetHist(hist);
#if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
panner = new QwtPlotPanner(canvas());
panner->setAxisEnabled(QwtPlot::yRight, false);
panner->setMouseButton(Qt::MidButton);
@ -191,37 +139,25 @@ void SlsQt2DPlot::SetupZoom() {
zoomer->setTrackerPen(c);
}
/*void SlsQt2DPlot::CompletelyUnZoom(){
setAxisScale(QwtPlot::xBottom,hist->GetXMin(),hist->GetXMin()+(hist->GetXMax()-hist->GetXMin()));
setAxisScale(QwtPlot::yLeft,hist->GetYMin(),hist->GetYMin()+(hist->GetYMax()-hist->GetYMin()));
zoomer->setZoomBase();
//replot();
}*/
void SlsQt2DPlot::UnZoom(bool replot) {
#if QWT_VERSION < 0x060000
zoomer->setZoomBase(QwtDoubleRect(hist->GetXMin(), hist->GetYMin(), hist->GetXMax() - hist->GetXMin(), hist->GetYMax() - hist->GetYMin()));
#else
zoomer->setZoomBase(QRectF(hist->GetXMin(), hist->GetYMin(), hist->GetXMax() - hist->GetXMin(), hist->GetYMax() - hist->GetYMin()));
#endif
zoomer->setZoomBase(replot); //Call replot for the attached plot before initializing the zoomer with its scales.
zoomer->setZoomBase(QRectF(hist->GetXMin(), hist->GetYMin(),
hist->GetXMax() - hist->GetXMin(),
hist->GetYMax() - hist->GetYMin()));
zoomer->setZoomBase(replot); // Call replot for the attached plot before
// initializing the zoomer with its scales.
// zoomer->zoom(0);
}
void SlsQt2DPlot::SetZoom(double xmin, double ymin, double x_width, double y_width) {
#if QWT_VERSION < 0x060000
zoomer->setZoomBase(QwtDoubleRect(xmin, ymin, x_width, y_width));
#else
void SlsQt2DPlot::SetZoom(double xmin, double ymin, double x_width,
double y_width) {
zoomer->setZoomBase(QRectF(xmin, ymin, x_width, y_width));
#endif
}
void SlsQt2DPlot::DisableZoom(bool disable) {
if (disableZoom != disable) {
disableZoom = disable;
#ifdef VERBOSE
if (disable)
std::cout << "Disabling zoom\n";
@ -230,25 +166,23 @@ void SlsQt2DPlot::DisableZoom(bool disable) {
#endif
if (disable) {
if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
#if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
Qt::NoButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::NoButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::NoButton);
}
if (panner)
panner->setMouseButton(Qt::NoButton);
} else {
if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
#if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
Qt::LeftButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
}
if (panner)
panner->setMouseButton(Qt::MidButton);
@ -256,7 +190,6 @@ void SlsQt2DPlot::DisableZoom(bool disable) {
}
}
void SlsQt2DPlot::SetZMinMax(double zmin, double zmax) {
hist->SetMinMax(zmin, zmax);
}
@ -269,63 +202,40 @@ QwtLinearColorMap *SlsQt2DPlot::myColourMap(QVector<double> colourStops) {
double g[] = {0.00, 0.81, 1.00, 0.20, 0.00};
double b[] = {0.51, 1.00, 0.12, 0.00, 0.00};
QColor c1, c2, c;
c1.setRgbF(r[0], g[0], b[0], 0);
// QColor c1, c2, c;
QColor c2, c;
c2.setRgbF(r[ns - 1], g[ns - 1], b[ns - 1]);
QwtLinearColorMap *copyMap = new QwtLinearColorMap(Qt::lightGray, c2);
for (int is = 0; is < ns - 1; is++) {
c.setRgbF(r[is], g[is], b[is]);
copyMap->addColorStop(colourStops.value(is), c);
copyMap->addColorStop(colourStops[is], c);
}
return copyMap;
}
QwtLinearColorMap *SlsQt2DPlot::myColourMap(int log) {
int ns = 5;
QVector<double> cs1(0);
QVector<double> lcs1(0);
cs1.append(0.);
cs1.append(0.34);
cs1.append(0.61);
cs1.append(0.84);
cs1.append(1.);
QVector<double> cs{0.0, 0.34, 0.61 ,0.84, 1.0};
if (log) {
for (int is = 0; is < ns; is++) {
lcs1.append((pow(10, 2 * cs1.value(is)) - 1) / 99.0);
}
return myColourMap(lcs1);
for (int i = 0; i < cs.size(); ++i)
cs[i] = (pow(10, 2 * cs[i]) - 1) / 99.0;
}
return myColourMap(cs1);
return myColourMap(cs);
}
void SlsQt2DPlot::Update() {
#if QWT_VERSION < 0x060000
rightAxis->setColorMap(d_spectrogram->data().range(), d_spectrogram->colorMap());
#else
if (isLog)
hist->SetMinimumToFirstGreaterThanZero();
const QwtInterval zInterval = d_spectrogram->data()->interval(Qt::ZAxis);
rightAxis->setColorMap(zInterval, myColourMap(isLog));
#endif
if (!zoomer->zoomRectIndex())
UnZoom();
#if QWT_VERSION < 0x060000
setAxisScale(QwtPlot::yRight, d_spectrogram->data().range().minValue(),
d_spectrogram->data().range().maxValue());
#else
//cprintf(MAGENTA, "zmin:%f zmax:%f\n", zInterval.minValue(), zInterval.maxValue());
setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue());
plotLayout()->setAlignCanvasToScales(true);
#endif
replot();
}
void SlsQt2DPlot::SetInterpolate(bool enable) {
@ -338,86 +248,44 @@ void SlsQt2DPlot::SetContour(bool enable) {
Update();
}
void SlsQt2DPlot::SetLogz(bool enable, bool isMin, bool isMax, double min, double max) {
LogZ(enable);
SetZRange(isMin, isMax, min, max);
void SlsQt2DPlot::SetLogz(bool enable, bool isMin, bool isMax, double min,
double max) {
LogZ(enable);
SetZRange(isMin, isMax, min, max);
}
void SlsQt2DPlot::SetZRange(bool isMin, bool isMax, double min, double max){
if(isLog) {
SetZMinimumToFirstGreaterThanZero();
}
void SlsQt2DPlot::SetZRange(bool isMin, bool isMax, double min, double max) {
if (isLog) {
SetZMinimumToFirstGreaterThanZero();
}
// set zmin and zmax
if (isMin || isMax) {
double zmin = (isMin ? min : GetZMinimum());
double zmax = (isMax ? max : GetZMaximum());
SetZMinMax(zmin, zmax);
}
// set zmin and zmax
if (isMin || isMax) {
double zmin = (isMin ? min : GetZMinimum());
double zmax = (isMax ? max : GetZMaximum());
SetZMinMax(zmin, zmax);
}
Update();
Update();
}
void SlsQt2DPlot::LogZ(bool on) {
if (on) {
isLog = 1;
//if(hist->GetMinimum()<=0) hist->SetMinimumToFirstGreaterThanZero();
#if QWT_VERSION < 0x060000
d_spectrogram->setColorMap(*colorMapLogScale);
#else
d_spectrogram->setColorMap(myColourMap(isLog));
#endif
setAxisScaleEngine(QwtPlot::yRight, new QwtLog10ScaleEngine);
#if QWT_VERSION < 0x060000
d_spectrogram->setContourLevels(*contourLevelsLog);
#else
setAxisScaleEngine(QwtPlot::yRight, new QwtLogScaleEngine);
d_spectrogram->setContourLevels(contourLevelsLog);
#endif
} else {
isLog = 0;
#if QWT_VERSION < 0x060000
d_spectrogram->setColorMap(*colorMapLinearScale);
#else
d_spectrogram->setColorMap(myColourMap(isLog));
#endif
setAxisScaleEngine(QwtPlot::yRight, new QwtLinearScaleEngine);
#if QWT_VERSION < 0x060000
d_spectrogram->setContourLevels(*contourLevelsLinear);
#else
d_spectrogram->setContourLevels(contourLevelsLinear);
#endif
}
Update();
}
void SlsQt2DPlot::showSpectrogram(bool on) {
// static int io=0;
// FillTestPlot(io++);
d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, on);
d_spectrogram->setDefaultContourPen(on ? QPen() : QPen(Qt::NoPen));
Update();
}
/*
void SlsQt2DPlot::printPlot(){
QPrinter printer;
printer.setOrientation(QPrinter::Landscape);
#if QT_VERSION < 0x040000
printer.setColorMode(QPrinter::Color);
printer.setOutputFileName("spectrogram.ps");
if (printer.setup())
#else
printer.setOutputFileName("spectrogram.pdf");
QPrintDialog dialog(&printer);
if ( dialog.exec() )
#endif
{
print(printer);
}
}
*/
}

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