我想在CAPL代码中进行特定函数调用后在C#中执行代码

发布于 2025-02-11 21:00:26 字数 446 浏览 2 评论 0原文

我的C#代码启动并执行CAPL代码,但是当任何特定功能时,例如。 ABC(int a)由CAPL内部调用,然后我想在C#中发送参数“ A”的数据并执行计算并将结果发送回相同函数“ ABC”,而CAPL代码应恢复ABC()的执行返回一个值,该值应来自我计算的C#代码。

我的问题:

  1. 我不知道何时调用ABC函数(ABC只是示例示例实际函数是预定义的),因此,想知道何时调用此函数并在C#中获取参数。
  2. 我通过在C#中使用“ Onchange”方法尝试,但是在执行后完成函数“ ABC”之后的工作。因此,这是没有用的,因为不维护同步,并且CAPL返回默认值。
  3. 尝试使用“计时器”方法,但与CAPL相同的同步问题并没有阻止执行,直到计时器才能继续执行。
  4. 尝试使用计时器时使用时循环,但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:

  1. 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#.
  2. 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.
  3. Tried using "timer" method but same issue of synchronization as CAPL is not stopping the execution it continues the execution till the timer.
  4. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮年慕年 2025-02-18 21:00:26

从独木舟版本12.0 SP3

搜索 .net dll 的详细信息以获取 .net dll 以获取详细信息。

基本上,您可以创建一个.NET函数,就像

namespace ns {
  public class Clazz {
    public static Int32 Func(Int32 a) {
      ...
      return a;
    }
  }
}

它必须是静态的,公共的和公共课程一样。
仅允许某些数据类型作为参数并返回值。

必须以与CAPL-DLL相同的方式添加编译的.NET DLL。

然后从CAPL调用该函数,然后看起来像这样:

retVal = ns::Clazz::Func(17);

如果您必须早于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

namespace ns {
  public class Clazz {
    public static Int32 Func(Int32 a) {
      ...
      return a;
    }
  }
}

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:

retVal = ns::Clazz::Func(17);

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文