feat: 实现 PLC↔MES 对账功能(#8),包含终端触发与系统触发逻辑
新增功能: 1. 新增 PLC 客户端接口 QueryStationPallet,支持 mock 与真实 PLC 寄存器读取 2. 新增对账检测逻辑,覆盖 11 个工位(G1~G10 + C15) 3. 事件驱动触发:终端 T2/T3/T5 触发单工位检测,T4 报工命中则阻断;T6/T7 系统触发全量检测并落预警中心 4. 新增路由、handler、logic、测试用例及帮助文档,完成对账全链路实现
This commit is contained in:
@@ -13,10 +13,13 @@ type mockClient struct {
|
||||
mu sync.RWMutex
|
||||
// dockPallet 模拟接驳台是否有托盘:默认全部无托盘;联调时可用 SetDockPallet 置位
|
||||
dockPallet map[string]bool
|
||||
// stationPallet 模拟工位托盘位是否有件(PLC↔MES 对账用):key=工位号,默认全部无件;
|
||||
// 联调/自测时可用 SetStationPallet 置位,模拟“PLC 说有位、MES 说无工件”的 mismatch 场景。
|
||||
stationPallet map[int]bool
|
||||
}
|
||||
|
||||
func newMockClient() *mockClient {
|
||||
return &mockClient{dockPallet: map[string]bool{}}
|
||||
return &mockClient{dockPallet: map[string]bool{}, stationPallet: map[int]bool{}}
|
||||
}
|
||||
|
||||
// SetDockPallet 手动设置某接驳台是否有托盘(供联调/测试用)
|
||||
@@ -26,6 +29,13 @@ func (m *mockClient) SetDockPallet(dockCode string, has bool) {
|
||||
m.dockPallet[dockCode] = has
|
||||
}
|
||||
|
||||
// SetStationPallet 手动设置某工位托盘位是否有件(PLC↔MES 对账联调/自测用)
|
||||
func (m *mockClient) SetStationPallet(stationNo int, has bool) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.stationPallet[stationNo] = has
|
||||
}
|
||||
|
||||
func (m *mockClient) SendProcessCode(_ context.Context, combination string) ([]int, error) {
|
||||
codes := parseCombination(combination)
|
||||
m.sent = combination
|
||||
@@ -49,4 +59,11 @@ func (m *mockClient) QueryDockPallet(_ context.Context, dockCode string) (bool,
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
return m.dockPallet[dockCode], nil
|
||||
}
|
||||
|
||||
// QueryStationPallet 读工位托盘位(mock):返回置位值,默认无件。
|
||||
func (m *mockClient) QueryStationPallet(_ context.Context, stationNo int) (bool, error) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
return m.stationPallet[stationNo], nil
|
||||
}
|
||||
Reference in New Issue
Block a user