#[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
impl UIMessageCode
Sourcepub const USER_MESSAGE_BASE: i32 = 10000
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.
Sourcepub const fn is_user_message(raw: i32) -> bool
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?
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}Sourcepub const fn from_bits(raw: i32) -> Result<Self, i32>
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?
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
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}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}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
impl Clone for UIMessageCode
Source§fn clone(&self) -> UIMessageCode
fn clone(&self) -> UIMessageCode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more