90 lines
2.2 KiB
Go
90 lines
2.2 KiB
Go
package device_sys
|
|
|
|
import (
|
|
"joylink.club/ecs"
|
|
"joylink.club/ecs/filter"
|
|
"joylink.club/rtsssimulation/component"
|
|
)
|
|
|
|
type PsdMotorSys struct {
|
|
query *ecs.Query
|
|
}
|
|
|
|
func NewPsdMotorSys() *PsdMotorSys {
|
|
return &PsdMotorSys{
|
|
query: ecs.NewQuery(filter.Contains(component.AsdMotorStateType)),
|
|
}
|
|
}
|
|
|
|
func (s *PsdMotorSys) Update(world ecs.World) {
|
|
//var rate int32 = 10000 / 4
|
|
//s.query.Each(world, func(entry *ecs.Entry) {
|
|
// psdMotorState := component.AsdMotorStateType.Get(entry)
|
|
// if psdMotorState.Gm_Td {
|
|
// gm(psdMotorState, rate)
|
|
// } else if psdMotorState.Km4_Td {
|
|
// km4(psdMotorState, rate)
|
|
// } else if psdMotorState.Km8_Td {
|
|
// km8(psdMotorState, rate)
|
|
// }
|
|
//})
|
|
}
|
|
|
|
func gm(psdMotorState *component.AsdMotorState, rate int32) {
|
|
//if psdMotorState.Km4 != consts.TwoPosMin {
|
|
// newRate := psdMotorState.Km4 - rate
|
|
// if newRate < consts.TwoPosMin {
|
|
// psdMotorState.Km4 = consts.TwoPosMin
|
|
// } else {
|
|
// psdMotorState.Km4 = newRate
|
|
// }
|
|
//}
|
|
//if psdMotorState.Km8_4 != consts.TwoPosMin {
|
|
// newRate := psdMotorState.Km8_4 - rate
|
|
// if newRate < consts.TwoPosMin {
|
|
// psdMotorState.Km8_4 = consts.TwoPosMin
|
|
// } else {
|
|
// psdMotorState.Km8_4 = newRate
|
|
// }
|
|
//}
|
|
//if !psdMotorState.Is8Km() && !psdMotorState.Is4Km() {
|
|
// psdMotorState.Gm_Td = false
|
|
//}
|
|
}
|
|
|
|
func km4(psdMotorState *component.AsdMotorState, rate int32) {
|
|
//if psdMotorState.Km4 != consts.TwoPosMax {
|
|
// newRate := psdMotorState.Km4 + rate
|
|
// if newRate > consts.TwoPosMax {
|
|
// psdMotorState.Km4 = consts.TwoPosMax
|
|
// } else {
|
|
// psdMotorState.Km4 = newRate
|
|
// }
|
|
//}
|
|
//if psdMotorState.Is4Km() || psdMotorState.Is8Km() {
|
|
// psdMotorState.Km4_Td = false
|
|
//}
|
|
}
|
|
|
|
func km8(psdMotorState *component.AsdMotorState, rate int32) {
|
|
//if psdMotorState.Km4 != consts.TwoPosMax {
|
|
// newRate := psdMotorState.Km4 + rate
|
|
// if newRate > consts.TwoPosMax {
|
|
// psdMotorState.Km4 = consts.TwoPosMax
|
|
// } else {
|
|
// psdMotorState.Km4 = newRate
|
|
// }
|
|
//}
|
|
//if psdMotorState.Km8_4 != consts.TwoPosMax {
|
|
// newRate := psdMotorState.Km8_4 + rate
|
|
// if newRate > consts.TwoPosMax {
|
|
// psdMotorState.Km8_4 = consts.TwoPosMax
|
|
// } else {
|
|
// psdMotorState.Km8_4 = newRate
|
|
// }
|
|
//}
|
|
//if psdMotorState.Is8Km() {
|
|
// psdMotorState.Km8_Td = false
|
|
//}
|
|
}
|