ekiwi / wellen

wellen: waveform datastructures in Rust. Fast VCD, FST and GHW parsing for waveform viewers.
BSD 3-Clause "New" or "Revised" License
41 stars 8 forks source link

Feature request: Get values of parameters without first loading them #20

Closed oscargus closed 3 months ago

oscargus commented 3 months ago

While working on https://gitlab.com/surfer-project/surfer/-/merge_requests/442 I am now in a state where I got stuck in a multiple mutable borrow scenario that I do not know how to handle.

This could all be avoided if parameters are always loaded. I do not understand enough about the mut aspects (I understand what it is, but not the borrow concepts) to say if one possibly can have this lazy loaded on first access. I tried something like that in the MR above, but it just got me into trouble...

The use case is to be able to display the value of the parameter (which shouldn't change, so just a single value must be loaded) in the variable/scope list. Maybe it can be an opt-in or a command that loads all parameters or something? (I can probably implement the latter in Surfer, but I guess it may be more efficient to do it in Wellen?)

ekiwi commented 3 months ago

I think this should be easier (not necessarily easy) to solve in Surfer. Surfer uses the advanced API and thus manages the signal loading very manually.

oscargus commented 3 months ago

Fair enough, I managed to get a list of all parameters. Just have to figure out how to actually load them (without adding them...).

ekiwi commented 3 months ago

You need to call load_variables on the wave container. Similar to what add_variables does here, but skipping the actual addition to the displayed items.

https://gitlab.com/surfer-project/surfer/-/blob/main/surfer/src/wave_data.rs?ref_type=heads#L387

You also need to make sure to use the return value, which will trigger the actual loading: https://gitlab.com/surfer-project/surfer/-/blob/main/surfer/src/main.rs?ref_type=heads#L726

Then where ever you use the value, needs to be able to deal with the data not being available yet, since the load_variables command will compete in the background.

oscargus commented 3 months ago

Thanks! I think the current things is the missing unwrap. (Did mean to close this the last time, so doing it now. May still comment here for additional questions though...)