最近
在鼓捣simulink的开发环境,想做一个加载数据字典的功能。
自定义封装一个模块,将其放在模型最顶层,双击此模块,可实现运行自定义脚本,从而加载数据字典。
![d5c3310f0b57d4d7a30db05be14d4d98.png](https://img-blog.csdnimg.cn/img_convert/d5c3310f0b57d4d7a30db05be14d4d98.png)
话不多说,在自定义lib中,创建一个新的空subsystem,然后加上mask,加上openfcn,如下图所示
![7079bf0a5abcd95ddb4043baa26bf832.png](https://img-blog.csdnimg.cn/img_convert/7079bf0a5abcd95ddb4043baa26bf832.png)
![25752cd3ec91521d90166867596c412f.png](https://img-blog.csdnimg.cn/img_convert/25752cd3ec91521d90166867596c412f.png)
设置完毕,保存自定义库文件my_lib,运行slblocks;
Browser.Library = 'my_lib';
Browser.Name = 'my_lib';
blkStruct.Browser = Browser;
结果打开library Browser一看,很意外,库是空的。
![1d1bea3bf58f5417286f6cc73f3677d7.png](https://img-blog.csdnimg.cn/img_convert/1d1bea3bf58f5417286f6cc73f3677d7.png)
明明我的库文件中,含有我自定义的模块,怎么会消失呢?
![d5c3310f0b57d4d7a30db05be14d4d98.png](https://img-blog.csdnimg.cn/img_convert/d5c3310f0b57d4d7a30db05be14d4d98.png)
试来试去,发现问题出在OpenFcn上。取消OpenFcn,或者将load命令,换到其他callback函数,消失的模块会重现。
额,难道说,有OpenFcn的空subsystem模块不配出现在Browser中?
不可能,上百度,中文网上没出现任何问题结果。
上mathwork社区,终于找到一个答案:
![1d2f5ea3045614222c9bda94fc07f1b8.png](https://img-blog.csdnimg.cn/img_convert/1d2f5ea3045614222c9bda94fc07f1b8.png)
按照答案,编辑mask的parameter。
![43a20e72e007b517e4766031dcbd3026.png](https://img-blog.csdnimg.cn/img_convert/43a20e72e007b517e4766031dcbd3026.png)
成功,自定义模块出现在browser中。
![14a345db3c981b8717ac151c45ce7055.png](https://img-blog.csdnimg.cn/img_convert/14a345db3c981b8717ac151c45ce7055.png)
撒花,下班。