CPAL脚本自动化测试 ———— Panel & Variables 系列函数

callAllOnEnvVar

使用方法

在这里插入图片描述

函数作用

 调用环境变量的所有事件过程(在 envVar 上)。 这在测量开始时可能是必要的,以初始化环境变量,启动响应环境变量变化的计时器,或使用环境变量的起始值在总线上发送消息。

示例

on start
{
callAllOnEnvVar();
}

ClockControlReset

使用方法

在这里插入图片描述

函数作用

 使用面板设计器重置设计为秒表的时钟控制(设置模式 = 秒表)。显示时间重置为 00:00:00 或 00:00,具体取决于面板设计器设置显示秒数。秒表无法重置 已经开始。 该面板通过在面板设计器中输入的单个面板名称进行访问。面板名称限制为 128 个字符。

示例

// Reset the clock control designed as stop watch.
on key 'a'
{
ClockControlReset("ClockControl", "StoppWatch");
}

ClockControlStart

使用方法

在这里插入图片描述

函数作用

 启动在 Panel Designer 中设计为秒表的时钟控制(设置模式 = 秒表)。秒表从 00:00:00 或 00:00 开始,具体取决于 Panel Designer 设置显示秒。 不能更改开始时间。秒表每秒更新一次。当秒表已经在运行时无法启动。通过面板设计器中输入的单个面板名称访问面板。面板名称限制为 128 个字符 .

示例

// Start the clock control designed as stop watch.
on key 'a'
{
ClockControlStart("ClockControl", "StoppWatch");
}

ClockControlStop

使用方法

在这里插入图片描述

函数作用

 停止使用 Panel Designer 设计为秒表的时钟控件(设置模式 = 秒表)。除非用户再次启动秒表或将其重置,否则显示的时间保持不变。如果秒表在未重置的情况下再次启动,则开始时间 是当前显示的时间(非零)。通过面板设计器中输入的面板名称访问面板。面板名称限制为 128 个字符。

示例

// Stop the clock control designed as stop watch.
on key 'a'
{
ClockControlStop("ClockControl", "StoppWatch");
}

closePanel

使用方法

在这里插入图片描述

函数作用

 关闭面板。通过面板设计器中输入的单个面板名称访问该面板。如果 CANoe 配置中存在多个具有相同名称的面板,则此命令会对所有这些面板产生影响。

DeleteControlContent

使用方法

在这里插入图片描述

函数作用

 删除面板设计器 CAPL 输出视图的内容。通过面板设计器中输入的单个面板名称访问面板。面板名称限制为 128 个字符。

示例

// Deletes the contents of a specific CAPL Output View control in the panel motor
DeleteControlContent(„motor“, „Outputview“);

// Deletes the contents of all CAPL Output View controls in the panel motor
DeleteControlContent(„motor“, „“);

// Deletes the contents of all CAPL Output View controls in all panels
DeleteControlContent(„“, „“);

enableControl

使用方法

在这里插入图片描述

函数作用

 某些面板控件的选择性激活和停用。如果控件和显示元素配置为简单显示,则此命令将不会影响相关元素。元素的打开或关闭状态在开始时保持不变/ 测量结束。 因此,应该为所涉及元素的测量开始创建一个定义的状态。面板名称限制为 128 个字符。
 参数enable的解释:
  0 —— turn off (disable)
  1 —— turn on (enable)

示例

on key 'a'
{
// enables a specific control of the "motor" panel
enableControl("motor", "PedalPos", 1);

// enables all controls of the panel
enableControl("motor", "PedalPos", 1);
}

getValueSize

使用方法

在这里插入图片描述

函数作用

 以字节为单位返回环境变量值的大小。对于字符串类型的环境变量,将返回字符串长度加上终止空字符。 对于形式 2,编译器无法检查 name 是否实际指定了正确类型的环境变量。 如果不是,则在运行时的写入窗口中将出现一条错误消息。

示例

int vSize;
// Size of the data of an environment variable of type integer
vSize = getValueSize(switch);
// Buffersize of an environment variable of type string
// (with terminating Null character)
vSize = getValueSize(nodename);
// Size of the data byffer of an environment variable of type data
vSize = getValueSize(DiagData);

MakeRGB

使用方法

在这里插入图片描述

函数作用

 从三个主要颜色分量计算颜色值。该值被解释为 4 个字节,颜色结果来自哪个值包含在哪个字节中:
  [0] = 忽略
  [1] = 红色
  [2] = 绿色
  [3] = 蓝色

示例

MakeRGB(255, 128, 0); // orange color

MakeARGB

使用方法

在这里插入图片描述

函数作用

 根据 alpha 值和三个主要颜色分量计算颜色值。该值被解释为 4 个字节,颜色结果来自哪个值包含在哪个字节中:
  [0] = Alpha(透明度)
  [1] = 红色
  [2] = 绿色
  [3] = 蓝色
&esmp;这里额外的说明一下alpha这个参数的取值范围[0,255]。

示例

MakeARGB(64, 255, 128, 0); // 25% opacity of orange color

openPanel

使用方法

在这里插入图片描述

函数作用

 打开一个面板。通过面板设计器中输入的单个面板名称访问该面板。如果 CANoe 配置中存在多个具有相同名称的面板,则此命令对所有这些面板都有影响

putValueAsync

使用方法

在这里插入图片描述

函数作用

 将值 val 分配给具有标识符 EnvVarName 的环境变量。
  整数分配给离散环境变量(形式 1);
  浮点数分配给连续环境变量(形式 2);
  字符串的内容被分配给字符串环境变量(形式3);
  对于数据字节环境变量(形式 4),数据缓冲区的字节被复制到环境变量中。
 赋值是异步执行的。 当激活测量设置并行化时,测量设置中的其他分支将在调用函数的分支之前或之后看到新值。与 putValue 相比,putValueAsync 不会阻止测量设置分支被并行化。putValueAsync 很有用 在模拟过程中设置环境变量,并在模拟停止后使用 EnvironmentVariable COM 对象读取它们的值。

示例

在这里插入代码片

使用方法

函数作用

示例

在这里插入代码片

使用方法

函数作用

示例

byte dataBuf[64];
// Assign the value 0 to environment variable Switch
putValueAsync(Switch, 0);

// Assign the value 22.5 to environment variable Temperature
putValueAsync(Temperature, 22.5);

// Assign the value Master to environment variable NodeName
putValueAsync(NodeName, "Master");

// Copy 64 bytes of the data buffer into the environment variable DiagData
putValueAsync(DiagData, dataBuf, 64);

putValueToControl

使用方法

在这里插入图片描述## 函数作用
 将值 val 分配给 Panel Designer Multi Display Control 或名称为 control 的 CAPL 输出视图。 Multi Display Control/CAPL Output View 位于带有标题面板的面板上。 多显示器控制/CAPL 输出视图显示不同的内容。 除了数字(浮点数和整数)和文本(char[]),还可以显示不同的消息(CAN、LIN、等等和 J1939 PGN)。使用多显示器控制/CAPL 输出视图,没有环境变量是必要的。

示例

Example: Output of a string, a message, a signal - no additional function parameters used

variables
{
   int value;
message EngineData mEngineData;
}
on envVar EnvShowMultiDisplay
{
   value = getvalue(this);
   switch(value)
   {
      case 1: putValueToControl("Gateway","DisplayControl","This is the Automot Demo!");
         break;
      case 2: putValueToControl("Gateway","DisplayControl",mEngineData);
         break;
      case 3: putValueToControl("Gateway","DisplayControl",mEngineData.EngSpeed.phys);
         break;
   }
}

Example: Output of a message — optional with function parameters

variables
{
...message MyMessage TestMsg;
}

}
on key 'a'
{
//Output of a message without additional parameter settings. In this case parameters have default settings; they are 'no new paragraph' and 'display message in 'hexadecimal' notation'
putValueToControl("TestPanel","ControlOutput1", TestMsg);

//Output of a message, each time in a new paragraph.
putValueToControl("TestPanel","ControlOutput1", TestMsg, 1);

//Output of a message, each time with a new paragraph and the message is displayed in decimal notation.
//putValueToControl("TestPanel","ControlOutput1", TestMsg, 1, 0);
}

Example: Output of a signal (raw format) — optional with function parameters

variables
{
...message MyMessage TestMsg;
}

}
on key 'b'
{
//Output of a signal (raw) without additional parameter settings.
//In this case parameters have default settings;
//they are 'no new paragraph' and display signal in 'decimal' notation.
putValueToControl("TestPanel","ControlOutput1", "\nSignal raw\n");
putValueToControl("TestPanel","ControlOutput1", TestMsg.Signal1);

//Output of a signal (raw), each time in a new paragraph.
putValueToControl("TestPanel","ControlOutput1", TestMsg.Signal1, 1);

//Output of a signal (raw), each time in a new paragraph and in hexadecimal notation.
putValueToControl("TestPanel","ControlOutput1", TestMsg.Signal1, 1, 1);
}

Example: Output of a signal (physical format) — optional with function parameters

variables
{
...message MyMessage TestMsg;
}

}
on key 'c'
{
//Output of a signal (physical) without additional parameter settings.
//In this case parameters have default settings;
//they are 'no new paragraph' and display signal in 'decimal' notation.
putValueToControl("TestPanel","ControlOutput1", "\nSignal raw\n");
putValueToControl("TestPanel","ControlOutput1", TestMsg.Signal1.phys);

//Output of a signal (physical), each time in a new paragraph.
putValueToControl("TestPanel","ControlOutput1", TestMsg.Signal1.phys, 1);
}

SetClockControlTime

使用方法

在这里插入图片描述

函数作用

 设置面板设计器时钟控件的时间。通过面板设计器中输入的单个面板名称访问面板。

示例

// Set the time in hours, minutes, seconds. It will be displayed '10:20:30'.
on key 'a'
{
SetClockControlTime("ClockControl1", "ClockCAPL", 10, 20, 30);
}

// Set the time in seconds. It will be displayed '01:00:00'.
on key 'b'
{
SetClockControlTime("ClockControl1", "ClockCAPL", 3600);
}

SetControlBackColor

使用方法

在这里插入图片描述

函数作用

 设置某些面板控件的背景颜色。通过面板设计器中输入的单个面板名称访问面板。

示例

// Set the background color for a specific control of a panel
SetControlBackColor("motor", "PedalPos", MakeRGB(255,0,0));

// All controls of the panel are set to the same background color
SetControlBackColor("motor", "", MakeRGB(255,0,0));

// All controls of all panels are set to the same background color
SetControlBackColor("", "", MakeRGB(255,0,0));

SetControlColors

使用方法

在这里插入图片描述

函数作用

 设置某些面板控件的背景和文本颜色。通过面板设计器中输入的单个面板名称访问面板。

示例

//Set the background and text color for a specific control of a panel
SetControlColors("motor", "PedalPos", MakeRGB(255,0,0), MakeRGB(0,0,255));

//All controls of the panel are set to the same background and text color
SetControlColors("motor", "", MakeRGB(255,0,0), MakeRGB(0,0,255));

//All controls of all panels are set to the same background and text color
SetControlColors("", "", MakeRGB(255,0,0), MakeRGB(0,0,255));

SetControlForeColor

使用方法

在这里插入图片描述

函数作用

 设置某些面板控件的前景色。通过面板设计器中输入的单个面板名称访问面板。

示例

// Set the foreground color for a specific control of a panel
SetControlForeColor("motor", "PedalPos", MakeRGB(255,0,0));

// All controls of the panel are set to the same foreground color
SetControlForeColor("motor", "", MakeRGB(255,0,0));

// All controls of all panels are set to the same foreground color
SetControlForeColor("", "", MakeRGB(255,0,0));

SetControlProperty

使用方法

在这里插入图片描述

函数作用

 设置面板编辑器 ActiveX 控件的属性。也可以设置 OCX 面板的属性。 因此,该属性必须定义为要在 OCX INI 文件中设置的属性。面板通过在面板编辑器中输入的单个面板名称访问。通过 makeRGB 访问颜色属性更容易。直到并包括 CANoe 版本 12.0 SP2,函数 makeRGB 在第二个字节中返回蓝色值,在第四个字节中返回红色值。接收此值作为参数的函数解释此交换,以便正确显示颜色。 从 CANoe 12.0 SP3 开始,函数 makeRGB 以正确的顺序返回颜色值。接收此值作为参数的函数也已调整为再次显示正确的颜色。 如果您没有使用函数 makeRGB 但您已经通过了颜色硬编码,则仅需要调整现有程序。

示例

SetControlProperty("Measurements", "StatusIndicator", "Caption", "running");
SetControlProperty("Measurements", "StatusIndicator", "BackColor", MakeRGB(0,145,255));

SetControlVisibility

使用方法

在这里插入图片描述

函数作用

 设置所有面板控件的可见性。通过面板设计器中输入的单个面板名称访问面板。

示例

// Set the visibility for a specific control of a panel
SetControlVisibility("motor", "PedalPos", 1);

// All controls of the panel are set to not visible
SetControlVisibility("motor", "", 0);

// All controls of all panels are set to visible
SetControlVisibility("", "", 1);

SetDefaultControlColors

使用方法

在这里插入图片描述

函数作用

 设置面板设计器中定义的某些面板控件的背景和文本颜色。通过面板设计器中输入的单个面板名称访问面板。

示例

//Set the default background and text color for a specific control of a panel.
SetDefaultControlColors("motor", "PedalPos");

//All controls of the panel are set to the default background and text color as defined in the Panel Designer.
SetDefaultControlColors("motor", "");

//All controls of all panels are set to the default background and text color as defined in the Panel Designer.
SetDefaultControlColors("", "");

SetMediaFile

使用方法

在这里插入图片描述

函数作用

 在运行时替换面板设计器媒体播放器控件的媒体文件。通过面板设计器中输入的单个面板名称访问面板。

示例

//Setting media file using absolute path.
on key 'x'
{
SetMediaFile("Movie", "Media Player", "D:\\Example\\MediaPlayerProject\\Videos\\song.mpg");
}

//Setting media file using relative path. The media file is in the Videos folder and this folder is parallel to the panel folder.
on key 'y'
{
SetMediaFile("Movie", "Media Player", "..\\Videos\\song.mpg");
}

SetMediaStream

使用方法

在这里插入图片描述

函数作用

 在运行期间替换面板设计器媒体流控件的指定索引处的媒体流。通过面板设计器中输入的单个面板名称访问面板。

示例

//Setting media stream from Ethernet channel 1.
on key 'x'
{
  byte streamId[8] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x00, 0x01 };
  SetMediaStream("AVTP Video H.264", "Media Stream Control", eEthernet, 1, 0, streamId);
}

SetPictureBoxImage

使用方法

在这里插入图片描述

函数作用

 在运行时替换面板设计器图片框控件的图像。通过面板设计器中输入的单个面板名称访问面板。

示例

//Setting image file using absolute path.
on key 'x'
{
SetPictureBoxImage("Movie", "Picture Box", "D:\\Example\\PictureBoxProject\\Images\\Picture.bmp");
}

//Setting image file using relative path. The image is in the Images folder and this folder is parallel to the panel folder.
on key 'y'
{
SetPictureBoxImage("Movie", "Picture Box", "..\\Images\\Picture.bmp");
}

sysSetVariableAsync

使用方法

在这里插入图片描述

函数作用

 将给定的值(数据、值或值[])分配给标识符为 SysVarName 的系统变量。
  数据缓冲区的字节被复制到结构体、通用数据和字节数组系统变量(形式 1)。
  字符串的内容被复制到 String 系统变量(形式 7)。
  浮点数或整数和数组被赋值给对应类型的系统变量(形式2-6)。

 赋值是异步执行的。当测量设置并行化被激活时,测量设置中的其他分支将在调用函数的分支之前或之后看到新值。与 sysSetVariable 函数相比,sysSetVariableAsync 不会阻止测量设置分支被并行化。sysSetVariableAsync在模拟期间设置系统变量并在模拟停止后使用系统 COM 对象读取它们的值很有用。为此,必须将系统变量配置为仅用于分析。 sysSetVariableAsync 函数还可用于结构类型或通用数组类型的系统变量的特定元素。为此,将元素添加到变量的名称中。如果您直接将元素名称提供给函数而不是使用字符串,请在名称前加上 sysvarMember:: 而不是 sysvar::。

示例

byte dataBuf[64];
// Assign the value 0 to system variable Switch
sysSetVariableAsync(sysvar::Switch, 0);

// Assign the value 22.5 to system variable Temperature
sysSetVariableAsync (sysvar::Temperature, 22.5);

// Assign the value Master to system variable NodeName
sysSetVariableAsync (sysvar::NodeName, "Master");

// Copy 64 bytes of the data buffer into the system variable DiagData
sysSetVariableAsync (sysvar::DiagData, dataBuf, 64);
  • 8
    点赞
  • 95
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
diagRequest是一个函数,用于发送诊断请求给目标ECU。它是在CAPL中使用的一个成熟的函数,可以帮助实现自动化测试。具体的格式如下: ``` diagRequest PAS3.* pasDiagReqst; dword diagLen; diagLen = stringToBytes(diagString, rawDiagReqst); diagResize(pasDiagReqst, diagLen); ``` 这个函数主要用于调整诊断对象的大小以匹配指定的参数迭代,或将总线消息的大小设置为给定的字节数。在上述示例中,首先将诊断请求字符串转换为字节数组,然后使用diagResize函数调整诊断对象的大小。 另外,还有其他与诊断相关的函数,如diagResponse用于处理诊断服务的响应,diagSetTarget用于设定诊断目标ECU,diagGenerateKeyFromSeed用于根据种子生成密钥等等。这些函数可以帮助我们完成日常的测试场景的覆盖。\[1\]\[2\] #### 引用[.reference_title] - *1* [CPAL脚本自动化测试 ———— Diag系列常用函数及使用](https://blog.csdn.net/qq_42957717/article/details/117077022)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [CAPL诊断函数解释](https://blog.csdn.net/seekshero/article/details/113863812)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小趴菜_自动驾驶搬砖人

谢谢大爷赏饭吃

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值