我想在CAPL代码中进行特定函数调用后在C#中执行代码
我的C#代码启动并执行CAPL代码,但是当任何特定功能时,例如。 ABC(int a)由CAPL内部调用,然后我想在C#中发送参数“ A”的数据并执行计算并将结果发送回相同函数“ ABC”,而CAPL代码应恢复ABC()的执行返回一个值,该值应来自我计算的C#代码。
我的问题:
- 我不知道何时调用ABC函数(ABC只是示例示例实际函数是预定义的),因此,想知道何时调用此函数并在C#中获取参数。
- 我通过在C#中使用“ Onchange”方法尝试,但是在执行后完成函数“ ABC”之后的工作。因此,这是没有用的,因为不维护同步,并且CAPL返回默认值。
- 尝试使用“计时器”方法,但与CAPL相同的同步问题并没有阻止执行,直到计时器才能继续执行。
- 尝试使用计时器时使用时循环,但CAPL滞后,并且CANEO停止工作,
我希望不需要示例代码,因为我只需要一个函数
My C# code starts and executes the CAPL code but when any specific function eg. abc(int a) is called internally by CAPL then I want to send data of parameter "a" in C# and perform calculation and send result back to same function "abc" and CAPL code should resume its execution from abc() as this function returns a value and that value should be from my calculated C# code.
My issues:
- I dont know when abc function is called (abc is just en example actual function is predefined) So, want to know when this function is called and get parameters in C#.
- I tried by using "onchange" method in C# but onchange works after execution is completed of function "abc". So, this is not useful as synchronization is not maintained and CAPL returns a default value.
- Tried using "timer" method but same issue of synchronization as CAPL is not stopping the execution it continues the execution till the timer.
- Tried using While loop with timer but CAPL gets lagged out and CANeo stops working
I Hope sample code is not required as I just need a function
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从独木舟版本12.0 SP3
搜索 .net dll 的详细信息以获取 .net dll 以获取详细信息。
基本上,您可以创建一个.NET函数,就像
它必须是静态的,公共的和公共课程一样。
仅允许某些数据类型作为参数并返回值。
必须以与CAPL-DLL相同的方式添加编译的.NET DLL。
然后从CAPL调用该函数,然后看起来像这样:
如果您必须早于12.0 SP3的独木舟版本,则必须在C/C ++中创建CAPL DLL,并通过CLI调用C#代码。
Calling C# (or any other .NET) code is actually possible starting from CANoe version 12.0 SP3
Search for .NET DLL in CANoe's help for details.
Basically, you create a .NET function like
It must be static, public and in a public class.
Only certain datatypes are allowed as parameters and return value.
The compiled .NET DLL has to be added to CANoe in the same way as a CAPL-DLL.
Calling the function from CAPL then looks like this:
If you have to use a CANoe version earlier than 12.0 SP3, you would have to create a CAPL DLL in C/C++ and call you C# code via CLI.