remove load_and_get_signal
, rename timeline
to load_signal_and_get_timeline
This commit is contained in:
parent
d8c1b0abac
commit
3f61f9f3fe
|
@ -33,12 +33,8 @@ pub async fn get_time_table() -> wellen::TimeTable {
|
||||||
platform::get_time_table().await
|
platform::get_time_table().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn load_and_get_signal(signal_ref: wellen::SignalRef) -> wellen::Signal {
|
pub async fn load_signal_and_get_timeline(signal_ref: wellen::SignalRef, screen_width: u32, block_height: u32) -> shared::Timeline {
|
||||||
platform::load_and_get_signal(signal_ref).await
|
platform::load_signal_and_get_timeline(signal_ref, screen_width, block_height).await
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn timeline(signal_ref: wellen::SignalRef, screen_width: u32, block_height: u32) -> shared::Timeline {
|
|
||||||
platform::timeline(signal_ref, screen_width, block_height).await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn unload_signal(signal_ref: wellen::SignalRef) {
|
pub async fn unload_signal(signal_ref: wellen::SignalRef) {
|
||||||
|
|
|
@ -81,17 +81,8 @@ pub(super) async fn get_time_table() -> wellen::TimeTable {
|
||||||
serde_json::from_value(serde_json::to_value(time_table).unwrap_throw()).unwrap_throw()
|
serde_json::from_value(serde_json::to_value(time_table).unwrap_throw()).unwrap_throw()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn load_and_get_signal(signal_ref: wellen::SignalRef) -> wellen::Signal {
|
pub(super) async fn load_signal_and_get_timeline(signal_ref: wellen::SignalRef, screen_width: u32, block_height: u32) -> shared::Timeline {
|
||||||
let mut waveform_lock = STORE.waveform.lock().unwrap_throw();
|
// @TODO implement, copy from tauri platform
|
||||||
let waveform = waveform_lock.as_mut().unwrap_throw();
|
|
||||||
// @TODO maybe run it in a thread to not block the main one and then
|
|
||||||
waveform.load_signals(&[signal_ref]);
|
|
||||||
let signal = waveform.get_signal(signal_ref).unwrap_throw();
|
|
||||||
// @TODO `clone` / `Rc/Arc` / refactor?
|
|
||||||
serde_json::from_value(serde_json::to_value(signal).unwrap_throw()).unwrap_throw()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) async fn timeline(signal_ref: wellen::SignalRef, screen_width: u32, block_height: u32) -> shared::Timeline {
|
|
||||||
shared::Timeline { blocks: Vec::new() }
|
shared::Timeline { blocks: Vec::new() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,18 +21,9 @@ pub(super) async fn get_time_table() -> wellen::TimeTable {
|
||||||
serde_wasm_bindgen::from_value(tauri_glue::get_time_table().await.unwrap_throw()).unwrap_throw()
|
serde_wasm_bindgen::from_value(tauri_glue::get_time_table().await.unwrap_throw()).unwrap_throw()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn load_and_get_signal(signal_ref: wellen::SignalRef) -> wellen::Signal {
|
pub(super) async fn load_signal_and_get_timeline(signal_ref: wellen::SignalRef, screen_width: u32, block_height: u32) -> shared::Timeline {
|
||||||
serde_wasm_bindgen::from_value(
|
serde_wasm_bindgen::from_value(
|
||||||
tauri_glue::load_and_get_signal(signal_ref.index())
|
tauri_glue::load_signal_and_get_timeline(signal_ref.index(), screen_width, block_height)
|
||||||
.await
|
|
||||||
.unwrap_throw(),
|
|
||||||
)
|
|
||||||
.unwrap_throw()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) async fn timeline(signal_ref: wellen::SignalRef, screen_width: u32, block_height: u32) -> shared::Timeline {
|
|
||||||
serde_wasm_bindgen::from_value(
|
|
||||||
tauri_glue::timeline(signal_ref.index(), screen_width, block_height)
|
|
||||||
.await
|
.await
|
||||||
.unwrap_throw(),
|
.unwrap_throw(),
|
||||||
)
|
)
|
||||||
|
@ -64,10 +55,7 @@ mod tauri_glue {
|
||||||
pub async fn get_time_table() -> Result<JsValue, JsValue>;
|
pub async fn get_time_table() -> Result<JsValue, JsValue>;
|
||||||
|
|
||||||
#[wasm_bindgen(catch)]
|
#[wasm_bindgen(catch)]
|
||||||
pub async fn load_and_get_signal(signal_ref_index: usize) -> Result<JsValue, JsValue>;
|
pub async fn load_signal_and_get_timeline(signal_ref_index: usize, screen_width: u32, block_height: u32) -> Result<JsValue, JsValue>;
|
||||||
|
|
||||||
#[wasm_bindgen(catch)]
|
|
||||||
pub async fn timeline(signal_ref_index: usize, screen_width: u32, block_height: u32) -> Result<JsValue, JsValue>;
|
|
||||||
|
|
||||||
#[wasm_bindgen(catch)]
|
#[wasm_bindgen(catch)]
|
||||||
pub async fn unload_signal(signal_ref_index: usize) -> Result<(), JsValue>;
|
pub async fn unload_signal(signal_ref_index: usize) -> Result<(), JsValue>;
|
||||||
|
|
|
@ -113,11 +113,10 @@ impl WaveformPanel {
|
||||||
eprintln!("timetable is empty");
|
eprintln!("timetable is empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let last_time = time_table.last().copied().unwrap_throw();
|
|
||||||
|
|
||||||
let var = hierarchy.get(var_ref);
|
let var = hierarchy.get(var_ref);
|
||||||
let signal_ref = var.signal_ref();
|
let signal_ref = var.signal_ref();
|
||||||
let timeline = platform::timeline(signal_ref, controller.screen_width(), ROW_HEIGHT).await;
|
let timeline = platform::load_signal_and_get_timeline(signal_ref, controller.screen_width(), ROW_HEIGHT).await;
|
||||||
|
|
||||||
// @TODO remove
|
// @TODO remove
|
||||||
zoon::println!("Timeline in Rust: {timeline:#?}");
|
zoon::println!("Timeline in Rust: {timeline:#?}");
|
||||||
|
|
|
@ -2523,11 +2523,8 @@ async function get_hierarchy() {
|
||||||
async function get_time_table() {
|
async function get_time_table() {
|
||||||
return await invoke2("get_time_table");
|
return await invoke2("get_time_table");
|
||||||
}
|
}
|
||||||
async function load_and_get_signal(signal_ref_index) {
|
async function load_signal_and_get_timeline(signal_ref_index, screen_width, block_height) {
|
||||||
return await invoke2("load_and_get_signal", { signal_ref_index });
|
return await invoke2("load_signal_and_get_timeline", { signal_ref_index, screen_width, block_height });
|
||||||
}
|
|
||||||
async function timeline(signal_ref_index, screen_width, block_height) {
|
|
||||||
return await invoke2("timeline", { signal_ref_index, screen_width, block_height });
|
|
||||||
}
|
}
|
||||||
async function unload_signal(signal_ref_index) {
|
async function unload_signal(signal_ref_index) {
|
||||||
return await invoke2("unload_signal", { signal_ref_index });
|
return await invoke2("unload_signal", { signal_ref_index });
|
||||||
|
@ -2535,9 +2532,8 @@ async function unload_signal(signal_ref_index) {
|
||||||
export {
|
export {
|
||||||
get_hierarchy,
|
get_hierarchy,
|
||||||
get_time_table,
|
get_time_table,
|
||||||
load_and_get_signal,
|
load_signal_and_get_timeline,
|
||||||
pick_and_load_waveform,
|
pick_and_load_waveform,
|
||||||
show_window,
|
show_window,
|
||||||
timeline,
|
|
||||||
unload_signal
|
unload_signal
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,12 +26,8 @@ export async function get_time_table(): Promise<WellenTimeTable> {
|
||||||
return await invoke("get_time_table");
|
return await invoke("get_time_table");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function load_and_get_signal(signal_ref_index: number): Promise<WellenSignal> {
|
export async function load_signal_and_get_timeline(signal_ref_index: number, screen_width: number, block_height: number): Promise<Timeline> {
|
||||||
return await invoke("load_and_get_signal", { signal_ref_index });
|
return await invoke("load_signal_and_get_timeline", { signal_ref_index, screen_width, block_height });
|
||||||
}
|
|
||||||
|
|
||||||
export async function timeline(signal_ref_index: number, screen_width: number, block_height: number): Promise<Timeline> {
|
|
||||||
return await invoke("timeline", { signal_ref_index, screen_width, block_height });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function unload_signal(signal_ref_index: number): Promise<void> {
|
export async function unload_signal(signal_ref_index: number): Promise<void> {
|
||||||
|
|
|
@ -47,22 +47,7 @@ async fn get_time_table(store: tauri::State<'_, Store>) -> Result<serde_json::Va
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
async fn load_and_get_signal(
|
async fn load_signal_and_get_timeline(
|
||||||
signal_ref_index: usize,
|
|
||||||
store: tauri::State<'_, Store>,
|
|
||||||
) -> Result<serde_json::Value, ()> {
|
|
||||||
let signal_ref = wellen::SignalRef::from_index(signal_ref_index).unwrap();
|
|
||||||
let mut waveform_lock = store.waveform.lock().unwrap();
|
|
||||||
let waveform = waveform_lock.as_mut().unwrap();
|
|
||||||
// @TODO maybe run it in a thread to not block the main one and then
|
|
||||||
// make the command async or return the result through a Tauri channel
|
|
||||||
waveform.load_signals_multi_threaded(&[signal_ref]);
|
|
||||||
let signal = waveform.get_signal(signal_ref).unwrap();
|
|
||||||
Ok(serde_json::to_value(signal).unwrap())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
|
||||||
async fn timeline(
|
|
||||||
signal_ref_index: usize,
|
signal_ref_index: usize,
|
||||||
screen_width: u32,
|
screen_width: u32,
|
||||||
block_height: u32,
|
block_height: u32,
|
||||||
|
@ -104,8 +89,7 @@ pub fn run() {
|
||||||
pick_and_load_waveform,
|
pick_and_load_waveform,
|
||||||
get_hierarchy,
|
get_hierarchy,
|
||||||
get_time_table,
|
get_time_table,
|
||||||
load_and_get_signal,
|
load_signal_and_get_timeline,
|
||||||
timeline,
|
|
||||||
unload_signal,
|
unload_signal,
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
|
|
Loading…
Reference in a new issue