1
1
from typing import ClassVar
2
2
3
+ from mxcubecore import HardwareRepository as HWR
3
4
from mxcubecore .HardwareObjects .abstract import AbstractDetector
4
5
5
6
from mxcubeweb .core .adapter .adapter_base import AdapterBase
6
7
from mxcubeweb .core .models .configmodels import ResourceHandlerConfigModel
7
8
8
9
resource_handler_config = ResourceHandlerConfigModel (
9
- name = "detector_test" ,
10
- url_prefix = "/mxcube/api/v0.1/detectortest" ,
11
- attributes = ["data" ],
10
+ commands = ["display_image" ],
11
+ attributes = ["data" , "get_value" ],
12
12
)
13
13
14
14
@@ -23,8 +23,29 @@ def __init__(self, ho, role, app):
23
23
super ().__init__ (ho , role , app , resource_handler_config )
24
24
ho .connect ("stateChanged" , self ._state_change )
25
25
26
+ def get_value (self ) -> dict :
27
+ """
28
+ Get the file suffix of the data files.
29
+ """
30
+ return {"fileSuffix" : HWR .beamline .detector .get_property ("file_suffix" , "?" )}
31
+
26
32
def _state_change (self , * args , ** kwargs ):
27
33
self .state_change (* args , ** kwargs )
28
34
29
35
def state (self ):
30
36
return self ._ho .get_state ().name .upper ()
37
+
38
+ def display_image (self , path : str , img_num ) -> dict :
39
+ """
40
+ Notify ADXV and/or Braggy of the image to display.
41
+ """
42
+ res = {"path" : "" , "img" : 0 }
43
+
44
+ if path :
45
+ fpath , img = HWR .beamline .detector .get_actual_file_path (path , img_num )
46
+ HWR .beamline .collect .adxv_notify (fpath , img )
47
+ fpath = HWR .beamline .session .get_path_with_proposal_as_root (fpath )
48
+
49
+ res = {"path" : fpath , "img_num" : img_num }
50
+
51
+ return res
0 commit comments