Sequence diagrams#
The sequence diagrams show how the NeXus Data Writer, the Configuration Server and the Selector Server work together, and how the data of the datasources described in NXDL extensions for data sources are recorded.
System overview#
The servers and programs of NeXDaTaS and their connections. Blissdata scans are scans published to blissdata, by BLISS or by the blissdata publisher of Sardana.
flowchart TB
User(["User / beamline staff"])
GUI["nxselector<br/>Component Selector"]
Sel["NXSRecSelector<br/>Selector Server"]
CS["NXSConfigServer<br/>Configuration Server"]
CDB[("MySQL: components<br/>and datasources")]
Sardana["Sardana<br/>with NeXus recorder"]
BLISS["BLISS session"]
W["NXSDataWriter<br/>Data Writer"]
BD[("blissdata")]
BW["NXSBlissWriter"]
FW["FIOBlissWriter"]
FIO[("FIO files")]
HW["Hardware servers<br/>Tango / Sardana / EPICS"]
DB[("Databases")]
Exp["Experiment hardware<br/>and detectors"]
Storage[("NeXus files")]
User --> GUI
User --> Sardana
User --> BLISS
GUI --> Sel
Sel <--> CS
CS <--> CDB
Sel -- "XML configuration" --> Sardana
Sel -- "XML configuration" --> BLISS
Sardana -- "commands,<br/>client data" --> W
BLISS -- "publishes<br/>scans" --> BD
Sardana -. "publishes scans<br/>(blissdata publisher)" .-> BD
BD -- "blissdata<br/>scans" --> BW
BD -- "blissdata<br/>scans" --> FW
FW --> FIO
Sardana -- "control" --> HW
BLISS -- "control" --> HW
HW --> Exp
W -- "reads" --> HW
W --> DB
W --> Storage
BW --> Storage
Exp -- "detector files,<br/>linked" --> Storage
Recording a scan#
A Sardana scan with the NeXus recorder (sardana-nxs-recorder). At the start of the scan, the recorder gets the XML configuration of the selected components from the Selector Server (NXSRecSelector), which creates it with the Configuration Server (NXSConfigServer)
sequenceDiagram
participant MS as MacroServer
participant Rec as NeXus recorder
participant Sel as NXSRecSelector
participant CS as NXSConfigServer
Note over MS: scan macro,<br/>e.g. ascan
MS->>Rec: startRecordList
Rec->>Sel: fetchProfile,<br/>importMntGrp / updateMntGrp
Rec->>Sel: createDynamicComponent,<br/>updateConfigVariables
Rec->>Sel: createWriterConfiguration<br/>(components)
Sel->>CS: CreateConfiguration<br/>(components)
CS-->>Sel: XMLString
Sel-->>Rec: XML configuration
Then it writes the scan data with the Data Writer (NXSDataWriter). The states of the Data Writer are given in brackets.
sequenceDiagram
participant MS as MacroServer
participant Rec as NeXus recorder
participant W as NXSDataWriter
participant Sel as NXSRecSelector
Rec->>W: FileName, OpenFile<br/>[ON to OPEN]
Rec->>W: XMLSettings =<br/>XML configuration
Rec->>W: JSONRecord =<br/>INIT client data
Rec->>W: OpenEntry<br/>[OPEN to EXTRACT]
Note over W: creates the NeXus tree,<br/>writes INIT data
loop every scan point
MS->>Rec: addRecord
Rec->>W: Record<br/>(JSON client data)
Note over W: appends STEP data
end
MS->>Rec: endRecordList
Rec->>W: JSONRecord =<br/>FINAL client data
Rec->>W: CloseEntry<br/>[EXTRACT to OPEN]
Note over W: writes FINAL data,<br/>creates virtual datasets
Rec->>W: CloseFile<br/>[OPEN to ON]
Rec->>Sel: removeDynamicComponent
OpenEntryAsynch, RecordAsynch and CloseEntryAsynch do the same
in the background, the Data Writer is in the RUNNING state until they
finish.
Creating the configuration#
The Configuration Server stores components and datasources in a MySQL
database. CreateConfiguration merges the components into one XML
configuration.
sequenceDiagram
participant Sel as NXSRecSelector
participant CS as NXSConfigServer
participant DB as MySQL database
Sel->>CS: Variables, STEPDataSources,<br/>LinkDataSources,<br/>ExtraLinkDataSources,<br/>CanFailDataSources
Sel->>CS: CreateConfiguration(components)
CS->>DB: components,<br/>their dependent components<br/>and datasources
DB-->>CS: XML of components<br/>and datasources
Note over CS: replaces $var.name by Variables
Note over CS: replaces $datasources.name<br/>by datasource XML
Note over CS: merges the components,<br/>switches STEPDataSources to STEP,<br/>adds links of LinkDataSources to NXdata,<br/>sets canfail of CanFailDataSources
CS-->>Sel: XMLString
Recording data#
The Data Writer reads the data of the datasources when their strategies
apply, i.e. INIT data in OpenEntry, STEP data in every Record
and FINAL data in CloseEntry. Datasources of one strategy are read in
parallel by a thread pool. CLIENT data are taken from the JSONRecord
attribute or from the JSON argument of Record.
sequenceDiagram
participant Rec as Client,<br/>e.g. NeXus recorder
participant W as NXSDataWriter
participant T as Tango servers
participant D as Databases
Rec->>W: Record(JSON client data)
par TANGO datasources
W->>T: read attributes,<br/>commands, properties
T-->>W: values
and DB datasources
W->>D: queries
D-->>W: values
and CLIENT datasources
Note over W: values from the JSON client data
end
Note over W: PYEVAL datasources evaluate<br/>their scripts with the values<br/>of their datasources
Note over W: writes the values,<br/>STEP fields grow by one record
W-->>Rec: done
A datasource with canfail="true" in its strategy does not stop the
recording when it cannot be read, the value is replaced by the maximum
value of its type.
Recording a scan with h5maps#
Scans published to blissdata can carry h5maps, i.e. JSON descriptions of the HDF5 tree of their files, which refer to the data streams of the scan. The file is then written from blissdata, e.g. by blisswriter or NXSBlissWriter, while the NXS servers only describe it.
With senv BlissdataH5Map nxs the NeXus recorder of Sardana runs the Data
Writer in its h5map mode: the writer builds the NeXus tree from the XML
configuration in memory and exports it to h5maps (the h5map writer of
nxstools) instead of writing the file.
sequenceDiagram
participant MS as MacroServer<br/>(blissdata publisher)
participant Rec as NeXus recorder
participant W as Data Writer<br/>(h5map mode)
participant BD as blissdata
participant FW as blisswriter or<br/>NXSBlissWriter
MS->>Rec: h5maps of the scan?
Rec->>W: OpenEntry
Note over W: builds the tree in memory,<br/>reads INIT data
W-->>Rec: h5maps: INIT data,<br/>STEP fields as streams
Rec-->>MS: h5maps
MS->>BD: new scan with h5maps<br/>in the scan info
BD-->>FW: new scan
loop every scan point
MS->>BD: scan data streams
BD-->>FW: stream data
end
MS->>Rec: end of the scan
Rec->>W: CloseEntry
Note over W: reads FINAL data
W-->>Rec: h5maps with FINAL data
Rec-->>MS: final h5maps
MS->>BD: final h5maps, close the scan
Note over FW: writes the NeXus file<br/>from the h5maps<br/>and the streams
h5maps are also used by
NXSBlissWriter – a blissdata scan without the XML configuration of the Data Writer is written as described by its h5maps,
NXSRecSelector – for BLISS scans, a hook adds the fields of the selected components, e.g. STEP fields as links to the BLISS data, to the h5maps of the scans.