0
votes

I've created a simulink block that stores data selected from a dbc file using a uitree. The data selected from the uitree is then stored in the block. My problem is that when the dbc file is loaded, it takes 10-15 seconds for the uitree to fully populate, which is fine for the first time the tree is created, but would be relatively inconvenient if there are multiple of these blocks, especially because my simulink model could potentially require over a dozen of these blocks. Having to recreate the uitree a dozen times, 15 seconds each time, would waste a decent chunk of time.

Little more background on how the code currently runs:

My custom made block is dropped into the simulink model. The user clicks on the block. The block calls a matlab script. This script then prompts the user with a uigetfile to select a dbc. The matlab script then collects data from the dbc file and populates the uitree with it. The uitree could have a hundred nodes, each potentially with 2-40 subnodes, which is why it takes so long to generate. The current issue is this would have to happen for every single custom block in the model.

Is there a way to cache the uitree, or some way that simulink/matlab could remember the uitree the first time it is loaded from a particular dbc file? This way, the next time a block attempts to open the it, it only takes a few seconds to open the tree that was previously generated, instead of completely recreating the uitree multiple times?

Thank you

1
I would advice to add some of the code you tried into your question. It will increase the chances of getting an answer and reduce the chances of having your question flagged and removed.acarlstein

1 Answers

0
votes

Presuming that the uitree is rendered in a MATLAB figure window, the current problem is that each time the figure is closed all of the data in it is destroyed. What you need to do is write a CloseFcn for your figure so that instead of being destroyed it just becomes invisible.

You will also need to add code so that,

  • every time a block is opened (i.e. a dbc file is selected) you check to see if a figure window displaying that dbc uitrees exists. If it does then make it visible. If it doesn't then create it.
  • handles populating the correct block with the selected data (given that multiple block may be using the same dbc uitree figure window.)
  • handles destroying all figures (whether they are visible or invisible) when the model is closed (by adding code to the model's CloseFcn.)

You could also consider having just one figure containing all dbc uitress that have been opened already, probably by putting each of them on a different uitab panel.