From 7fe2443144f242e7faa496e35d19d543743859d4 Mon Sep 17 00:00:00 2001 From: primardj Date: Tue, 16 Apr 2024 21:16:34 +0100 Subject: [PATCH] add commands h, a, i, q, 1, 2 --- .../executor/execute_service/sent_signal.rs | 22 ++++++++++++++-- .../execute_service/sent_signal/misc.rs | 25 ++++++++++++++++--- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/01_phase_rust_src/sv-rustit/src/executor/execute_service/sent_signal.rs b/01_phase_rust_src/sv-rustit/src/executor/execute_service/sent_signal.rs index 3448f3a..e70899e 100644 --- a/01_phase_rust_src/sv-rustit/src/executor/execute_service/sent_signal.rs +++ b/01_phase_rust_src/sv-rustit/src/executor/execute_service/sent_signal.rs @@ -26,11 +26,29 @@ pub fn sent_signal( svwait_var: i32, verbose: i8, command: &str, mut sv: status_ "p" => { // case where it's the pause command which is entered. return misc::pause_verbose(sv.sent_signal(b"p"), true, verbose, svwait_var, sv); - } + }, "c" => { // case where it's the continue command which is entered. return misc::pause_verbose(sv.sent_signal(b"c"), false, verbose, svwait_var, sv); - } + }, + "h" => { + return misc::noexcept_verbose(sv.sent_signal(b"h"), verbose, sv); + }, + "a" => { + return misc::noexcept_verbose(sv.sent_signal(b"a"), verbose, sv); + }, + "i" => { + return misc::noexcept_verbose(sv.sent_signal(b"i"), verbose, sv); + }, + "q" => { + return misc::noexcept_verbose(sv.sent_signal(b"q"), verbose, sv); + }, + "1" => { + return misc::noexcept_verbose(sv.sent_signal(b"1"), verbose, sv); + }, + "2" => { + return misc::noexcept_verbose(sv.sent_signal(b"1"), verbose, sv); + }, other => { println!("Error, command {} not implemented.", other); // TODO : Put the real error // message. diff --git a/01_phase_rust_src/sv-rustit/src/executor/execute_service/sent_signal/misc.rs b/01_phase_rust_src/sv-rustit/src/executor/execute_service/sent_signal/misc.rs index 917e9d3..f389bc6 100644 --- a/01_phase_rust_src/sv-rustit/src/executor/execute_service/sent_signal/misc.rs +++ b/01_phase_rust_src/sv-rustit/src/executor/execute_service/sent_signal/misc.rs @@ -25,8 +25,8 @@ pub fn print_status(mut sv: status_obj::StatusObj) -> i32 { pub fn run_verbose(sent_signal: bool, expected: bool, verbose: i8, svwait_var: i32, mut sv: status_obj::StatusObj) -> i32 { - // if the state is true, wait for the service to run. - // If the state is false, wait for the service to down. + // if the excepted is true, wait for the service to run. + // If the excepted is false, wait for the service to down. if sent_signal && verbose == 1 { let mut time_wait = 0; loop { @@ -54,8 +54,8 @@ pub fn run_verbose(sent_signal: bool, expected: bool, verbose: i8, svwait_var: i } pub fn pause_verbose(sent_signal: bool, expected: bool, verbose: i8, svwait_var: i32, mut sv: status_obj::StatusObj) -> i32 { - // if the state is true, wait for the service to pause. - // if the state is false, wait for the service to continue. + // if the excepted is true, wait for the service to pause. + // if the excepted is false, wait for the service to continue. if sent_signal && verbose == 1 { let mut time_wait = 0; loop { @@ -81,3 +81,20 @@ pub fn pause_verbose(sent_signal: bool, expected: bool, verbose: i8, svwait_var: return 1 } } + + +pub fn noexcept_verbose(sent_signal: bool, verbose: i8, mut sv: status_obj::StatusObj) -> i32 { + if sent_signal && verbose == 1 { + let status = sv.update_status(); + if status == 1 { + return 1; + } + println!("ok: {}", sv.get_status_string()); + return 0 + } else if sent_signal && verbose == 0 { + return 0 + } else { + // Case sent_signal != true. + return 1 + } +}