Skip to content

psdaq.control.DaqControl

DaqControl(*, host, platform, timeout) is the client API for the control process: getState(), getStatus(), setState(state, phase1Info={}), setTransition(...), setConfig(...), setRecord(...), monitorStatus() and others. It is used by daqstate, timed_run and the scan helpers (TimedRun, ConfigScan, BlueskyScan).

See DAQ control.

psdaq.control.DaqControl

Client-side DaqControl class that talks to the DAQ collection process over ZMQ.

Requests go over REQ sockets to front_rep_port and fast_rep_port; status updates are received on a SUB socket connected to front_pub_port and step_pub_port.

DaqControl

DaqControl(*, host, platform, timeout)

Base class for controlling data acquisition

getState

getState()

Send a 'getstate' request and return the reply's header['key'].

On a receive timeout (zmq.Again) the front REQ socket is re-created.

Returns:

Type Description
str

The reply key, or 'error' on timeout, exception, KeyboardInterrupt or a missing key.

getPlatform

getPlatform()

Send a 'getstate' request and return the reply's body.

On a receive timeout (zmq.Again) the front REQ socket is re-created.

Returns:

Type Description
dict

reply['body'], or {} on timeout, exception, KeyboardInterrupt or a missing key.

getJsonConfig

getJsonConfig()

Return the platform info converted by levels_to_activedet as indented, sorted JSON.

Note that neither levels_to_activedet nor oldjson is imported in this module, so as written this raises NameError.

storeJsonConfig

storeJsonConfig(json_data)

Send a 'storejsonconfig' request with body {'json_data': json_data}.

On a receive timeout (zmq.Again) the front REQ socket is re-created.

Parameters:

Name Type Description Default
json_data

Data placed in the request body.

required

Returns:

Type Description
dict

reply['body'], or {} on timeout, exception, KeyboardInterrupt or a missing key.

selectPlatform

selectPlatform(body)

Send a 'selectplatform' request with the given body.

On a receive timeout (zmq.Again) the front REQ socket is re-created.

Parameters:

Name Type Description Default
body dict

Request body.

required

Returns:

Type Description
dict

reply['body'], or {} on timeout, exception, KeyboardInterrupt or a missing key.

getInstrument

getInstrument()

Send a 'getinstrument' request on the fast REQ socket.

Returns:

Type Description
str or None

reply['body']['instrument'], or None if the request or lookup fails (the exception is printed).

getStatus

getStatus()

Send a 'getstatus' request and return fields of the reply body.

Returns:

Type Description
tuple

(transition, state, config_alias, recording, platform, bypass_activedet, experiment_name, run_number, last_run_number). Defaults are 'error' for every field except platform ({}); on a KeyError, fields read before it keep their values.

monitorStatus

monitorStatus()

Block on the SUB socket until a recognized message arrives and return its fields.

Messages with other keys are ignored. Always returns an 8-tuple: 'status' -> (transition, state, config_alias, recording, bypass_activedet, experiment_name, run_number, last_run_number); 'error'/'warning' -> (key, err_info, 'error' x6); 'fileReport' -> ('fileReport', path, 'error' x6); 'progress' -> ('progress', transition, elapsed, total, 'error' x4); 'step' -> ('step', step_done, 'error' x6). On KeyboardInterrupt or KeyError returns eight Nones.

setState

setState(state, phase1Info={})

Send a 'setstate.' request with phase1Info as the body.

On a receive timeout (zmq.Again) the front REQ socket is re-created.

Parameters:

Name Type Description Default
state str

Target state name.

required
phase1Info dict

Per-transition phase-1 info, e.g. {'beginstep': {...}, 'enable': {...}}.

{}

Returns:

Type Description
str or None

reply['body']['err_info'] if present, an error string on timeout/exception, else None.

setConfig

setConfig(config)

Send a 'setconfig.' request on the front REQ socket.

Returns:

Type Description
str or None

reply['body']['err_info'] if present, an error string on exception, else None.

setRecord

setRecord(recordIn)

Send 'setrecord.1' or 'setrecord.0' on the fast REQ socket.

Parameters:

Name Type Description Default
recordIn bool

Record flag; any non-bool value is rejected without sending.

required

Returns:

Type Description
str or None

reply['body']['err_info'] if present, an error string on exception or non-bool input, else None.

getBlock

getBlock(data)

Send a 'getblock' request with data as body on the fast REQ socket.

Returns:

Type Description
object or None

reply['body'], or None if the request or lookup fails (the exception is printed).

setBypass

setBypass(bypassIn)

Send 'setbypass.1' or 'setbypass.0' on the front REQ socket.

Parameters:

Name Type Description Default
bypassIn bool

Bypass flag; any non-bool value is rejected without sending.

required

Returns:

Type Description
str or None

reply['body']['err_info'] if present, an error string on exception or non-bool input, else None.

setTransition

setTransition(transition, phase1Info={})

Send a request whose key is transition with phase1Info as the body.

Returns:

Type Description
str or None

reply['body']['err_info'] if present, an error string on exception, else None.

front_req_init

front_req_init()

Close the existing front REQ socket (if any) and create a new one.

The new socket has linger 0 and RCVTIMEO set to self.timeout, and is connected to front_req_endpoint.

fast_req_init

fast_req_init()

Close the existing fast REQ socket (if any) and create a new one.

The new socket has linger 0 and RCVTIMEO set to self.timeout, and is connected to fast_req_endpoint.