- If you are setting the Constant block value using set_param() based on the selection in second Popup, then this is the wrong implementation if you want to put it in a libarary. Instead, you should set the value of the Constant block as "Pop2" and name the parameter for the second Popup as "Pop2". In other word, pass the masked parameter to the Constant block.
- If you have to use set_param() to set the value of the Constant block, then you need to add a callback to the CopyFcn of the library block, which will automatically disable the library link once the block is dropped to the model. This is not ideal because all the library links will be broken. But it had to be done if all the blocks dropped to the model end up differently due to set_param(). Remember, all the blocks in the model are supposed to be an exact copy of the library block except the allowed parameters. If your blocks in the model end up diffrently due to the selection in Popup in the mask, then you have a problem and you have to deal with it accordingly.
- Look for "Parameterized Links and Self-Modifiable Linked Subsystems" in the document. I believe your issue stems from this topic. Option 1 and 2 above are easy solutions if they are acceptable. This document should provide full details.
One of the Mask Parameters getting reset in Entire Model while saving Custom Library.
5 次查看(过去 30 天)
显示 更早的评论
I have created a masked subsystem which has three fields:
- Edit field to choose data dictionary name. Based on this selection, the masked block reads the dictionary and finds out all the enumerations present in the dictionary.
- First Popup to list all Enumerations found in data dictionary [Populates Based on callback added in Edit field] and make selection as per User Click. (Variable name --> enum_datatype)
- Second Popup to create list of values based on Enum Selection made in First Popup [Populates Based on callback added in First Popup]. (Variable name --> enum_params)
First Popup is then used to write Output Datatype of a Constant block and its Value (of constant block) is written from Second Popup.
This is working fine and masked subsystem is able to update underlying Constant block as per selections done. I have made it a custom library for my model and using it at many places then.
However while saving custom library, First Popup variable (enum_datatype) still holds its values but Second Popup variable (enum_params) resets itself. Due to this in model, wherever this block is used, second variable (enum_params) in all of them gets reset. This happens also while compiling the model.
I have tried debugging the Mask initialization code and variable is resetted even before Mask Initialization has been called. I have also tried checking all attributes and they all are set to "Evaluate, Tunable, Enable and Visible". Remaining attributes like "Read Only, Hidden and Never Save" are not ticked.
Please help me on getting solution for this! I am not sure what is resetting it.
Thanks in advance.
0 个评论
采纳的回答
Fangjun Jiang
2021-4-13
Things like this usually gets complicated when it is put in a library.
Without the actual model, I could guess:
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Author Block Masks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!