lab-measurement / Lab-Measurement

Lab::Measurement allows to perform test and measurement tasks with Perl scripts.
https://www.labmeasurement.de/
Other
10 stars 11 forks source link

Feature request: Function to call if sweep dies #71

Open Deadmansshoe opened 2 years ago

Deadmansshoe commented 2 years ago

Hi everyone,

I had an idea for a new feature, which could enhance Lab-Measurement. Instead of leaving everything as it was before the code crashes (if e.g. a limit is reached or an instrument is no longer reachable), code could be executed. This could give the opportunity to set crucial inputs back to safe values or send a notification to the user.

I thought this could be a function given to the sweep start function call, similar to the function reference given to sweep initialization.

...
my $crashfunction = sub {
    $yokogawa->set_voltage(value => '0.0');
};

...

$sweep->start(
    measurement => $meas,
    datafile    => $datafile,
    coderef_crash => $crashfunction,
);

What are your ideas to something like that? Do you think this could be possible?

Greetings Robin

akhuettel commented 2 months ago

Uh, only just saw this. Possible, but most likely not very reliable for nontrivial things... let's talk.