Files
bj_power/bj_power_mes/internal/plc/tcp.go
T
SunYF 8e6048c64b feat: 实现 PLC↔MES 对账功能(#8),包含终端触发与系统触发逻辑
新增功能:
1. 新增 PLC 客户端接口 QueryStationPallet,支持 mock 与真实 PLC 寄存器读取
2. 新增对账检测逻辑,覆盖 11 个工位(G1~G10 + C15)
3. 事件驱动触发:终端 T2/T3/T5 触发单工位检测,T4 报工命中则阻断;T6/T7 系统触发全量检测并落预警中心
4. 新增路由、handler、logic、测试用例及帮助文档,完成对账全链路实现
2026-10-13 15:51:45 +08:00

42 lines
1.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package plc
import (
"context"
"bj_power_mes/internal/config"
)
// tcpClient 占位:对接西门子 S7 的实现签名。
// 本项目以 mock 为主,真实 S7 对接预留(寄存器写工序码、读完成信号位)。
type tcpClient struct {
c config.PlcConf
}
func newTcpClient(c config.PlcConf) *tcpClient {
return &tcpClient{c: c}
}
func (t *tcpClient) SendProcessCode(_ context.Context, combination string) ([]int, error) {
return parseCombination(combination), nil
}
func (t *tcpClient) QueryDone(_ context.Context) (bool, error) {
return true, nil
}
func (t *tcpClient) AckDone(_ context.Context, ok bool) {
_ = ok
}
// QueryDockPallet 读接驳台托盘传感器。真实对接:按 DOCK 编码映射 PLC 寄存器(如 DB101.DBX0.0=DOCK01 托盘到位)。
// 信号定义未确认前返回 false(默认无托盘),待现场 PLC 点位表给到后在此处补读寄存器逻辑。
func (t *tcpClient) QueryDockPallet(_ context.Context, _ string) (bool, error) {
return false, nil
}
// QueryStationPallet 读工位托盘位(PLC↔MES 对账)。真实对接:按工位号映射 PLC 寄存器
// (G1~G10→M895.0~M896.1、C15→M898.0)。信号定义未确认前返回 false(默认无件),
// 待现场 PLC 点位表给到后在此处补读寄存器逻辑(与 QueryDockPallet 同为占位实现)。
func (t *tcpClient) QueryStationPallet(_ context.Context, _ int) (bool, error) {
return false, nil
}