HL.MCP.Service.PickTag 2.0.9
HL.MCP.Service.PickTag
MCP 框架的电子标签(拣货系统/播种墙)服务实现,支持多种主流电子标签系统。
功能特性
- 🏷️ 多品牌电子标签系统支持
- 💡 标签灯光控制(点亮/熄灭)
- 🔢 数字和字符显示
- ⌨️ 按键事件处理
- 🌈 多彩屏支持(ARIS)
- 🔄 网关/总线管理
- 📡 MCP 服务框架集成
- 🎯 状态分发机制
支持的电子标签系统
1. AIOI(爱欧)电子标签
- PickTagAIOIService - 升级控制版
- PickTagAPIService - API 版本
- 应用场景:播种墙、拣货系统
- 支持数字和字符显示
2. ARIS(国产)电子标签
- PickTagARISService - PTL900U 彩屏版
- 支持彩色液晶显示屏
- 支持产品名称、数量、描述多行显示
- 可配置按钮颜色和背景
- 支持切换按钮控制
3. ATOP(上尚)电子标签
- PickTagATOPService
- ⚠️ 注意:仅支持 32 位编译
- 自动生成 IPINDEX 配置文件
安装
dotnet add package HL.MCP.Service.PickTag
使用方法
AIOI 电子标签(升级控制版)
using HL.MCP.Service.PickTag;
// 初始化服务
var pickTagService = new PickTagAIOIService();
pickTagService.Initialize("picktag-config.xml");
pickTagService.Start();
// 点亮标签
pickTagService.LightOn(addr: 1, gateway: 0);
// 显示数字
pickTagService.DisplayNum(addr: 1, num: 99, dotPosition: 0, gateway: 0);
// 显示字符
pickTagService.DisplayStr(addr: 1, msg: "A01", dotPosition: 0, gateway: 0);
// 熄灭标签
pickTagService.LightOff(addr: 1, gateway: 0);
ARIS 彩屏电子标签
using HL.MCP.Service.PickTag;
using Ptl.Device.Communication.Command;
// 初始化服务
var arisService = new PickTagARISService();
arisService.Initialize("aris-config.xml");
arisService.Start();
// 点亮标签
arisService.LightOn(addr: 1, gateway: 0);
// 彩屏显示(支持多行信息)
arisService.DisplayNum(
tagAddress: 1,
productName: "阿莫西林胶囊",
quantity: 10,
description: "规格:0.5g*24粒\n批号:20231201\n效期:2025-12",
lightColor: LightColor.Green,
background: SurfaceBackground.White,
mustCollect: true,
enableF1OkColorAfterPress: false
);
// 熄灭标签
arisService.LightOff(addr: 1, gateway: 0);
// 熄灭所有标签
arisService.LightOffAll();
// 控制切换按钮
arisService.ShiftTagControl(light: true);
ATOP 电子标签
using HL.MCP.Service.PickTag;
// 初始化服务(会自动生成 IPINDEX 文件)
var atopService = new PickTagATOPService();
atopService.Initialize("atop-config.xml");
atopService.Start();
// 点亮标签
atopService.LightOn(addr: 1, gateway: 0);
// 显示数字
atopService.DisplayNum(addr: 1, num: 25, dotPosition: 0, gateway: 0);
// 显示字符
atopService.DisplayStr(addr: 1, msg: "OK", dotPosition: 0, gateway: 0);
// 熄灭标签
atopService.LightOff(addr: 1, gateway: 0);
配置文件
基本配置(AIOI/ATOP)
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<IP>192.168.1.100</IP>
<Port>4660</Port>
</Configuration>
ARIS 配置
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<IP>192.168.1.100</IP>
<Port>8899</Port>
<BusCount>4</BusCount>
<TagItems>
<TagItem TagAddress="1" ShiftTag="false" />
<TagItem TagAddress="2" ShiftTag="false" />
<TagItem TagAddress="3" ShiftTag="true" />
<!-- 更多标签配置 -->
</TagItems>
</Configuration>
按键事件处理
所有服务都支持按键事件,通过 MCP 状态分发机制传递:
// 按键事件会自动触发
// 事件参数结构:
public class KeyPressArgs
{
public int addr { get; set; } // 标签地址
public bool isok { get; set; } // 是否确认按键
public int gateway { get; set; } // 网关编号
public int cmdType { get; set; } // 命令类型
}
// 通过 MCP 框架接收按键事件
// DispatchState("KeyPress", args);
应用场景
1. 药品播种墙系统
public class PharmacySeedingWall
{
private PickTagARISService pickTagService;
public void Initialize()
{
pickTagService = new PickTagARISService();
pickTagService.Initialize("pharmacy-config.xml");
pickTagService.Start();
}
public void StartSeeding(int position, string drugName, int quantity, string specs)
{
// 显示药品信息和数量
pickTagService.DisplayNum(
tagAddress: (byte)position,
productName: drugName,
quantity: (ushort)quantity,
description: specs,
lightColor: LightColor.Red,
background: SurfaceBackground.White
);
}
public void ConfirmPicked(int position)
{
// 熄灭已完成的标签
pickTagService.LightOff(position);
}
}
2. 电商拣货系统
public class EcommercePickingSystem
{
private PickTagAIOIService pickTagService;
public void Initialize()
{
pickTagService = new PickTagAIOIService();
pickTagService.Initialize("ecommerce-config.xml");
pickTagService.Start();
}
public void DisplayPickTask(int location, int quantity)
{
// 点亮拣货位
pickTagService.LightOn(location);
// 显示拣货数量
pickTagService.DisplayNum(location, quantity);
}
public void ClearLocation(int location)
{
pickTagService.LightOff(location);
}
}
3. 生产线配料系统
public class ProductionMaterialSystem
{
private PickTagATOPService pickTagService;
public void Initialize()
{
pickTagService = new PickTagATOPService();
pickTagService.Initialize("production-config.xml");
pickTagService.Start();
}
public void DisplayMaterialRequest(int binLocation, string materialCode, int quantity)
{
// 点亮料箱位置
pickTagService.LightOn(binLocation);
// 显示物料代码
pickTagService.DisplayStr(binLocation, materialCode);
// 在另一显示区域显示数量
// pickTagService.DisplayNum(binLocation + 100, quantity);
}
}
API 参考
共通方法
所有服务类都实现以下方法:
LightOn
点亮标签灯光
void LightOn(int addr, int gateway = 0)
LightOff
熄灭标签灯光
void LightOff(int addr, int gateway = 0)
DisplayNum
显示数字
void DisplayNum(int addr, int num, int dotPosition = 0, int gateway = 0)
AIOI/ATOP 特有方法
DisplayStr
显示字符串
void DisplayStr(int addr, string msg, int dotPosition = 0, int gateway = 0)
ARIS 特有方法
DisplayNum (彩屏版本)
彩屏多行显示
void DisplayNum(
byte tagAddress,
string productName,
ushort quantity,
string description = null,
LightColor lightColor = LightColor.Red,
SurfaceBackground background = default,
bool mustCollect = true,
bool enableF1OkColorAfterPress = false
)
LightOffAll
熄灭所有标签
void LightOffAll()
ShiftTagControl
控制切换按钮
void ShiftTagControl(bool light)
参数说明
通用参数
- addr / tagAddress: 标签地址(1-255)
- gateway: 网关编号(0-N)
- num / quantity: 显示的数字
- msg / productName: 显示的文本
- dotPosition: 小数点位置(0=无小数点)
ARIS 特有参数
- description: 描述信息(支持多行,使用
\n换行) - lightColor: 按钮灯光颜色
LightColor.Red- 红色LightColor.Green- 绿色LightColor.Yellow- 黄色LightColor.Blue- 蓝色
- background: 彩屏背景色
SurfaceBackground.White- 白色SurfaceBackground.Black- 黑色- 其他预定义颜色
- mustCollect: 是否必须采集确认
- enableF1OkColorAfterPress: 按键后是否启用 F1 功能
注意事项
ATOP 系统
- ⚠️ 仅支持 32 位编译,需要配置项目为 x86 平台
- 自动生成
IPINDEX配置文件到应用程序目录 - IPINDEX 格式:
网关编号 端口 IP地址
网络配置
- 确保标签控制器与服务器在同一网络
- 检查防火墙设置,允许对应端口通信
- 建议使用独立网段避免干扰
性能优化
- 批量操作时考虑增加延迟避免指令堆积
- 合理规划网关和总线分配
- 避免频繁点亮/熄灭同一标签
错误处理
- Read/Write 方法未实现,不要直接调用
- 使用专用的 LightOn/LightOff/Display 方法
- 监控按键事件通过 MCP 状态分发
故障排查
标签无响应
问题: 标签不亮或显示不更新
解决方案:
- 检查网络连接和 IP 配置
- 验证标签地址是否正确
- 确认控制器电源正常
- 检查网关编号配置
- 查看日志错误信息
ATOP 系统启动失败
问题: ATOP 服务无法初始化
解决方案:
- 确认编译为 x86(32 位)
- 检查 IPINDEX 文件是否生成
- 验证本机 DLL 依赖项
- 确认控制器固件版本
按键事件不触发
问题: 按下标签按钮没有反应
解决方案:
- 检查事件订阅是否正确
- 验证 MCP 状态分发配置
- 确认标签地址匹配
- 查看控制器通信日志
技术规格
支持的网关数量
- AIOI: 可配置(默认 1)
- ARIS: 通过 BusCount 配置
- ATOP: 默认 1
标签地址范围
- 通常: 1-255
- 具体范围参考各品牌控制器手册
通信协议
- TCP/IP 网络通信
- 各品牌私有协议
- 由 HL.PickTag 库封装实现
依赖项
- HL.MCP - MCP 框架核心
- HL.PickTag - 电子标签通信库
- Newtonsoft.Json - JSON 序列化(PickTagAPIService)
- .NET Framework 4.6.1 或更高版本
相关产品
- 播种墙系统: 医药、电商订单分拣
- 拣货系统: 仓储、物流拣货
- 生产配料: 制造业物料配送
- 库存管理: 货位可视化管理
许可证
MIT License
技术支持
如需更多技术支持或定制开发,请联系:
- 贵州慧联科技有限公司
- 项目仓库:https://git.csmhxx.com/hl/framework/hl.framework
更新日志
v2.0.1
- 支持 AIOI、ARIS、ATOP 多品牌电子标签
- ARIS 彩屏支持
- 优化按键事件处理
- 完善配置文件格式
No packages depend on HL.MCP.Service.PickTag.
.NET Framework 4.6.2
- HL.PickTag (>= 2.0.9)
| Version | Downloads | Last updated |
|---|---|---|
| 2.0.9 | 0 | 08/19/2026 |