project8/dragonfly

Run scripting: Implement a "wait until" step

Closed this issue · 2 comments

In the set of possible actions in the run scripting we have a wait which requires the operator's consciousness for making a decision.
It might be interesting to define an action where we wait until a set of condition is fulfilled: once these conditions are fulfilled, the script continues.
Examples:

  • we can check the cell temperature while making a temperature scan. We could also have a condition on the temperature variation/slope.
  • we could use this as a safety net for our DAQ storage space: if the space is insufficient, the run should wait. This would make things a bit nicer than the current implementation which consists in sending a broadcast.set_condition.

We would have to define clearly what the range of possible conditions are, in order to prevent dangerous deviations by the users.

Probably a useful feature. We should be careful how we define things to work because it is easy to imagine this blocking forever, looking for a condition that is never met. Also, there would need to either be a configured polling interval or a time requirement if listening on alert values.

This probably makes more sense as a supplement to the set_condition usage, which is an active abort compared to this which is more of a pause.

You could imagine doing something like adding a loop/break logic and conditional evaluation with the existing sleep to get something similar. On the other hand, at some point we're trying to implement too much logic in the config file and should consider writing actual scripts instead (or perhaps should have support for config files to execute scripts to do some flow control logic).

There is a slow control call this week, we should perhaps discuss the usages we really expect to see in the near term.

This feature is possible in the new python run scripting. An example snippet (that ended up not being used would be like) for the detection efficiency studies (from my memory, syntax may be wrong) would wait before the temperature got back within a suitable range before resuming runs.

def sleep_while_hot():
    T = 0
   while( T < 85 or T > 95):
       sleep(30)    
        T = run_interface.dragonfly.get("cell_temp")
    

Because using python directly is much more versatile, in principle one can do this. Whether or not each instance is a good idea is another question...

Is the python implementation sufficient for closing this issue?