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