SIMULINK中S功能(C代码)的多实例用法 [英] Multi-Instance usage of S-Functions (C code) in SIMULINK

查看:190
本文介绍了SIMULINK中S功能(C代码)的多实例用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的SIMULINK模型中有一个旧版C函数,该函数在其函数中使用一些静态变量。静态变量全局可用。当我引用模型的多个实例时,出现错误,因为未为此配置S函数。我收到此错误消息是因为代码生成不允许这样做。

I have a legacy C function in my SIMULINK model that uses some static variables in its functions. The static variables are available globally. When I reference multiple instance of my model, I get error because my S-function is not configured for that. I am getting this error message because code generation doesn't allow this.

我收到的错误消息如下:

The error message I get is the following:


在多实例普通模式下不支持S功能块'ECDCTRL / PULDESC / S-Function Builder',因为它没有声明它支持多个执行实例。如果S-Function满足多个执行实例的要求,则可以在'mdlSetWorkWidths'方法中使用SimStruct函数'ssSupportsMultipleExecInstances'进行声明。

The S-Function block 'ECDCTRL/PULDESC/S-Function Builder' is not supported in multi-instance Normal mode because it does not declare that it supports multiple execution instances. If the S-Function satisfies the multiple execution instances requirements, you can declare this using the SimStruct function 'ssSupportsMultipleExecInstances' in the 'mdlSetWorkWidths' method.

使用自动生成的代码构建文件时,我正在使用(MYSFUNC)_Outputs_Wrapper.c 文件。使用模型的多个引用时,如何确保可以使用旧版C函数? SIMULINK网站建议使用 ssSupportsMultipleExecInstances(SimStruct * S,bool flag)方法,但这是不正确的,因为我没有使用 SimStruct 头文件。怎么回事?

I am using the (MYSFUNC)_Outputs_Wrapper.c file when I build it with the auto-generated code. How can I make sure that I can use my legacy C function when using multiple references of my model? SIMULINK website suggests using ssSupportsMultipleExecInstances(SimStruct *S, bool flag) method, but it is not correct as I am not using the SimStruct header files. What is the way around?

推荐答案

使用DWork向量代替静态变量。引用自此处

Use DWork vectors instead of static variables. Quoting from here:


DWork向量具有几个优点:

DWork vectors have several advantages:

Provide instance-specific storage for block variables
Eliminate static and global variables


这篇关于SIMULINK中S功能(C代码)的多实例用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆