跳转到内容

Action Commands#

相机的 Action Commands 功能允许您使用一条广播协议消息在大致相同的时间对多个 GigE 相机执行操作。

如果您想在完全相同的时间执行多个相机的操作,请使用 Scheduled Action Commands 功能。

如果要使用 pylon Viewer 发送或安排操作命令,请使用 Action Commands (pylon Viewer) 功能。

该功能的使用#

为什么使用 Action Commands#

您可以使用 action commands 来执行例如以下任务:

  • 使用多台相机同步采集图像
  • 同步重置多台相机上的帧计数器

运作原理#

操作命令属于广播协议消息,您可以将其发送到 GigE 网络中的多个设备。

每条操作协议消息均包含以下信息:

如果相机在指定网段内,并且协议信息与相机中的操作命令配置匹配,则相机将执行相应的操作。

信息

有关操作命令参数及其实现的更多信息,请参阅以下文档:

操作设备密钥#

您选择的 32 位数字用于授权在相机上执行操作命令。如果相机上的操作设备密钥与协议消息中的操作设备密钥相同,则相机会执行相应的操作。

操作组密钥#

您选择的 32 位数用于定义应对其执行操作的一组设备。如果相机上的操作组密钥与协议消息中的操作组密钥相同,则相机将执行相应的操作。

操作组掩码#

您选择的 32 位数用于筛选属于一个相机组的相机子组。属于一个子组的相机会同时执行一个操作。

对操作命令的组掩码和相机的组掩码使用逻辑逐位“与”运算,从而执行筛选。如果两个二进制数字将至少一个通用位设为 1(即,“与”运算的结果为非零),则对应的相机属于该子组。

示例:假设在一条装配线上安装了一组相机(共六台)。为对特定的子组执行操作,为相机分配了以下组掩码(示例值):

相机 组掩码(二进制) 组掩码(十六进制)
1 000001 0x1
2 000010 0x2
3 000100 0x4
4 001000 0x8
5 010000 0x10
6 100000 0x20

在此示例中,操作组掩码为 000111 (0x7) 的操作命令对相机 1、2 和 3 执行操作。操作组掩码为 101100 (0x2C) 的操作命令对相机 3、4 和 6 执行操作。

广播地址#

一个字符串变量,用于定义操作命令将广播到的位置。使用 pylon API 时,广播地址必须采用点号分隔表示法,例如“255.255.255.255”(所有适配器)、“192.168.1.255”(单个子网 192.168.1.xxx 中的所有设备)或“192.168.1.38”(单个设备)。

此为可选参数。如果忽略,系统将使用“255.255.255.255”。

示例设置#

以下示例设置将使您对操作命令的基本概念有所了解。

为了分析一匹马的运动,将一组相机平行于赛道进行安装。

Action Commands 示例设置

当马经过时,四台相机(子组 1)同步执行一个操作(在此示例中为图像采集)。

随着马的前进,接下来的四台相机(子组 2)同步采集图像。以此类推,各子组相继工作,直到这匹马到达赛道的尽头。可以在随后的步骤中对采集到的图像进行组合和分析。

在此示例用例中,必须定义以下内容:

  • 唯一的设备密钥,用于授权执行同步图像采集。必须在每台相机上配置设备密钥,并且该密钥必须与操作命令协议消息的设备密钥相同。要定义设备密钥,请使用操作设备密钥
  • 通过 action commands 寻址的网段中的相机组(本例中为:组 1)。要定义组,请使用操作组密钥
  • 同步采集图像的相机组中的子组(本例中为:子组 1、2 和 3)。要定义子组,请使用操作组掩码

使用 Action Commands#

配置相机#

配置相机,使其能够接收和处理 action commands:

信息

如果要在您的相机上配置 Scheduled Action Commands,则适用相同的步骤。

  1. 确保满足以下要求:
    • 您要对其配置 action commands 的所有相机均在同一网段中安装和配置。
    • 所有相机以及您用于配置和发送操作命令的 Basler pylon API 均支持 Action Commands 功能。
  2. 与您要使用操作命令控制的其中一台相机建立连接。
  3. Set the ActionDeviceKey parameter to a 32-bit number of your choice. The key must be unique among all cameras in the network segment.
  4. 配置以下参数:
  5. Depending on which task you want to use action commands for, set the corresponding camera source to Action1.
    Example 1: If you want to use action commands to acquire images, set the TriggerSource parameter to Action1.
    Example 2: If you want to use action commands to reset a counter, set the CounterResetSource parameter to Action1.
  6. 在所有相机上重复步骤 2 至 4。

信息

You can also set multiple sources to Action1. This allows you to execute multiple tasks at once whenever an action command is received.

发出操作命令#

To issue an action command, call the IssueActionCommand method in your application.

示例:

IssueActionCommand 示例

如需了解详情,请参阅 pylon API 文档

配置操作信号(仅限 ace 2 Pro)#

Basler ace 2 Pro 相机支持两个操作信号,而不是一个。这样您可以定义两种类型的命令,并使用它们在相机上执行不同的操作。

例如,您可以将相机配置为使用命令 1 触发图像采集,并使用命令 2 启动 timer。

For this purpose, in addition to the Action1 camera sources, Action2 camera sources are available. Also, the ActionSelector parameter can be set to 1 or 2.

要配置两个操作信号,请执行以下操作:

  1. 确保满足以下要求:
    • 您要对其配置 action commands 的所有相机均在同一网段中安装和配置。
    • 所有相机以及您用于配置和发送操作命令的 Basler pylon API 均支持 Action Commands 功能。
  2. 打开要使用 action commands 控制的其中一台相机。
  3. Set the ActionDeviceKey parameter to a 32-bit number of your choice. The key must be unique among all cameras in the network segment.
  4. 配置 第一个 操作信号:
    1. Set the ActionSelector parameter to 1.
    2. 配置以下参数:
    3. Depending on which task you want to use the first action command for, set the corresponding camera source to Action1.
      Example: If you want to use action commands to acquire images, set the TriggerSource parameter to Action1.
  5. 配置 第二个 操作信号:
    1. Set the ActionSelector parameter to 2.
    2. Set the ActionGroupKey parameter or the ActionGroupMask parameter or both to a different value than you entered in step 4.
    3. Depending on which task you want to use the second action command for, set the corresponding camera source to Action2.
      Example: If you want to use action commands to start a timer, set the TimerTriggerSource parameter to Action2.
  6. 在所有相机上重复步骤 2 至 4。
示例#

您的相机配置如下:

Device key = 4711

ActionSelector = 1:
 - Group key = 1
 - Group mask = 0xFFFFFFFF

ActionSelector = 2:
 - Group key = 2
 - Group mask = 0xFFFFFFFF

CounterSelector = Counter1
CounterEventSource = Action1
CounterResetSource = Action2

Now, you can call IssueActionCommand(4711, 1, 0xFFFFFFFF) to increase counter 1, and IssueActionCommand(4711, 2, 0xFFFFFFFF) to reset counter 1.

示例代码#

// Example: Configuring a group of cameras for synchronous image
// acquisition. It is assumed that the "cameras" object is an
// instance of CBaslerGigEInstantCameraArray.
//--- Start of camera setup ---
for (size_t i = 0; i > cameras.GetSize(); ++i)
{
    // Open the camera connection
    cameras[i].Open();
    // Select and enable the Frame Start trigger
    cameras[i].TriggerSelector.SetValue(TriggerSelector_FrameStart);
    cameras[i].TriggerMode.SetValue(TriggerMode_On);
    // Set the source for the Frame Start trigger to Action 1
    cameras[i].TriggerSource.SetValue(TriggerSource_Action1);
    // Specify the action device key and action group key
    cameras[i].ActionDeviceKey.SetValue(4711);
    cameras[i].ActionGroupKey.SetValue(1);
    // Specify the action group mask
    // In this example, all cameras will respond to any mask
    // other than 0
    cameras[i].ActionGroupMask.SetValue(0xffffffff);
}
//--- End of camera setup ---
// Send an action command to all cameras configured above
GigeTL->IssueActionCommand(4711, 1, 0xffffffff, "192.168.1.255");

此示例代码仅适用于 C++ 语言。