【继电器操作返回处理结果信息】
This commit is contained in:
parent
dfe96a977c
commit
32a8921f9b
16
fi/relay.go
16
fi/relay.go
@ -30,8 +30,8 @@ func driveWjRelay(w ecs.World, entry *ecs.Entry, td bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 驱动继电器到吸起位置
|
// 驱动继电器到吸起位置
|
||||||
func DriveRelayUp(w ecs.World, id string) {
|
func DriveRelayUp(w ecs.World, id string) error {
|
||||||
w.Execute(func() {
|
result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||||
wd := entity.GetWorldData(w)
|
wd := entity.GetWorldData(w)
|
||||||
entry, ok := wd.EntityMap[id]
|
entry, ok := wd.EntityMap[id]
|
||||||
if ok {
|
if ok {
|
||||||
@ -41,14 +41,16 @@ func DriveRelayUp(w ecs.World, id string) {
|
|||||||
driveWjRelay(w, entry, true)
|
driveWjRelay(w, entry, true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("未找到id=%s的继电器\n", id)
|
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的继电器", id))
|
||||||
}
|
}
|
||||||
|
return ecs.NewOkEmptyResult()
|
||||||
})
|
})
|
||||||
|
return result.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 驱动继电器到落下位置
|
// 驱动继电器到落下位置
|
||||||
func DriveRelayDown(w ecs.World, id string) {
|
func DriveRelayDown(w ecs.World, id string) error {
|
||||||
w.Execute(func() {
|
result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||||
wd := entity.GetWorldData(w)
|
wd := entity.GetWorldData(w)
|
||||||
entry, ok := wd.EntityMap[id]
|
entry, ok := wd.EntityMap[id]
|
||||||
if ok {
|
if ok {
|
||||||
@ -58,7 +60,9 @@ func DriveRelayDown(w ecs.World, id string) {
|
|||||||
driveWjRelay(w, entry, false)
|
driveWjRelay(w, entry, false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("未找到id=%s的继电器\n", id)
|
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的继电器", id))
|
||||||
}
|
}
|
||||||
|
return ecs.NewOkEmptyResult()
|
||||||
})
|
})
|
||||||
|
return result.Err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user