98 lines
3.1 KiB
Go
98 lines
3.1 KiB
Go
package station
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"errors"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Station 封装设备特定的机器人取放操作。
|
||
|
|
// RobotWorker 委托给 Station 而非 switch machineID。
|
||
|
|
type Station interface {
|
||
|
|
// Load 将工件放入该工站设备。
|
||
|
|
Load(ctx context.Context, wt int, machineSlot int) error
|
||
|
|
|
||
|
|
// Unload 从该工站设备取出工件。返回调整后的暂存台目标槽位号。
|
||
|
|
Unload(ctx context.Context, wt int, machineSlot int, dstTempSlot int) (adjustedTempSlot int, err error)
|
||
|
|
|
||
|
|
// Exchange 换料:取出卸料工件同时放入上料工件。
|
||
|
|
Exchange(ctx context.Context, wt int, machineSlot int) error
|
||
|
|
}
|
||
|
|
|
||
|
|
// PreLoadStation 需要上料前 PLC 握手的工站(清洗线)。
|
||
|
|
type PreLoadStation interface {
|
||
|
|
Station
|
||
|
|
PreLoad(ctx context.Context) error // Load 前调用(请求料盘→等待就绪→检查Done)
|
||
|
|
PostLoad(ctx context.Context) error // Load 后 defer 调用(关闭请求信号)
|
||
|
|
}
|
||
|
|
|
||
|
|
// StartupStation 需要启动命令的工站(高压清洗机)。
|
||
|
|
type StartupStation interface {
|
||
|
|
Station
|
||
|
|
Startup(ctx context.Context) error
|
||
|
|
}
|
||
|
|
|
||
|
|
// BatchUnloadStation 支持批量卸料的工站(高压清洗机多槽位同时 Done)。
|
||
|
|
type BatchUnloadStation interface {
|
||
|
|
Station
|
||
|
|
BatchUnload(ctx context.Context, wt int, slots []BatchSlot, releaser SlotReleaser) error
|
||
|
|
}
|
||
|
|
|
||
|
|
// SlotReleaser 槽位释放窄接口(由 actor.MachineActor 满足)。
|
||
|
|
type SlotReleaser interface {
|
||
|
|
ReleaseSlot(slotNo int)
|
||
|
|
}
|
||
|
|
|
||
|
|
// BatchSlot 批量卸料的单个槽位参数。
|
||
|
|
type BatchSlot struct {
|
||
|
|
JobID int
|
||
|
|
SlotNo int
|
||
|
|
TempSlot int
|
||
|
|
}
|
||
|
|
|
||
|
|
// ErrActionCancelled 清洗线检测到 Done 工件,需重新调度为 Exchange。
|
||
|
|
var ErrActionCancelled = errors.New("action cancelled: re-schedule")
|
||
|
|
|
||
|
|
// --- robotController 窄接口子集 ---
|
||
|
|
|
||
|
|
// RobotPlacer 机器人放料操作。
|
||
|
|
type RobotPlacer interface {
|
||
|
|
PlaceWorkpieceToMachine(ctx context.Context, wt int, machineID int, slot ...int) error
|
||
|
|
PlaceWorkpieceToRollingLine(ctx context.Context, wt int) error
|
||
|
|
PlaceWorkpieceToSamplingStation(ctx context.Context, wt int) error
|
||
|
|
PlaceWorkpieceToTempStation(ctx context.Context, wt int, slot int) error
|
||
|
|
}
|
||
|
|
|
||
|
|
// RobotFetcher 机器人取料操作。
|
||
|
|
type RobotFetcher interface {
|
||
|
|
FetchWorkpieceFromMachine(ctx context.Context, wt int, machineID int, slot ...int) error
|
||
|
|
FetchWorkpieceFromRollingLine(ctx context.Context, wt int) error
|
||
|
|
FetchWorkpieceFromSamplingStation(ctx context.Context, wt int) error
|
||
|
|
}
|
||
|
|
|
||
|
|
// RobotExchanger 机器人换料操作。
|
||
|
|
type RobotExchanger interface {
|
||
|
|
ExchangeWorkpieceToMachine(ctx context.Context, wt int, machineID int, slot ...int) error
|
||
|
|
}
|
||
|
|
|
||
|
|
// RobotPlacerFetcher 组合接口。
|
||
|
|
type RobotPlacerFetcher interface {
|
||
|
|
RobotPlacer
|
||
|
|
RobotFetcher
|
||
|
|
RobotExchanger
|
||
|
|
}
|
||
|
|
|
||
|
|
// RobotCleanLineController 清洗线 PLC 操作。
|
||
|
|
type RobotCleanLineController interface {
|
||
|
|
RobotPlacerFetcher
|
||
|
|
RequestCleaningLoading(ctx context.Context) error
|
||
|
|
WaitCleaningReady(ctx context.Context) error
|
||
|
|
IsCleanLineDone(ctx context.Context) (bool, error)
|
||
|
|
CloseRequestCleaningLoading(ctx context.Context) error
|
||
|
|
}
|
||
|
|
|
||
|
|
// RobotWasherController 清洗机 PLC 操作。
|
||
|
|
type RobotWasherController interface {
|
||
|
|
RobotPlacerFetcher
|
||
|
|
StartupWasher(ctx context.Context) error
|
||
|
|
}
|