This commit is contained in:
xzb 2023-10-23 17:40:13 +08:00
commit f5e9aeecc8
11 changed files with 277 additions and 276 deletions

View File

@ -13,25 +13,22 @@ type MkxInfo struct {
var MkxCircuitType = ecs.NewComponentType[MkxCircuit]()
type MkxCircuit struct {
PcbList []*ecs.Entry
Pcbj *ecs.Entry
PobList []*ecs.Entry
Pobj *ecs.Entry
PabList []*ecs.Entry
Pabj *ecs.Entry
}
var MkxBoxType = ecs.NewComponentType[MkxBox]()
type MkxBox struct {
Btn *ecs.Entry
MkxplBtn *ecs.Entry
MkxplBtn *ecs.Entry //门控箱旁路按钮
PcbList []*ecs.Entry
Pcbj *ecs.Entry
PobList []*ecs.Entry
Pobj *ecs.Entry
PabList []*ecs.Entry
Pabj *ecs.Entry
}
var MkxCollectionCircuitType = ecs.NewComponentType[MkxCollectionCircuit]()
type MkxCollectionCircuit struct {
Pcb bool
Pob bool
Pab bool
PcbXh bool
PobXh bool
PabXh bool
PcbLx bool
PobLx bool
PabLx bool
}

11
component/psc.go Normal file
View File

@ -0,0 +1,11 @@
package component
import "joylink.club/ecs"
// PscType 中央控制盘
var PscType = ecs.NewComponentType[Psc]()
type Psc struct {
Mkx *ecs.Entry
Psd *ecs.Entry
}

View File

@ -3,18 +3,11 @@ package component
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component/component_proto"
"joylink.club/rtsssimulation/consts"
)
var PsdTag = ecs.NewTag()
var PsdStateType = ecs.NewComponentType[component_proto.PsdState]()
var PsdInfoType = ecs.NewComponentType[PsdInfo]()
type PsdInfo struct {
PlatformId string
}
var PsdCircuitType = ecs.NewComponentType[PsdCircuit]()
type PsdCircuit struct {
@ -27,35 +20,6 @@ type PsdCircuit struct {
MPLJ *ecs.Entry
}
var PsdMotorType = ecs.NewComponentType[ecs.Entry]()
var PsdMotorStateType = ecs.NewComponentType[PsdMotorState]()
// PsdMotorState 屏蔽门电机状态
type PsdMotorState struct {
//4编组开门通电
Km4_Td bool
//8编组开门通电
Km8_Td bool
//关门通电
Gm_Td bool
//4编组开门进度
Km4 int32
//8编组与4编组差集的门的开门进度
Km8_4 int32
//开关门速度
Speed int32
}
// Is4Km 是否4编组开门不用开到位
func (p *PsdMotorState) Is4Km() bool {
return p.Km4 != consts.TwoPosMin && p.Km8_4 == consts.TwoPosMin
}
// Is4Km 是否4编组开门不用开到位
func (p *PsdMotorState) Is8Km() bool {
return p.Km4 != consts.TwoPosMin && p.Km8_4 != consts.TwoPosMin
}
var PsdDriveCircuitType = ecs.NewComponentType[PsdDriveCircuit]()
// PsdDriveCircuit 屏蔽门驱动电路
@ -79,3 +43,20 @@ type PsdCollectionCircuit struct {
MPLJ_X bool
MPLJ_L bool
}
var AsdListType = ecs.NewComponentType[AsdList]()
// AsdList 滑动门列表
type AsdList struct {
List []*ecs.Entry
}
var AsdMotorStateType = ecs.NewComponentType[AsdMotorState]()
// AsdMotorState 滑动门电机状态
type AsdMotorState struct {
GM bool //向关门方向转动
KM bool //向开门方向转动
MG bool //门关闭状态
MK bool //门开启状态
}

View File

@ -44,12 +44,9 @@ func loadPsdCircuit(world ecs.World, entry *ecs.Entry, psd *repository.Psd, entr
func NewPsdEntry(world ecs.World, psd *repository.Psd, worldData *component.WorldData) *ecs.Entry {
entry, ok := worldData.EntityMap[psd.Id()]
if !ok {
entry = world.Entry(world.Create(component.PsdTag, component.UidType, component.PsdInfoType, component.PsdStateType,
component.PsdDriveCircuitType, component.PsdCollectionCircuitType, component.PsdMotorType))
entry = world.Entry(world.Create(component.PsdTag, component.UidType, component.PsdStateType,
component.PsdDriveCircuitType, component.PsdCollectionCircuitType, component.AsdListType))
component.UidType.SetValue(entry, component.Uid{Id: psd.Id()})
component.PsdInfoType.SetValue(entry, component.PsdInfo{PlatformId: psd.PlatformId()})
psdMotor := world.Entry(world.Create(component.PsdMotorStateType))
component.PsdMotorType.Set(entry, psdMotor)
worldData.EntityMap[psd.Id()] = entry
}
return entry

View File

@ -5,6 +5,7 @@ import "joylink.club/rtsssimulation/repository/model/proto"
type Psd struct {
Identity
platformId string
asdGroups []*AsdGroup
componentGroups []*ElectronicComponentGroup
}
@ -18,6 +19,29 @@ func (p *Psd) PlatformId() string {
return p.platformId
}
func (p *Psd) AsdGroups() []*AsdGroup {
return p.asdGroups
}
func (p *Psd) ComponentGroups() []*ElectronicComponentGroup {
return p.componentGroups
}
// AsdGroup 滑动门编组
type AsdGroup struct {
group int //编组4/8编组
start int //编组起始的滑动门编号
end int //编组结束的滑动门编号
}
func (a *AsdGroup) Group() int {
return a.group
}
func (a *AsdGroup) Start() int {
return a.start
}
func (a *AsdGroup) End() int {
return a.end
}

View File

@ -33,7 +33,7 @@ func BindSystem(w ecs.World) {
//门控箱
circuit_sys.NewMkxSys(),
//联锁机
device_sys.NewInterlockSys(),
device_sys.NewPscSys(),
// IBP
circuit_sys.NewIBPSys(),
device_sys.NewAlarmSys(),

View File

@ -19,40 +19,39 @@ func NewMkxSys() *MkxSys {
func (p *MkxSys) Update(world ecs.World) {
p.query.Each(world, func(entry *ecs.Entry) {
circuit := component.MkxCircuitType.Get(entry)
p.exciteRelay(circuit.PcbList, circuit.Pcbj)
p.exciteRelay(circuit.PobList, circuit.Pobj)
if circuit.Pabj != nil { //北岗子没有PABJ而是PDBJ,原因未知
p.exciteRelay(circuit.PabList, circuit.Pabj)
p.exciteRelay(circuit.MkxplBtn, circuit.PcbList, circuit.Pcbj)
p.exciteRelay(circuit.MkxplBtn, circuit.PobList, circuit.Pobj)
if circuit.Pabj != nil { //北岗子没有PABJ而是PDBJ
p.exciteRelay(circuit.MkxplBtn, circuit.PabList, circuit.Pabj)
}
//联锁采集
collectionCircuit := component.MkxCollectionCircuitType.Get(entry)
pcb := component.BitStateType.Get(circuit.Pcbj).Val
collectionCircuit.Pcb = pcb
collectionCircuit.PcbXh = pcb
pob := component.BitStateType.Get(circuit.Pobj).Val
collectionCircuit.Pob = pob
collectionCircuit.PobXh = pob
if circuit.Pabj != nil { //北岗子没有PABJ而是PDBJ原因未知
pab := component.BitStateType.Get(circuit.Pabj).Val
collectionCircuit.Pab = pab
collectionCircuit.PabXh = pab
}
})
}
func (p *MkxSys) exciteRelay(entries []*ecs.Entry, relay *ecs.Entry) {
func (p *MkxSys) exciteRelay(mkxplBtn *ecs.Entry, entries []*ecs.Entry, relay *ecs.Entry) {
if !component.BitStateType.Get(mkxplBtn).Val {
return
}
on := false
for _, entry := range entries {
box := component.MkxBoxType.Get(entry)
btn := component.BitStateType.Get(box.Btn)
mkxplBtn := component.BitStateType.Get(box.MkxplBtn)
if btn.Val && mkxplBtn.Val {
btn := component.BitStateType.Get(entry)
if btn.Val {
on = true
break
}
}
if on {
component.RelayDriveType.Get(relay).Td = true
//component.BitStateType.Get(relay).Val = true
} else {
component.RelayDriveType.Get(relay).Td = false
//component.BitStateType.Get(relay).Val = false
}
}

View File

@ -12,26 +12,24 @@ type PsdSys struct {
func NewPsdSys() *PsdSys {
return &PsdSys{
query: ecs.NewQuery(filter.Contains(component.PsdDriveCircuitType, component.PsdMotorType)),
query: ecs.NewQuery(filter.Contains(component.PsdDriveCircuitType)),
}
}
func (p *PsdSys) Update(world ecs.World) {
p.query.Each(world, func(entry *ecs.Entry) {
psdMotor := component.PsdMotorType.Get(entry)
psdMotorState := component.PsdMotorStateType.Get(psdMotor)
psdDrive := component.PsdDriveCircuitType.Get(entry)
if entry.HasComponent(component.PsdCircuitType) { //有屏蔽门电路
psdCircuit := component.PsdCircuitType.Get(entry)
p.exciteByDrive(psdCircuit, psdDrive)
p.exciteGMJ(psdMotorState, psdCircuit, psdDrive)
p.exciteKMJ4(psdMotorState, psdCircuit, psdDrive)
p.exciteKMJ8(psdMotorState, psdCircuit, psdDrive)
p.exciteMGJ(psdCircuit, psdMotorState)
p.exciteGMJ(nil, psdCircuit, psdDrive)
p.exciteKMJ4(nil, psdCircuit, psdDrive)
p.exciteKMJ8(nil, psdCircuit, psdDrive)
p.exciteMGJ(psdCircuit, nil)
} else { //无屏蔽门电路,直接驱动电机
p.driveMotor(psdMotorState, psdDrive.GMJ, psdDrive.KMJ4, psdDrive.KMJ8)
p.driveMotor(nil, psdDrive.GMJ, psdDrive.KMJ4, psdDrive.KMJ8)
}
p.updatePsdState(entry, psdMotorState)
p.updatePsdState(entry, nil)
})
}
@ -51,102 +49,102 @@ func (p *PsdSys) exciteByDrive(psd *component.PsdCircuit, drive *component.PsdDr
}
// 驱动电机
func (p *PsdSys) driveMotor(psdMotorState *component.PsdMotorState, gm, km4, km8 bool) {
if gm {
psdMotorState.Gm_Td = true
psdMotorState.Km4_Td = false
psdMotorState.Km8_Td = false
} else if km4 {
psdMotorState.Gm_Td = false
psdMotorState.Km4_Td = true
psdMotorState.Km8_Td = false
} else if km8 {
psdMotorState.Gm_Td = false
psdMotorState.Km4_Td = false
psdMotorState.Km8_Td = true
}
func (p *PsdSys) driveMotor(psdMotorState *component.AsdMotorState, gm, km4, km8 bool) {
//if gm {
// psdMotorState.Gm_Td = true
// psdMotorState.Km4_Td = false
// psdMotorState.Km8_Td = false
//} else if km4 {
// psdMotorState.Gm_Td = false
// psdMotorState.Km4_Td = true
// psdMotorState.Km8_Td = false
//} else if km8 {
// psdMotorState.Gm_Td = false
// psdMotorState.Km4_Td = false
// psdMotorState.Km8_Td = true
//}
}
func (p *PsdSys) exciteGMJ(state *component.PsdMotorState, psd *component.PsdCircuit, psdDrive *component.PsdDriveCircuit) {
gmj := component.BitStateType.Get(psd.GMJ)
kmj4 := component.BitStateType.Get(psd.KMJ4)
kmj8 := component.BitStateType.Get(psd.KMJ8)
if psdDrive.GMJ { //驱动电路接通
component.RelayDriveType.Get(psd.GMJ).Td = true
gmj.Val = true
} else if gmj.Val {
if !kmj4.Val && !kmj8.Val {
component.RelayDriveType.Get(psd.GMJ).Td = true
} else {
component.RelayDriveType.Get(psd.GMJ).Td = false
gmj.Val = false
}
}
if gmj.Val && !kmj4.Val && !kmj8.Val {
state.Gm_Td = true
}
func (p *PsdSys) exciteGMJ(state *component.AsdMotorState, psd *component.PsdCircuit, psdDrive *component.PsdDriveCircuit) {
//gmj := component.BitStateType.Get(psd.GMJ)
//kmj4 := component.BitStateType.Get(psd.KMJ4)
//kmj8 := component.BitStateType.Get(psd.KMJ8)
//if psdDrive.GMJ { //驱动电路接通
// component.RelayDriveType.Get(psd.GMJ).Td = true
// gmj.Val = true
//} else if gmj.Val {
// if !kmj4.Val && !kmj8.Val {
// component.RelayDriveType.Get(psd.GMJ).Td = true
// } else {
// component.RelayDriveType.Get(psd.GMJ).Td = false
// gmj.Val = false
// }
//}
//if gmj.Val && !kmj4.Val && !kmj8.Val {
// state.Gm_Td = true
//}
}
func (p *PsdSys) exciteKMJ4(state *component.PsdMotorState, psd *component.PsdCircuit, psdDrive *component.PsdDriveCircuit) {
kmj4 := component.BitStateType.Get(psd.KMJ4)
gmj := component.BitStateType.Get(psd.GMJ)
kmj8 := component.BitStateType.Get(psd.KMJ8)
if psdDrive.KMJ4 {
component.RelayDriveType.Get(psd.KMJ4).Td = true
kmj4.Val = true
} else if kmj4.Val {
if !gmj.Val && !kmj8.Val {
component.RelayDriveType.Get(psd.KMJ4).Td = true
} else {
component.RelayDriveType.Get(psd.KMJ4).Td = false
kmj4.Val = false
}
}
if kmj4.Val && !gmj.Val && !kmj8.Val {
state.Km4_Td = true
}
func (p *PsdSys) exciteKMJ4(state *component.AsdMotorState, psd *component.PsdCircuit, psdDrive *component.PsdDriveCircuit) {
//kmj4 := component.BitStateType.Get(psd.KMJ4)
//gmj := component.BitStateType.Get(psd.GMJ)
//kmj8 := component.BitStateType.Get(psd.KMJ8)
//if psdDrive.KMJ4 {
// component.RelayDriveType.Get(psd.KMJ4).Td = true
// kmj4.Val = true
//} else if kmj4.Val {
// if !gmj.Val && !kmj8.Val {
// component.RelayDriveType.Get(psd.KMJ4).Td = true
// } else {
// component.RelayDriveType.Get(psd.KMJ4).Td = false
// kmj4.Val = false
// }
//}
//if kmj4.Val && !gmj.Val && !kmj8.Val {
// state.Km4_Td = true
//}
}
func (p *PsdSys) exciteKMJ8(state *component.PsdMotorState, psd *component.PsdCircuit, psdDrive *component.PsdDriveCircuit) {
kmj8 := component.BitStateType.Get(psd.KMJ8)
gmj := component.BitStateType.Get(psd.GMJ)
kmj4 := component.BitStateType.Get(psd.KMJ4)
if psdDrive.KMJ4 {
component.RelayDriveType.Get(psd.KMJ8).Td = true
kmj8.Val = true
} else if kmj8.Val {
if !gmj.Val && !kmj4.Val {
component.RelayDriveType.Get(psd.KMJ8).Td = true
} else {
component.RelayDriveType.Get(psd.KMJ8).Td = false
kmj8.Val = false
}
}
if kmj8.Val && !gmj.Val && !kmj4.Val {
state.Km8_Td = true
}
func (p *PsdSys) exciteKMJ8(state *component.AsdMotorState, psd *component.PsdCircuit, psdDrive *component.PsdDriveCircuit) {
//kmj8 := component.BitStateType.Get(psd.KMJ8)
//gmj := component.BitStateType.Get(psd.GMJ)
//kmj4 := component.BitStateType.Get(psd.KMJ4)
//if psdDrive.KMJ4 {
// component.RelayDriveType.Get(psd.KMJ8).Td = true
// kmj8.Val = true
//} else if kmj8.Val {
// if !gmj.Val && !kmj4.Val {
// component.RelayDriveType.Get(psd.KMJ8).Td = true
// } else {
// component.RelayDriveType.Get(psd.KMJ8).Td = false
// kmj8.Val = false
// }
//}
//if kmj8.Val && !gmj.Val && !kmj4.Val {
// state.Km8_Td = true
//}
}
func (p *PsdSys) exciteMGJ(psdCircuit *component.PsdCircuit, state *component.PsdMotorState) {
if state.Is4Km() || state.Is8Km() {
component.RelayDriveType.Get(psdCircuit.MGJ).Td = false
component.BitStateType.Get(psdCircuit.MGJ).Val = false
} else {
component.RelayDriveType.Get(psdCircuit.MGJ).Td = true
component.BitStateType.Get(psdCircuit.MGJ).Val = true
}
func (p *PsdSys) exciteMGJ(psdCircuit *component.PsdCircuit, state *component.AsdMotorState) {
//if state.Is4Km() || state.Is8Km() {
// component.RelayDriveType.Get(psdCircuit.MGJ).Td = false
// component.BitStateType.Get(psdCircuit.MGJ).Val = false
//} else {
// component.RelayDriveType.Get(psdCircuit.MGJ).Td = true
// component.BitStateType.Get(psdCircuit.MGJ).Val = true
//}
}
func (p *PsdSys) updatePsdState(entry *ecs.Entry, psdMotorState *component.PsdMotorState) {
psdState := component.PsdStateType.Get(entry)
if psdMotorState.Is8Km() {
psdState.Km8 = true
psdState.Km4 = false
} else if psdMotorState.Is4Km() {
psdState.Km4 = true
psdState.Km8 = false
} else {
psdState.Km4 = false
psdState.Km8 = false
}
func (p *PsdSys) updatePsdState(entry *ecs.Entry, psdMotorState *component.AsdMotorState) {
//psdState := component.PsdStateType.Get(entry)
//if psdMotorState.Is8Km() {
// psdState.Km8 = true
// psdState.Km4 = false
//} else if psdMotorState.Is4Km() {
// psdState.Km4 = true
// psdState.Km8 = false
//} else {
// psdState.Km4 = false
// psdState.Km8 = false
//}
}

View File

@ -1,42 +0,0 @@
package device_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
type InterlockSys struct {
psdQuery *ecs.Query
mkxQuery *ecs.Query
}
func NewInterlockSys() *InterlockSys {
return &InterlockSys{
psdQuery: ecs.NewQuery(filter.Contains(component.PsdTag, component.UidType, component.PsdDriveCircuitType)),
mkxQuery: ecs.NewQuery(filter.Contains(component.MkxInfoType, component.MkxCollectionCircuitType)),
}
}
func (s *InterlockSys) Update(world ecs.World) {
psdEntryMap := make(map[string]*ecs.Entry)
s.psdQuery.Each(world, func(entry *ecs.Entry) {
psdEntryMap[component.UidType.Get(entry).Id] = entry
})
s.mkxQuery.Each(world, func(entry *ecs.Entry) {
mkxState := component.MkxCollectionCircuitType.Get(entry)
if mkxState.Pcb {
psdEntry := psdEntryMap[component.MkxInfoType.Get(entry).PsdId]
psdDriveCircuit := component.PsdDriveCircuitType.Get(psdEntry)
psdDriveCircuit.GMJ = true
psdDriveCircuit.KMJ4 = false
psdDriveCircuit.KMJ8 = false
} else if mkxState.Pob {
psdEntry := psdEntryMap[component.MkxInfoType.Get(entry).PsdId]
psdDriveCircuit := component.PsdDriveCircuitType.Get(psdEntry)
psdDriveCircuit.GMJ = false
psdDriveCircuit.KMJ4 = false
psdDriveCircuit.KMJ8 = true
}
})
}

37
sys/device_sys/psc.go Normal file
View File

@ -0,0 +1,37 @@
package device_sys
import (
"github.com/yohamta/donburi"
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
// PscSys 中央控制盘系统
type PscSys struct {
query *ecs.Query
}
func NewPscSys() *PscSys {
return &PscSys{
query: ecs.NewQuery(filter.Contains(component.PscType)),
}
}
func (s *PscSys) Update(world ecs.World) {
s.query.Each(world, func(entry *donburi.Entry) {
psc := component.PscType.Get(entry)
mkxState := component.MkxCollectionCircuitType.Get(psc.Mkx)
if mkxState.PcbXh {
psdDriveCircuit := component.PsdDriveCircuitType.Get(psc.Psd)
psdDriveCircuit.GMJ = true
psdDriveCircuit.KMJ4 = false
psdDriveCircuit.KMJ8 = false
} else if mkxState.PobXh {
psdDriveCircuit := component.PsdDriveCircuitType.Get(psc.Psd)
psdDriveCircuit.GMJ = false
psdDriveCircuit.KMJ4 = false
psdDriveCircuit.KMJ8 = true
}
})
}

View File

@ -4,7 +4,6 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/consts"
)
type PsdMotorSys struct {
@ -13,78 +12,78 @@ type PsdMotorSys struct {
func NewPsdMotorSys() *PsdMotorSys {
return &PsdMotorSys{
query: ecs.NewQuery(filter.Contains(component.PsdMotorStateType)),
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.PsdMotorStateType.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)
}
})
//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.PsdMotorState, 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 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.PsdMotorState, 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 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.PsdMotorState, 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
}
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
//}
}