wave_27 test file + related code
This commit is contained in:
parent
c6ef5c65a4
commit
f8e07d213d
|
@ -3,7 +3,7 @@ use crate::HierarchyAndTimeTable;
|
|||
use std::collections::VecDeque;
|
||||
use std::rc::Rc;
|
||||
use wellen::GetItem;
|
||||
use zoon::{println, *};
|
||||
use zoon::*;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct VarForUI<'a> {
|
||||
|
@ -61,7 +61,13 @@ impl ControlsPanel {
|
|||
.s(Padding::all(20))
|
||||
.s(Gap::new().y(40))
|
||||
.s(Align::new().top())
|
||||
.item(self.load_button())
|
||||
.item(
|
||||
Row::new()
|
||||
.s(Gap::both(15))
|
||||
.s(Align::new().left())
|
||||
.item(self.load_button("simple.vcd"))
|
||||
.item(self.load_button("wave_27.fst"))
|
||||
)
|
||||
.item_signal(
|
||||
self.hierarchy_and_time_table
|
||||
.signal_cloned()
|
||||
|
@ -74,7 +80,7 @@ impl ControlsPanel {
|
|||
)
|
||||
}
|
||||
|
||||
fn load_button(&self) -> impl Element {
|
||||
fn load_button(&self, test_file_name: &'static str) -> impl Element {
|
||||
let (hovered, hovered_signal) = Mutable::new_and_signal(false);
|
||||
let hierarchy_and_time_table = self.hierarchy_and_time_table.clone();
|
||||
Button::new()
|
||||
|
@ -88,13 +94,13 @@ impl ControlsPanel {
|
|||
El::new().s(Font::new().no_wrap()).child_signal(
|
||||
hierarchy_and_time_table
|
||||
.signal_ref(Option::is_some)
|
||||
.map_bool(|| "Unload simple.vcd", || "Load simple.vcd"),
|
||||
.map_bool(|| format!("Unload test file"), move || format!("Load {test_file_name}")),
|
||||
),
|
||||
)
|
||||
.on_hovered_change(move |is_hovered| hovered.set_neq(is_hovered))
|
||||
// @TODO REMOVE
|
||||
.after_insert(clone!((hierarchy_and_time_table) move |_| {
|
||||
if crate::SIMULATE_CLICKS {
|
||||
if crate::SIMULATE_CLICKS && test_file_name == "simple.vcd" {
|
||||
let mut hierarchy_and_time_table_lock = hierarchy_and_time_table.lock_mut();
|
||||
if hierarchy_and_time_table_lock.is_some() {
|
||||
*hierarchy_and_time_table_lock = None;
|
||||
|
@ -103,16 +109,18 @@ impl ControlsPanel {
|
|||
drop(hierarchy_and_time_table_lock);
|
||||
let hierarchy_and_time_table = hierarchy_and_time_table.clone();
|
||||
Task::start(async move {
|
||||
tauri_bridge::load_waveform().await;
|
||||
tauri_bridge::load_waveform(test_file_name).await;
|
||||
let hierarchy = tauri_bridge::get_hierarchy().await;
|
||||
for variable in hierarchy.iter_vars() {
|
||||
println!("{variable:?}");
|
||||
}
|
||||
for scope in hierarchy.iter_scopes() {
|
||||
println!("{scope:?}");
|
||||
}
|
||||
// @TODO remove
|
||||
// for variable in hierarchy.iter_vars() {
|
||||
// zoon::println!("{variable:?}");
|
||||
// }
|
||||
// for scope in hierarchy.iter_scopes() {
|
||||
// zoon::println!("{scope:?}");
|
||||
// }
|
||||
let time_table = tauri_bridge::get_time_table().await;
|
||||
println!("{time_table:?}");
|
||||
// @TODO remove
|
||||
// zoon::println!("{time_table:?}");
|
||||
hierarchy_and_time_table.set(Some((Rc::new(hierarchy), Rc::new(time_table))))
|
||||
})
|
||||
}
|
||||
|
@ -126,16 +134,18 @@ impl ControlsPanel {
|
|||
drop(hierarchy_and_time_table_lock);
|
||||
let hierarchy_and_time_table = hierarchy_and_time_table.clone();
|
||||
Task::start(async move {
|
||||
tauri_bridge::load_waveform().await;
|
||||
tauri_bridge::load_waveform(test_file_name).await;
|
||||
let hierarchy = tauri_bridge::get_hierarchy().await;
|
||||
for variable in hierarchy.iter_vars() {
|
||||
println!("{variable:?}");
|
||||
}
|
||||
for scope in hierarchy.iter_scopes() {
|
||||
println!("{scope:?}");
|
||||
}
|
||||
// @TODO remove
|
||||
// for variable in hierarchy.iter_vars() {
|
||||
// zoon::println!("{variable:?}");
|
||||
// }
|
||||
// for scope in hierarchy.iter_scopes() {
|
||||
// zoon::println!("{scope:?}");
|
||||
// }
|
||||
let time_table = tauri_bridge::get_time_table().await;
|
||||
println!("{time_table:?}");
|
||||
// @TODO remove
|
||||
// zoon::println!("{time_table:?}");
|
||||
hierarchy_and_time_table.set(Some((Rc::new(hierarchy), Rc::new(time_table))))
|
||||
})
|
||||
})
|
||||
|
|
|
@ -12,7 +12,7 @@ use waveform_panel::WaveformPanel;
|
|||
type HierarchyAndTimeTable = (Rc<wellen::Hierarchy>, Rc<wellen::TimeTable>);
|
||||
|
||||
// @TODO REMOVE
|
||||
const SIMULATE_CLICKS: bool = false;
|
||||
const SIMULATE_CLICKS: bool = true;
|
||||
|
||||
fn main() {
|
||||
start_app("app", root);
|
||||
|
|
|
@ -4,8 +4,8 @@ pub async fn show_window() {
|
|||
tauri_glue::show_window().await
|
||||
}
|
||||
|
||||
pub async fn load_waveform() {
|
||||
tauri_glue::load_waveform().await
|
||||
pub async fn load_waveform(test_file_name: &'static str) {
|
||||
tauri_glue::load_waveform(test_file_name).await
|
||||
}
|
||||
|
||||
pub async fn get_hierarchy() -> wellen::Hierarchy {
|
||||
|
@ -33,7 +33,7 @@ mod tauri_glue {
|
|||
extern "C" {
|
||||
pub async fn show_window();
|
||||
|
||||
pub async fn load_waveform();
|
||||
pub async fn load_waveform(test_file_name: &str);
|
||||
|
||||
pub async fn get_hierarchy() -> JsValue;
|
||||
|
||||
|
|
|
@ -2514,8 +2514,8 @@ var invoke2 = core_exports.invoke;
|
|||
async function show_window() {
|
||||
return await invoke2("show_window");
|
||||
}
|
||||
async function load_waveform() {
|
||||
return await invoke2("load_waveform");
|
||||
async function load_waveform(test_file_name) {
|
||||
return await invoke2("load_waveform", { test_file_name });
|
||||
}
|
||||
async function get_hierarchy() {
|
||||
return await invoke2("get_hierarchy");
|
||||
|
|
|
@ -12,8 +12,8 @@ export async function show_window(): Promise<void> {
|
|||
return await invoke("show_window");
|
||||
}
|
||||
|
||||
export async function load_waveform(): Promise<void> {
|
||||
return await invoke("load_waveform");
|
||||
export async function load_waveform(test_file_name: string): Promise<void> {
|
||||
return await invoke("load_waveform", { test_file_name });
|
||||
}
|
||||
|
||||
export async function get_hierarchy(): Promise<WellenHierarchy> {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use std::sync::Mutex;
|
||||
use std::rc::Rc;
|
||||
use wellen::simple::Waveform;
|
||||
|
||||
mod wellen_helpers;
|
||||
|
@ -14,9 +15,15 @@ fn show_window(window: tauri::Window) {
|
|||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
fn load_waveform(store: tauri::State<Store>) {
|
||||
let waveform =
|
||||
wellen_helpers::read_from_bytes(include_bytes!("../../test_files/simple.vcd").to_vec());
|
||||
fn load_waveform(test_file_name: Rc<String>, store: tauri::State<Store>) {
|
||||
static SIMPLE_VCD: &'static[u8; 311] = include_bytes!("../../test_files/simple.vcd");
|
||||
static WAVE_27_FST: &'static[u8; 28860652] = include_bytes!("../../test_files/wave_27.fst");
|
||||
let chosen_file = match test_file_name.as_str() {
|
||||
"simple.vcd" => SIMPLE_VCD.to_vec(),
|
||||
"wave_27.fst" => WAVE_27_FST.to_vec(),
|
||||
test_file_name => todo!("add {test_file_name} to the `test_files` folder")
|
||||
};
|
||||
let waveform = wellen_helpers::read_from_bytes(chosen_file);
|
||||
let Ok(waveform) = waveform else {
|
||||
panic!("VCD file reading failed")
|
||||
};
|
||||
|
|
BIN
test_files/wave_27.fst
Normal file
BIN
test_files/wave_27.fst
Normal file
Binary file not shown.
Loading…
Reference in a new issue