Skip to main content

UIMessageCode

Enum UIMessageCode 

Source
#[repr(i32)]
pub enum UIMessageCode {
Show 45 variants BreakOnUserRequest = 1, BreakOnBreakpoint = 2, BreakOnRunTimeError = 3, Trace = 4, TerminatingExecution = 5, AbortingExecution = 6, KillingExecutionThreads = 7, EndExecution = 8, ShutDownComplete = 9, StartExecution = 10, ProgressPercent = 11, ProgressText = 12, StartInteractiveExecution = 13, EndInteractiveExecution = 14, TerminatingInteractiveExecution = 15, TerminationCanceled = 16, ResumeFromBreak = 17, StartFileExecution = 18, EndFileExecution = 19, ShutDownCanceled = 20, LocalizationSettingChanged = 21, OpenWindows = 22, TileWindows = 23, CascadeWindows = 24, ReportChanged = 25, CloseWindows = 26, RefreshWindows = 27, ClientFileChanged = 28, DisplayReport = 29, ModelStateInitializing = 30, ModelStateWaiting = 31, ModelStateIdentified = 32, ModelStateBeginTesting = 33, ModelStateTestingComplete = 34, ModelStatePostProcessingComplete = 35, ModelStateEnabledStateSet = 36, ReportLocationChanged = 37, GotoLocation = 38, PushUndoItem = 39, OutputMessages = 40, TypePaletteFileListChanged = 41, NonTerminatableThreadsArePreventingTermination = 42, ModelStatePostProcessing = 43, ReportCollectionChanged = 44, RuntimeError = 45,
}
Expand description

A user-interface message code (UIMsg_*).

The engine posts these to tell a host what an execution is doing. A sequence can also post its own, numbered from USER_MESSAGE_BASE upward, which is how a test reports progress to whatever is driving it.

Variants§

§

BreakOnUserRequest = 1

UIMsg_BreakOnUserRequest.

§

BreakOnBreakpoint = 2

UIMsg_BreakOnBreakpoint.

§

BreakOnRunTimeError = 3

UIMsg_BreakOnRunTimeError.

§

Trace = 4

UIMsg_Trace.

§

TerminatingExecution = 5

UIMsg_TerminatingExecution.

§

AbortingExecution = 6

UIMsg_AbortingExecution.

§

KillingExecutionThreads = 7

UIMsg_KillingExecutionThreads.

§

EndExecution = 8

UIMsg_EndExecution.

§

ShutDownComplete = 9

UIMsg_ShutDownComplete.

§

StartExecution = 10

UIMsg_StartExecution.

§

ProgressPercent = 11

UIMsg_ProgressPercent.

§

ProgressText = 12

UIMsg_ProgressText.

§

StartInteractiveExecution = 13

UIMsg_StartInteractiveExecution.

§

EndInteractiveExecution = 14

UIMsg_EndInteractiveExecution.

§

TerminatingInteractiveExecution = 15

UIMsg_TerminatingInteractiveExecution.

§

TerminationCanceled = 16

UIMsg_TerminationCanceled.

§

ResumeFromBreak = 17

UIMsg_ResumeFromBreak.

§

StartFileExecution = 18

UIMsg_StartFileExecution.

§

EndFileExecution = 19

UIMsg_EndFileExecution.

§

ShutDownCanceled = 20

UIMsg_ShutDownCanceled.

§

LocalizationSettingChanged = 21

UIMsg_LocalizationSettingChanged.

§

OpenWindows = 22

UIMsg_OpenWindows.

§

TileWindows = 23

UIMsg_TileWindows.

§

CascadeWindows = 24

UIMsg_CascadeWindows.

§

ReportChanged = 25

UIMsg_ReportChanged.

§

CloseWindows = 26

UIMsg_CloseWindows.

§

RefreshWindows = 27

UIMsg_RefreshWindows.

§

ClientFileChanged = 28

UIMsg_ClientFileChanged.

§

DisplayReport = 29

UIMsg_DisplayReport.

§

ModelStateInitializing = 30

UIMsg_ModelStateInitializing.

§

ModelStateWaiting = 31

UIMsg_ModelStateWaiting.

§

ModelStateIdentified = 32

UIMsg_ModelStateIdentified.

§

ModelStateBeginTesting = 33

UIMsg_ModelStateBeginTesting.

§

ModelStateTestingComplete = 34

UIMsg_ModelStateTestingComplete.

§

ModelStatePostProcessingComplete = 35

UIMsg_ModelStatePostProcessingComplete.

§

ModelStateEnabledStateSet = 36

UIMsg_ModelStateEnabledStateSet.

§

ReportLocationChanged = 37

UIMsg_ReportLocationChanged.

§

GotoLocation = 38

UIMsg_GotoLocation.

§

PushUndoItem = 39

UIMsg_PushUndoItem.

§

OutputMessages = 40

UIMsg_OutputMessages.

§

TypePaletteFileListChanged = 41

UIMsg_TypePaletteFileListChanged.

§

NonTerminatableThreadsArePreventingTermination = 42

UIMsg_NonTerminatableThreadsArePreventingTermination.

§

ModelStatePostProcessing = 43

UIMsg_ModelStatePostProcessing.

§

ReportCollectionChanged = 44

UIMsg_ReportCollectionChanged.

§

RuntimeError = 45

UIMsg_RuntimeError.

Implementations§

Source§

impl UIMessageCode

Source

pub const ALL: [Self; 45]

Every code the engine defines.

Source

pub const USER_MESSAGE_BASE: i32 = 10000

The first code available to a sequence (UIMsg_UserMessageBase).

Engine codes sit below this; anything at or above it was posted by a sequence, so a host can tell the two apart without a lookup.

Source

pub const fn bits(self) -> i32

The value the COM boundary expects.

Source

pub const fn is_user_message(raw: i32) -> bool

Whether a raw code was posted by a sequence rather than the engine.

Examples found in repository?
examples/ui_messages_handle.rs (line 92)
40fn main() -> Result<(), Box<dyn std::error::Error>> {
41    let engine = Engine::new()?;
42
43    // Nothing reaches the queue until polling is switched on.
44    engine.set_ui_message_polling_enabled(true)?;
45
46    let sequence_file = engine.new_sequence_file()?;
47    let main_sequence = sequence_file.get_sequence_by_name("MainSequence")?;
48
49    // Posted through the engine and tagged with the execution. Synchronous, so
50    // the sequence waits until the host acknowledges it.
51    add_statement(
52        &engine,
53        &main_sequence,
54        "Report Stage",
55        &format!(
56            "RunState.Engine.PostUIMessage(RunState.Execution, RunState.Thread, {STAGE_MESSAGE}, \
57             1, \"stage: configuring instruments\", Nothing, True)"
58        ),
59    )?;
60    // Posted through the thread. Asynchronous, so the sequence carries on.
61    add_statement(
62        &engine,
63        &main_sequence,
64        "Report Progress",
65        &format!(
66            "RunState.Thread.PostUIMessageEx({PROGRESS_MESSAGE}, 50, \"progress: halfway\", \
67             Nothing, False)"
68        ),
69    )?;
70
71    let execution = engine.new_execution(&sequence_file, "MainSequence", None, false, 0)?;
72    println!(
73        "Execution {} started; polling for messages...",
74        execution.id()?
75    );
76
77    // The end is detected from the message stream, not by waiting on the
78    // execution: a wait call does not pump the queue, so a synchronous message
79    // would sit unacknowledged and both sides would stop.
80    let started = Instant::now();
81    let mut ended = false;
82    while started.elapsed() < Duration::from_secs(60) && !ended {
83        while !engine.is_ui_message_queue_empty()? {
84            let message = engine.get_ui_message()?;
85            let code = message.event()?;
86            if matches!(
87                UIMessageCode::from_bits(code),
88                Ok(UIMessageCode::EndExecution)
89            ) {
90                ended = true;
91            }
92            let origin = if UIMessageCode::is_user_message(code) {
93                "sequence".to_owned()
94            } else {
95                format!("engine {:?}", UIMessageCode::from_bits(code))
96            };
97            println!(
98                "  [{origin}] code={code} numeric={} string={:?} synchronous={}",
99                message.numeric_data()?,
100                message.string_data()?,
101                message.is_synchronous()?
102            );
103            // Required: releases a synchronous poster and asks for the next.
104            message.acknowledge()?;
105        }
106    }
107
108    println!("\nExecution ended: {ended}");
109    engine.release_sequence_file_ex(sequence_file, NO_OPTIONS)?;
110    Ok(())
111}
Source

pub const fn from_bits(raw: i32) -> Result<Self, i32>

Reads a raw code, returning it unchanged when it is not an engine one.

§Errors

The raw value, for a user message or a code this build does not name.

Examples found in repository?
examples/execution_run_subsequence.rs (line 95)
86fn wait_for_end(engine: &Engine, deadline: Duration) -> Result<bool, Error> {
87    let started = Instant::now();
88    while started.elapsed() < deadline {
89        if pump_thread_messages() {
90            return Ok(false);
91        }
92        while !engine.is_ui_message_queue_empty()? {
93            let message = engine.get_ui_message()?;
94            let ended = matches!(
95                UIMessageCode::from_bits(message.event()?),
96                Ok(UIMessageCode::EndExecution)
97            );
98            message.acknowledge()?;
99            if ended {
100                return Ok(true);
101            }
102        }
103    }
104    Ok(false)
105}
More examples
Hide additional examples
examples/result_list_parse.rs (line 97)
88fn wait_for_end(engine: &Engine, deadline: Duration) -> Result<bool, Error> {
89    let started = Instant::now();
90    while started.elapsed() < deadline {
91        if pump_thread_messages() {
92            return Ok(false);
93        }
94        while !engine.is_ui_message_queue_empty()? {
95            let message = engine.get_ui_message()?;
96            let ended = matches!(
97                UIMessageCode::from_bits(message.event()?),
98                Ok(UIMessageCode::EndExecution)
99            );
100            message.acknowledge()?;
101            if ended {
102                return Ok(true);
103            }
104        }
105    }
106    Ok(false)
107}
examples/execution_run_test_headless.rs (line 99)
90fn wait_for_end(engine: &Engine, deadline: Duration) -> Result<bool, Error> {
91    let started = Instant::now();
92    while started.elapsed() < deadline {
93        if pump_thread_messages() {
94            return Ok(false);
95        }
96        while !engine.is_ui_message_queue_empty()? {
97            let message = engine.get_ui_message()?;
98            let ended = matches!(
99                UIMessageCode::from_bits(message.event()?),
100                Ok(UIMessageCode::EndExecution)
101            );
102            // Acknowledging is what releases a synchronous poster; skipping it
103            // stalls the sequence rather than merely losing a notification.
104            message.acknowledge()?;
105            if ended {
106                return Ok(true);
107            }
108        }
109    }
110    Ok(false)
111}
examples/ui_messages_handle.rs (line 87)
40fn main() -> Result<(), Box<dyn std::error::Error>> {
41    let engine = Engine::new()?;
42
43    // Nothing reaches the queue until polling is switched on.
44    engine.set_ui_message_polling_enabled(true)?;
45
46    let sequence_file = engine.new_sequence_file()?;
47    let main_sequence = sequence_file.get_sequence_by_name("MainSequence")?;
48
49    // Posted through the engine and tagged with the execution. Synchronous, so
50    // the sequence waits until the host acknowledges it.
51    add_statement(
52        &engine,
53        &main_sequence,
54        "Report Stage",
55        &format!(
56            "RunState.Engine.PostUIMessage(RunState.Execution, RunState.Thread, {STAGE_MESSAGE}, \
57             1, \"stage: configuring instruments\", Nothing, True)"
58        ),
59    )?;
60    // Posted through the thread. Asynchronous, so the sequence carries on.
61    add_statement(
62        &engine,
63        &main_sequence,
64        "Report Progress",
65        &format!(
66            "RunState.Thread.PostUIMessageEx({PROGRESS_MESSAGE}, 50, \"progress: halfway\", \
67             Nothing, False)"
68        ),
69    )?;
70
71    let execution = engine.new_execution(&sequence_file, "MainSequence", None, false, 0)?;
72    println!(
73        "Execution {} started; polling for messages...",
74        execution.id()?
75    );
76
77    // The end is detected from the message stream, not by waiting on the
78    // execution: a wait call does not pump the queue, so a synchronous message
79    // would sit unacknowledged and both sides would stop.
80    let started = Instant::now();
81    let mut ended = false;
82    while started.elapsed() < Duration::from_secs(60) && !ended {
83        while !engine.is_ui_message_queue_empty()? {
84            let message = engine.get_ui_message()?;
85            let code = message.event()?;
86            if matches!(
87                UIMessageCode::from_bits(code),
88                Ok(UIMessageCode::EndExecution)
89            ) {
90                ended = true;
91            }
92            let origin = if UIMessageCode::is_user_message(code) {
93                "sequence".to_owned()
94            } else {
95                format!("engine {:?}", UIMessageCode::from_bits(code))
96            };
97            println!(
98                "  [{origin}] code={code} numeric={} string={:?} synchronous={}",
99                message.numeric_data()?,
100                message.string_data()?,
101                message.is_synchronous()?
102            );
103            // Required: releases a synchronous poster and asks for the next.
104            message.acknowledge()?;
105        }
106    }
107
108    println!("\nExecution ended: {ended}");
109    engine.release_sequence_file_ex(sequence_file, NO_OPTIONS)?;
110    Ok(())
111}

Trait Implementations§

Source§

impl Clone for UIMessageCode

Source§

fn clone(&self) -> UIMessageCode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for UIMessageCode

Source§

impl Debug for UIMessageCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for UIMessageCode

Source§

impl Hash for UIMessageCode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for UIMessageCode

Source§

fn eq(&self, other: &UIMessageCode) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for UIMessageCode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.