简体   繁体   English

如何将模拟上下文传递到 Scilab C 块中?

[英]How to pass simulation context into Scilab C block?

I have been developing my own function block in Scilab/Xcos on the C block basis and I have been struggling with passing parameters defined in the simulation context into the C code.我一直在 C 块基础上在 Scilab/Xcos 中开发自己的 function 块,我一直在努力将模拟上下文中定义的参数传递到 C 代码中。 Does anybody know how to do that?有人知道该怎么做吗? Thanks in advance for any ideas.提前感谢您的任何想法。

I have found functional solution.我找到了功能解决方案。 Let's say I have following parameters defined in the simulation context: T, RS, RR, LL, LM, pp, K .假设我在模拟上下文中定义了以下参数: T, RS, RR, LL, LM, pp, K In case I place instance of the C block into the simulation and double click on it following window opens如果我将 C 块的实例放入模拟中并在 window 打开后双击它

在此处输入图像描述

Then I fill in the parameters which I want to pass into the C block instance (text field Real parameters vector).然后,我将要传递给 C 块实例的参数填入(文本字段实际参数向量)。 The parameters values are then accessible in the C language code inside the C block via block->rpar[0] (parameter Ts), block->rpar[1] (parameter RS), block->rpar[2] (parameter RR), block->rpar[3] (parameter LL), block->rpar[4] (parameter LM), block->rpar[5] (parameter pp), block->rpar[6] (parameter K)`.然后可以通过block->rpar[0] (参数 Ts)、 block->rpar[1] (参数 RS)、 block->rpar[2] (参数 RR)在 C 块内的 C 语言代码中访问参数值), block->rpar[3] (参数LL), block->rpar[4] (参数LM), block->rpar[5] (参数pp), block->rpar[6] (参数K)` .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM