Skip to main content

station_options_update/
station_options_update.rs

1//! Example: set station options from code and commit them to disk.
2//!
3//! Everything here is written to the station configuration, so it outlives the
4//! process and affects every later run on this machine. Read it as provisioning
5//! a station, not as setup for one execution.
6
7use rs_teststand::Engine;
8
9fn main() -> Result<(), rs_teststand::Error> {
10    let engine = Engine::new()?;
11    let station_options = engine.station_options()?;
12
13    station_options.set_tracing_enabled(true)?;
14    station_options.set_disable_results(false)?;
15    station_options.set_check_out_files_when_edited(false)?;
16    station_options.set_language("English")?;
17    station_options.set_always_goto_cleanup_on_failure(true)?;
18    station_options.set_prompt_to_find_files(false)?;
19    station_options.set_auto_login_system_user(true)?;
20    station_options.set_station_id("STATION_RUST_01")?;
21    station_options.set_use_station_model(true)?;
22    station_options.set_allow_other_models(false)?;
23    station_options.set_use_localized_decimal_point(false)?;
24    station_options.set_time_limit(0, 0, 60.0)?;
25    station_options.set_time_limit_enabled(0, 0, true)?;
26
27    // Debug options are left exactly as the station has them. `Engine::new`
28    // already clears the two bits that raise a dialog at shutdown, and the rest
29    // are the operator's own choices. Writing them here would commit that
30    // decision to disk on someone else's machine.
31    //
32    // Breakpoints are left alone for the same reason: enabling them suspends an
33    // execution until a person acts, which is the opposite of what a provisioned
34    // station wants.
35    //
36    // `UIMessageDelay` is also untouched. It paces every traced step, so a value
37    // meant for watching a run costs real wall-clock time on an unattended one.
38
39    engine.commit_globals_to_disk(false)?;
40    println!("Station options updated and committed to disk.");
41
42    Ok(())
43}