--- title: "Cognex Unit Test" slug: "cognex-unit-test" updated: 2023-11-03T16:32:15Z published: 2023-11-03T16:32:15Z canonical: "support.tulip.co/cognex-unit-test" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.tulip.co/llms.txt > Use this file to discover all available pages before exploring further. # 康耐视单元测试 *注意:本技术指南假定具备 Node-RED 和 MQTT 代理配置的基本知识。* ## 目的 本文档概述了将康耐视边缘智能数据(如康耐视 DataMan 设备进行的扫描)转发到 Tulip 的必要流程。 数据将通过 MQTT 从 Cognex Edge Intelligence 网关转发到 Tulip Edge 设备,Tulip Edge 设备充当代理和客户端。然后,Node-RED 将用于接收 MQTT 数据,执行简单的数据处理,并将数据转发到 Tulip 机器属性。 --- ## 康耐视到 Node-RED:MQTT 转发 首先,在康耐视边缘智能平台中配置 MQTT 转发。参考康耐视边缘智能手册 ([linked here](https://support.cognex.com/docs/EI_100/EN/Edge_Intelligence_Reference_Manual.pdf)),从第 91 页开始。 使用任何用户名和密码组合,但一定要记下这一点以及 QoS 设置,因为稍后将在 Tulip Edge 设备中使用。 --- ## 边缘设备上的 Node-RED:MQTT 代理设置 确保 Tulip Edge 设备(Edge MC 或 Edge IO)已打开并连接到互联网。此外,确保它能通过公共网络(如现场 Wi-Fi)或将康耐视网关直接连接到 Tulip Edge 设备的 LAN 端口,从而连接到康耐视 Edge Intelligence 网关。 通过 Tulip Edge 设备的 IP 地址访问其配置门户。 *注意:您的计算机必须与 Edge 设备处于同一网络才能访问此页面。* [Use the first half of this guide](https://support.tulip.co/docs/how-to-enable-and-set-up-the-edge-device-mqtt-broker)配置边缘设备上的 MQTT 代理。使用在康耐视 Edge Intelligence 平台中配置的相同用户名和密码组合。 配置并保存代理后,通过以下任一方式进入 Node-RED 编辑器: * 单击设备配置页面中的 "Node-RED 编辑器 "链接,或 * 在 Web 浏览器中导航至 *:1880 。 使用 [the same guide](https://support.tulip.co/docs/how-to-build-your-first-mqtt-data-source)配置 MQTT "接收 "节点: * 使用与 Edge Intelligence 平台配置相同的 QoS 设置。 * 将 "主题 "设置为 "**康耐视**"。 * 所有其他设置均可保留为默认设置。 部署 Node-RED 流量。观察 MQTT 接收节点下方出现的绿色 "已连接 "消息,确认连接成功。 --- ## Node-RED 到郁金香:消息配置和机器属性 从 Edge Intelligence 平台发送消息,例如使用 DataMan 设备扫描条形码。使用 Node-RED 中的调试节点,观察信息是否以 JSON 字符串的形式出现在调试窗格中。 添加一个**json**解析节点,将**msg.payload**中的数据从 JSON 字符串转换为对象。现在就可以使用**msg.payload** 中的完整信息了。 *注意:DataMan 和其他 Edge Intelligence 设备以高速运行,并会转发它们读取的每个扫描。为提高性能,建议添加一个 RBE 节点。* 例如,*配置 RBE 以阻止 JSON 节点的输出,除非* *msg.cognexBarcodeRead*的*值* *发生变化。* 最后,[使用郁金香标签节点](https://support.tulip.co/docs/how-to-send-data-to-machines-from-edge-devices-using-node-red-and-tulip-tags)将任何需要的数据转发到郁金香机器属性。扫描条形码的内容将在**msg.payload.Trigger.payload.readString** 中找到。 *注:如果在 Tulip Edge Device 以外的设备上运行 Node-RED,请使用[Tulip Machine Attribute Node](https://support.tulip.co/docs/using-node-red-with-edge-mc) ,网址为[in the Node-RED Library](https://flows.nodered.org/node/@tulip/node-red-tulip-api) 。*