forked from syncope/lavue
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLavueController
executable file
·828 lines (736 loc) · 31.3 KB
/
LavueController
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# ############################################################################
# license :
# ============================================================================
#
# File : LavueController.py
#
# Project : Lavue Controller
#
# This file is part of Tango device class.
#
# Tango is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Tango is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Tango. If not, see <http://www.gnu.org/licenses/>.
#
#
# $Author : jan.kotanski$
#
# $Revision : $
#
# $Date : $
#
# $HeadUrl : $
# ============================================================================
# This file is generated by POGO
# (Program Obviously used to Generate tango Object)
# ############################################################################
try:
import tango
except Exception:
import PyTango as tango
import sys
import json
__all__ = ["LavueController", "LavueControllerClass", "main"]
__docformat__ = 'restructuredtext'
if sys.version_info > (3,):
unicode = str
def dummy_callback(*args, **kwargs):
pass
class LavueController (tango.LatestDeviceImpl):
"""tango server to change lavue setting in real time"""
def __init__(self, cl, name):
tango.LatestDeviceImpl.__init__(self, cl, name)
self.debug_stream("In __init__()")
self.current_scalar_aliases = []
self.current_spectrum_aliases = []
self.current_rois_aliases = []
self.current_attributes = set()
self.ROITypes = ["rectangle", "ellipse"]
LavueController.init_device(self)
def __unsubscribe(self):
if hasattr(self, "__eids"):
for eid in self.__eids.values():
if eid is not None:
self.unsubscribe_event(eid)
self.__eids.clear()
def __push_event(self, atname, data):
if atname not in self.DataReadyEventAttributes:
if atname not in self.__eids:
self.__eids[atname] = None
elif self.__eids[atname] is None:
self.__eids[atname] = self.__dp.subscribe_event(
atname, tango.EventType.CHANGE_EVENT,
dummy_callback)
self.push_change_event(atname, data)
else:
self.push_data_ready_event(atname, 0)
def delete_device(self):
self.debug_stream("In delete_device()")
self.__unsubscribe()
def init_device(self):
self.debug_stream("In init_device()")
self.get_device_properties(self.get_device_class())
self.attr_BeamCenterX_read = 0.0
self.attr_BeamCenterY_read = 0.0
self.attr_DetectorDistance_read = 0.0
self.attr_DetectorROIs_read = ""
self.attr_DetectorROIsValues_read = ""
self.attr_DetectorROIsParams_read = ""
self.attr_Energy_read = 0.0
self.attr_LavueState_read = ""
self.attr_LavueState_write = ""
self.attr_PixelSizeX_read = 0.0
self.attr_PixelSizeY_read = 0.0
self.attr_ToolResults_read = ""
self.__attrname_list = [
"BeamCenterX",
"BeamCenterY",
"DetectorDistance",
"DetectorROIs",
"DetectorROIsValues",
"DetectorROIsParams",
"Energy",
"LavueState",
"PixelSizeX",
"PixelSizeY",
"ToolResults"
]
for atname in self.__attrname_list:
self.set_change_event(atname, True, False)
if hasattr(self, "set_data_ready_event"):
self.set_data_ready_event(atname, True)
else:
self.get_device_attr().\
get_attr_by_name(atname).set_data_ready_event(True)
self.attr_DetectorROIs_read = "{}"
self.attr_DetectorROIsValues_read = "{}"
self.requested_scalar_aliases = []
self.requested_spectrum_aliases = []
self.requested_rois_aliases = []
if not self.DynamicROIsValues and self.current_scalar_aliases:
for alias in self.current_scalar_aliases:
if alias not in self.requested_scalar_aliases:
aalias = ("%sSum" % alias) \
if alias != "__Null__" else "Sum"
if aalias not in self.ROIAttributesNames:
self.remove_attribute(str(aalias))
if aalias in self.current_attributes:
self.current_attributes = \
set([at for at in self.current_attributes
if at != aalias])
self.current_scalar_aliases = []
if not self.DynamicROIsValues and self.current_spectrum_aliases:
for alias in self.current_spectrum_aliases:
if alias not in self.requested_spectrum_aliases:
aalias = ("%sSums" % alias) \
if alias != "__Null__" else "Sums"
if aalias not in self.ROIAttributesNames:
self.remove_attribute(str(aalias))
if aalias in self.current_attributes:
self.current_attributes = \
set([at for at in self.current_attributes
if at != aalias])
self.current_spectrum_aliases = []
if not self.DynamicROIs and not self.FloatDynamicROIs \
and self.current_rois_aliases:
for alias in self.current_rois_aliases:
aalias = "%sROI" % alias \
if alias != "__Null__" else "ROI"
if aalias not in self.ROIAttributesNames:
self.remove_attribute(str(aalias))
if aalias in self.current_attributes:
self.current_attributes = \
set([at for at in self.current_attributes
if at != aalias])
self.current_rois_aliases = []
attrs = []
for alias in list(self.current_attributes):
if alias not in self.ROIAttributesNames:
self.remove_attribute(str(alias))
else:
attrs.append(alias)
self.current_attributes = set(attrs)
self.initialize_dynamic_attributes()
self.__unsubscribe()
self.__eids = {}
self.__dp = tango.DeviceProxy(self.get_name())
def always_executed_hook(self):
self.debug_stream("In always_excuted_hook()")
# -------------------------------------------------------------------------
# LavueController read/write attribute methods
# -------------------------------------------------------------------------
def read_BeamCenterX(self, attr):
self.debug_stream("In read_BeamCenterX()")
attr.set_value(self.attr_BeamCenterX_read)
def write_BeamCenterX(self, attr):
self.debug_stream("In write_BeamCenterX()")
data = attr.get_write_value()
if self.attr_BeamCenterX_read != float(data):
self.attr_BeamCenterX_read = float(data)
self.__push_event("BeamCenterX", self.attr_BeamCenterX_read)
def read_BeamCenterY(self, attr):
self.debug_stream("In read_BeamCenterY()")
attr.set_value(self.attr_BeamCenterY_read)
def write_BeamCenterY(self, attr):
self.debug_stream("In write_BeamCenterY()")
data = attr.get_write_value()
if self.attr_BeamCenterY_read != float(data):
self.attr_BeamCenterY_read = float(data)
self.__push_event("BeamCenterY", self.attr_BeamCenterY_read)
def read_PixelSizeX(self, attr):
self.debug_stream("In read_PixelSizeX()")
attr.set_value(self.attr_PixelSizeX_read)
def write_PixelSizeX(self, attr):
self.debug_stream("In write_PixelSizeX()")
data = attr.get_write_value()
if self.attr_PixelSizeX_read != float(data):
self.attr_PixelSizeX_read = float(data)
self.__push_event("PixelSizeX", self.attr_PixelSizeX_read)
def read_PixelSizeY(self, attr):
self.debug_stream("In read_PixelSizeY()")
attr.set_value(self.attr_PixelSizeY_read)
def write_PixelSizeY(self, attr):
self.debug_stream("In write_PixelSizeY()")
data = attr.get_write_value()
if self.attr_PixelSizeY_read != float(data):
self.attr_PixelSizeY_read = float(data)
self.__push_event("PixelSizeY", self.attr_PixelSizeY_read)
def read_DetectorDistance(self, attr):
self.debug_stream("In read_DetectorDistance()")
attr.set_value(self.attr_DetectorDistance_read)
def write_DetectorDistance(self, attr):
self.debug_stream("In write_DetectorDistance()")
data = attr.get_write_value()
#
if self.attr_DetectorDistance_read != float(data):
self.attr_DetectorDistance_read = float(data)
self.__push_event(
"DetectorDistance", self.attr_DetectorDistance_read)
def read_LavueState(self, attr):
self.debug_stream("In read_LavueState()")
attr.set_value(self.attr_LavueState_read)
def write_LavueState(self, attr):
self.debug_stream("In write_LavueState()")
data = attr.get_write_value()
detcnf = json.loads(data)
for key, value in detcnf.items():
if not isinstance(key, (str, unicode)):
raise Exception(
"state key %s is not a string" % str(key))
if "__timestamp__" in detcnf.keys():
self.attr_LavueState_read = data
else:
self.attr_LavueState_write = data
self.__push_event(
"LavueState", self.attr_LavueState_write)
def read_DetectorROIs(self, attr):
self.debug_stream("In read_DetectorROIs()")
attr.set_value(self.attr_DetectorROIs_read)
def write_DetectorROIs(self, attr):
self.debug_stream("In write_DetectorROIs()")
data = attr.get_write_value()
detrois = json.loads(data)
for det, rois in detrois.items():
if not isinstance(det, (str, unicode)):
raise Exception(
"ROI name %s is not a string" % str(det))
if not isinstance(rois, (list)):
raise Exception(
"ROI %s is not a double list" % str(det))
for roi in rois:
if isinstance(roi, (list)):
if len(roi) not in [4, 5]:
raise Exception(
"ROI %s len is not 4 or 5" % str(det))
for cr in roi:
float(cr)
elif isinstance(roi, (dict)):
if "bounds" not in roi:
raise Exception(
"ROI bounds of %s not defined" % str(det))
if not isinstance(roi["bounds"], (list)):
raise Exception(
"ROI %s is written in an unknown format"
% str(det))
if len(roi["bounds"]) not in [4, 5]:
raise Exception(
"ROI %s len is not 4 or 5" % str(det))
for cr in roi["bounds"]:
float(cr)
if "type" in roi:
if roi["type"] not in self.ROITypes:
raise Exception(
"ROI type %s for %s is unknown" % (
roi["type"], str(det)))
else:
raise Exception(
"ROI %s is written in an unknown format" % str(det))
if self.DynamicROIs or self.FloatDynamicROIs:
self.requested_rois_aliases = []
for det, rois in detrois.items():
self.requested_rois_aliases.append(det.title())
if self.attr_DetectorROIs_read != data:
self.attr_DetectorROIs_read = data
if self.DynamicROIs or self.FloatDynamicROIs:
self.initialize_dynamic_attributes()
self.__push_event(
"DetectorROIs", self.attr_DetectorROIs_read)
def read_ToolResults(self, attr):
self.debug_stream("In read_ToolResults()")
attr.set_value(self.attr_ToolResults_read)
def write_ToolResults(self, attr):
self.debug_stream("In write_ToolResults()")
data = attr.get_write_value()
_ = json.loads(data)
if self.attr_ToolResults_read != data:
self.attr_ToolResults_read = data
self.__push_event("ToolResults", self.attr_ToolResults_read)
def read_DetectorROIsValues(self, attr):
self.debug_stream("In read_DetectorROIsValues()")
attr.set_value(self.attr_DetectorROIsValues_read)
def write_DetectorROIsValues(self, attr):
self.debug_stream("In write_DetectorROIsValues()")
data = attr.get_write_value()
detrois = json.loads(data)
for det, rois in detrois.items():
if not isinstance(det, (str, unicode)):
raise Exception(
"ROI name %s is not a string" % str(det))
if not isinstance(rois, (list)):
raise Exception(
"ROI %s is not a double list" % str(det))
for vroi in rois:
if vroi is not None:
float(vroi)
if self.DynamicROIsValues:
self.requested_scalar_aliases = []
self.requested_spectrum_aliases = []
for det, rois in detrois.items():
if len(rois) == 1:
self.requested_scalar_aliases.append(det.title())
elif len(rois) > 1:
self.requested_spectrum_aliases.append(det.title())
if self.attr_DetectorROIsValues_read != data:
self.attr_DetectorROIsValues_read = data
if self.DynamicROIsValues:
self.initialize_dynamic_attributes()
self.__push_event(
"DetectorROIsValues", self.attr_DetectorROIsValues_read)
def read_DetectorROIsParams(self, attr):
self.debug_stream("In read_DetectorROIsParams()")
attr.set_value(self.attr_DetectorROIsParams_read)
def write_DetectorROIsParams(self, attr):
self.debug_stream("In write_DetectorROIsParams()")
data = attr.get_write_value()
if self.attr_DetectorROIsParams_read != str(data):
self.attr_DetectorROIsParams_read = str(data)
self.__push_event(
"DetectorROIsParams", self.attr_DetectorROIsParams_read)
def read_Energy(self, attr):
self.debug_stream("In read_Energy()")
attr.set_value(self.attr_Energy_read)
def write_Energy(self, attr):
self.debug_stream("In write_Energy()")
data = attr.get_write_value()
if self.attr_Energy_read != float(data):
self.attr_Energy_read = float(data)
self.__push_event("Energy", self.attr_Energy_read)
def read_ScalarDynamicAttr(self, attr):
self.debug_stream("In read_ScalarDynamicAttr()")
name = attr.get_name()[:-3]
if not name:
name = "__null__"
detrois = json.loads(self.attr_DetectorROIsValues_read)
if name in detrois.keys() and detrois[name]:
attr.set_value(detrois[name][0])
else:
name = ("%s%s" % (name[0].lower(), name[1:]))
if name in detrois.keys() and detrois[name]:
attr.set_value(detrois[name][0])
else:
attr.set_value(-1)
def read_SpectrumDynamicAttr(self, attr):
self.debug_stream("In read_SpectrumDynamicAttr()")
name = attr.get_name()[:-4]
if not name:
name = "__null__"
detrois = json.loads(self.attr_DetectorROIsValues_read)
if name in detrois.keys():
attr.set_value(detrois[name])
else:
name = ("%s%s" % (name[0].lower(), name[1:]))
if name in detrois.keys():
attr.set_value(detrois[name])
else:
attr.set_value([])
def read_ROIsDynamicAttr(self, attr):
self.debug_stream("In read_ROIsDynamicAttr()")
name = attr.get_name()[:-3]
if not name:
name = "__null__"
detrois = json.loads(self.attr_DetectorROIs_read)
if name not in detrois.keys():
name = ("%s%s" % (name[0].lower(), name[1:]))
dtrois = []
if name in detrois.keys():
for roi in detrois[name]:
if isinstance(roi, list):
if self.FloatDynamicROIs:
dtrois.extend([float(it) for it in roi])
else:
dtrois.extend([int(round(it)) for it in roi])
elif isinstance(roi, dict) and "bounds" in roi \
and isinstance(roi["bounds"]):
if self.FloatDynamicROIs:
dtrois.extend([float(it) for it in roi["bounds"]])
else:
dtrois.extend([int(round(it)) for it in roi["bounds"]])
attr.set_value(dtrois)
def initialize_dynamic_rois_sums_attributes(self):
""" initialize rois dynamic attributes
"""
if self.current_scalar_aliases != self.requested_scalar_aliases or \
self.current_spectrum_aliases != \
self.requested_spectrum_aliases or \
self.ROIAttributesNames:
for alias in self.current_scalar_aliases:
if alias not in self.requested_scalar_aliases:
aalias = ("%sSum" % alias) \
if alias != "__Null__" else "Sum"
if aalias not in self.ROIAttributesNames:
self.remove_attribute(str(aalias))
for alias in self.current_spectrum_aliases:
if alias not in self.requested_spectrum_aliases:
aalias = ("%sSums" % alias) \
if alias != "__Null__" else "Sums"
if aalias not in self.ROIAttributesNames:
self.remove_attribute(str(aalias))
for alias in self.requested_scalar_aliases:
if alias not in self.current_scalar_aliases:
myAttr = tango.Attr(
str("%sSum" % alias) if alias != "__Null__" else "Sum",
tango.DevDouble, tango.READ)
self.add_attribute(
myAttr, LavueController.read_ScalarDynamicAttr,
None, None)
for alias in self.requested_spectrum_aliases:
if alias not in self.current_spectrum_aliases:
myAttr = tango.SpectrumAttr(
str("%sSums" % alias)
if alias != "__Null__" else "Sums",
tango.DevDouble,
tango.AttrWriteType.READ, 4096)
self.add_attribute(
myAttr, LavueController.read_SpectrumDynamicAttr,
None, None)
for alias in self.ROIAttributesNames:
if alias.endswith("Sum"):
salias = alias[:-3]
if not salias:
salias = "__Null__"
if salias not in self.current_scalar_aliases:
myAttr = tango.Attr(
str(alias),
tango.DevDouble, tango.READ)
self.add_attribute(
myAttr, LavueController.read_ScalarDynamicAttr,
None, None)
self.current_attributes.add(str(alias))
if alias.endswith("Sums"):
salias = alias[:-3]
if not salias:
salias = "__Null__"
if salias not in self.current_spectrum_aliases:
myAttr = tango.SpectrumAttr(
str(alias), tango.DevDouble,
tango.AttrWriteType.READ, 4096)
self.add_attribute(
myAttr,
LavueController.read_SpectrumDynamicAttr,
None, None)
self.current_attributes.add(str(alias))
self.current_scalar_aliases = self.requested_scalar_aliases
self.current_spectrum_aliases = self.requested_spectrum_aliases
def initialize_dynamic_rois_attributes(self):
""" initialize rois dynamic attributes
"""
if self.current_rois_aliases != \
self.requested_rois_aliases or self.ROIAttributesNames:
for alias in self.current_rois_aliases:
if alias not in self.requested_rois_aliases:
aalias = "%sROI" % alias \
if alias != "__Null__" else "ROI"
if aalias not in self.ROIAttributesNames:
self.remove_attribute(str(aalias))
if self.FloatDynamicROIs:
dynamicROIType = tango.DevLong
else:
dynamicROIType = tango.DevDouble
for alias in self.requested_rois_aliases:
if alias not in self.current_rois_aliases:
myAttr = tango.SpectrumAttr(
str("%sROI" % alias)
if alias != "__Null__" else "ROI",
dynamicROIType,
tango.AttrWriteType.READ, 4096)
self.add_attribute(
myAttr, LavueController.read_ROIsDynamicAttr,
None, None)
for alias in self.ROIAttributesNames:
if alias.endswith("ROI"):
salias = alias[:-3]
if not salias:
salias = "__Null__"
if salias not in self.current_rois_aliases:
myAttr = tango.SpectrumAttr(
str(alias), dynamicROIType,
tango.AttrWriteType.READ, 4096)
self.add_attribute(
myAttr, LavueController.read_ROIsDynamicAttr,
None, None)
self.current_attributes.add(str(alias))
self.current_rois_aliases = self.requested_rois_aliases
def initialize_dynamic_attributes(self):
self.debug_stream("In initialize_dynamic_attributes()")
# Example to add dynamic attributes
# Copy inside the folowing protected area to instanciate at startup.
""" For Attribute ScalarDynamicAttr
myScalarDynamicAttr = tango.Attr(
'MyScalarDynamicAttr', tango.DevDouble, tango.READ)
self.add_attribute(
myScalarDynamicAttr,LavueController.read_ScalarDynamicAttr,
None, None)
self.attr_ScalarDynamicAttr_read = 0.0
"""
""" For Attribute SpectrumDynamicAttr
mySpectrumDynamicAttr = tango.SpectrumAttr(
'MySpectrumDynamicAttr', tango.DevDouble, tango.READ, 4096)
self.add_attribute(mySpectrumDynamicAttr,
LavueController.read_SpectrumDynamicAttr, None, None)
self.attr_SpectrumDynamicAttr_read = [0.0]
"""
self.initialize_dynamic_rois_sums_attributes()
self.initialize_dynamic_rois_attributes()
def read_attr_hardware(self, data):
self.debug_stream("In read_attr_hardware()")
# -------------------------------------------------------------------------
# LavueController command methods
# -------------------------------------------------------------------------
def dev_state(self):
""" This command gets the device state
(stored in its device_state data member) and returns it to the caller.
:return: Device state
:rtype: tango.CmdArgType.DevState
"""
self.debug_stream("In dev_state()")
argout = tango.DevState.UNKNOWN
argout = tango.DevState.ON
return argout
if argout != tango.DevState.ALARM:
tango.LatestDeviceImpl.dev_state(self)
return self.get_state()
def dev_status(self):
""" This command gets the device status
(stored in its device_status data member)
and returns it to the caller.
:return: Device status
:rtype: tango.ConstDevString
"""
self.debug_stream("In dev_status()")
self.argout = "State is ON"
self.set_status(self.argout)
self.__status = tango.LatestDeviceImpl.dev_status(self)
return self.__status
class LavueControllerClass(tango.DeviceClass):
# -------- Add you global class variables here --------------------------
def dyn_attr(self, dev_list):
"""Invoked to create dynamic attributes for the given devices.
Default implementation calls
:meth:`LavueController.initialize_dynamic_attributes` for each device
:param dev_list: list of devices
:type dev_list: :class:`tango.DeviceImpl`"""
for dev in dev_list:
try:
dev.initialize_dynamic_attributes()
except Exception:
import traceback
dev.warn_stream("Failed to initialize dynamic attributes")
dev.debug_stream("Details: " + traceback.format_exc())
# Class Properties
class_property_list = {
}
# Device Properties
device_property_list = {
'DynamicROIs':
[tango.DevBoolean,
"create dynamically Attributes for ROIs aliases "
"with their (int) bounds",
[True]],
'FloatDynamicROIs':
[tango.DevBoolean,
"create dynamically Attributes for ROIs aliases "
"with their float bounds",
[False]],
'DynamicROIsValues':
[tango.DevBoolean,
"create dynamically Attributes for ROIs aliases with their sums",
[True]],
'ROIAttributesNames':
[tango.DevVarStringArray,
"fixed ROI attributes names, They should ends with ROI, Sum or Sums",
[]],
'DataReadyEventAttributes':
[tango.DevVarStringArray,
"Names of attributes for which push_data_ready_event is called "
"instead of push_change_event",
["ToolResults"]],
}
# Command definitions
cmd_list = {
}
# Attribute definitions
attr_list = {
'BeamCenterX':
[[tango.DevDouble,
tango.SCALAR,
tango.READ_WRITE],
{
'label': "beam center x",
'unit': "pixels",
'abs_change': "0.0001",
'Memorized': "true"
}],
'BeamCenterY':
[[tango.DevDouble,
tango.SCALAR,
tango.READ_WRITE],
{
'label': "beam center y",
'unit': "pixels",
'abs_change': "0.0001",
'Memorized': "true"
}],
'DetectorDistance':
[[tango.DevDouble,
tango.SCALAR,
tango.READ_WRITE],
{
'label': "detector distance",
'unit': "mm",
'abs_change': "0.0001",
'Memorized': "true"
}],
'DetectorROIs':
[[tango.DevString,
tango.SCALAR,
tango.READ_WRITE],
{
'label': "detector ROIs",
'description': "json dictionary with detector ROIs, e.g. "
"{\"pilatusroi1\": [[26, 15, 232, 65]], "
"\"lambdarois\": [[54, 78, 102, 204], [10, 20, 40, 50]]}",
'Display level': tango.DispLevel.EXPERT,
'Memorized': "true"
}],
'ToolResults':
[[tango.DevString,
tango.SCALAR,
tango.READ_WRITE],
{
'label': "tool results",
'description': "json dictionary with tool results",
'Display level': tango.DispLevel.EXPERT,
'Memorized': "false"
}],
'DetectorROIsValues':
[[tango.DevString,
tango.SCALAR,
tango.READ_WRITE],
{
'label': "detector ROIs values",
'description':
"json dictionary with detector ROIs values, e.g. "
"{\"pilatusroi1\": [26.3], \"lambdarois\": [54.3, 434.30]]}",
'Memorized': "true"
}],
'DetectorROIsParams':
[[tango.DevString,
tango.SCALAR,
tango.READ_WRITE],
{
'label': "detector ROIs parameters",
'description': "json dictionary with detector ROIs "
"parameters, e.g. {\"transpose\": False, "
"\"flip-lr\": True, \"flip-ud\": False}",
'Memorized': "true"
}],
'Energy':
[[tango.DevDouble,
tango.SCALAR,
tango.READ_WRITE],
{
'label': "beam energy",
'unit': "eV",
'abs_change': "0.0001",
'Memorized': "true"
}],
'PixelSizeX':
[[tango.DevDouble,
tango.SCALAR,
tango.READ_WRITE],
{
'label': "pixel x-size",
'unit': "um",
'description': "pixel x- size in micrometers",
'abs_change': "0.0001",
'Memorized': "true"
}],
'PixelSizeY':
[[tango.DevDouble,
tango.SCALAR,
tango.READ_WRITE],
{
'label': "pixel y-size",
'unit': "um",
'description': "pixel y- size in micrometers",
'abs_change': "0.0001",
'Memorized': "true"
}],
'LavueState':
[[tango.DevString,
tango.SCALAR,
tango.READ_WRITE],
{
'label': "Lavue State",
'description': "json dictionary with Lavue State "
"configuration, "
"e.g. {\"source\": \"hidra\", "
"\"configuration\":\"hasodet.desy.de\"}",
'Display level': tango.DispLevel.EXPERT,
# 'Memorized': "true"
}],
}
def main():
try:
py = tango.Util(sys.argv)
py.add_class(LavueControllerClass, LavueController, 'LavueController')
U = tango.Util.instance()
U.server_init()
U.server_run()
except tango.DevFailed as e:
print('-------> Received a DevFailed exception: %s' % e)
except Exception as e:
print('-------> An unforeseen exception occured.... %s' % e)
if __name__ == '__main__':
main()