Custom Library Blocks get reset to default value every time the model is closed.

4 次查看(过去 30 天)
I have developed a small custom library for the logic that I reuse multiple times in the model of my current project. All these blocks have masks, such that, for example, if I enter the value "48" in the Edit Field on the mask dialog box, then the value of certain constant blocks inside the library block gets changed to 48. All blocks have "Modified parameter in link" written, since I'm changing the default value of the mask parameter. However, the value of all constant blocks inside these library subsystems gets reset to the default value whenever I try to build the model or open it again after closing (in short, the changes inside the blocks aren't being saved). Can anyone assist me with this?
I have attached a screenshot to show what my library block looks like in terms of the library links. Thanks in advance.

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2023-1-11
This is caused by improper mask or improper usage of a custom library block.
The proper way is to specify the Constant block value in the library as 'MyConst', mask it using the Edit field 'MyConst'.
In the model, drop the first copy, specify the value as 48. Drop a second copy, specify the value as 49.
In this case, the two Constnat blocks are still the same as the Constant block in the library. It's value is 'MyConst'.
For whatever reason, your usage caused a "Parameterized Link", which means in the first copy, the Constant value is 48, in the second copy, the Constant value is 49. That is what the text "Modified parameter in link" indicates.
The "Parameterized Link" should still be saved with the model and should not reset to the same as the library. Either your description of the problem is inaccurate, or, the Parameterized Link is somewhere else in the library but your Constant block value got reset. But still, how could the Constant block value got changed but the library link is still intact?
Anyway, Look at the document link below. There is a way to find out if there are Parameterized Links in the model. Parameterized Link shall be avoided if possible.
  2 个评论
Mihir Tasgaonkar
Mihir Tasgaonkar 2023-1-12
Hi, I'll try to explain my problem in a better way as far as possible. There exists a Data Store Memory and Data Store Read inside my masked subsystem. I have an Edit Field, and I have written a mask evaluation code, so that if the user enters "Current" on the mask's edit field, then the value of the 'DataStoreName' of the Data Store Memory and Data Store Read inside gets changed to "Current_Enable". The default value of the Edit Field in the library is "Variable", and my expectation is that the user can change this to "Current" or "Voltage" or whatever he/she wishes to.
The issue is, whenever I double click on my masked subsystem and change the Edit Field from "Variable" to "Current", it gives me a warning saying "Changing parameters of a block within a link. These changes can later be discarded or propagated to the library". When I click on OK, the DataStoreName of the Memory and Read block gets changed as I want it to. But after I close the model and reopen it, when I click on "Look Under Mask" before double-clicking the mask, I can see that the memory and read blocks have been reset to "Variable". If I double click and then look under the mask, I can see it as "Current", since the mask initialization code is run when I double click and the changes are applied inside the subsystem. I want to keep the changes saved without having to manually double click on the blocks every time.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Subsystems 的更多信息

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by