iscs bas 大系统-阀门
This commit is contained in:
parent
ead7947345
commit
a922cf8133
@ -21,14 +21,19 @@ func main() {
|
|||||||
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan3", FanType: proto.Fan_SoftStartFan})
|
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan3", FanType: proto.Fan_SoftStartFan})
|
||||||
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan4", FanType: proto.Fan_HighLowSpeedFan})
|
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan4", FanType: proto.Fan_HighLowSpeedFan})
|
||||||
//
|
//
|
||||||
|
protoRepo.Valves = append(protoRepo.Valves, &proto.Valve{Id: "valve1", ValveType: proto.Valve_ElectricControlValve})
|
||||||
|
protoRepo.Valves = append(protoRepo.Valves, &proto.Valve{Id: "valve2", ValveType: proto.Valve_ElectricAirValve})
|
||||||
|
protoRepo.Valves = append(protoRepo.Valves, &proto.Valve{Id: "valve3", ValveType: proto.Valve_CombinationAirValve})
|
||||||
|
protoRepo.Valves = append(protoRepo.Valves, &proto.Valve{Id: "valve4", ValveType: proto.Valve_ElectricButterflyValve})
|
||||||
|
//
|
||||||
repo, _ := repository.BuildRepository(protoRepo)
|
repo, _ := repository.BuildRepository(protoRepo)
|
||||||
sim, _ := newIscsSimulation(repo)
|
sim, _ := newIscsSimulation(repo)
|
||||||
sim.StartUp()
|
sim.StartUp()
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
fi.MotorOperate(sim, "fan2", fi.FiMsOnForward, 60)
|
fi.ValveOperate(sim, "valve1", 100)
|
||||||
time.Sleep(8 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
fi.MotorOperate(sim, "fan2", fi.FiMsOnReverse, 60)
|
fi.ValveOperate(sim, "valve1", 1)
|
||||||
time.Sleep(8 * time.Second)
|
time.Sleep(4 * time.Second)
|
||||||
sim.Close()
|
sim.Close()
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package iscs_sys
|
package iscs_sys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/ecs/filter"
|
"joylink.club/ecs/filter"
|
||||||
"joylink.club/rtsssimulation/component"
|
"joylink.club/rtsssimulation/component"
|
||||||
"joylink.club/rtsssimulation/consts"
|
"joylink.club/rtsssimulation/consts"
|
||||||
"joylink.club/rtsssimulation/entity"
|
"joylink.club/rtsssimulation/entity"
|
||||||
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ValveSystem 阀门
|
// ValveSystem 阀门
|
||||||
@ -31,18 +31,26 @@ func (s *ValveSystem) Update(w ecs.World) {
|
|||||||
valve.Closed = valve.OpenRate <= 0
|
valve.Closed = valve.OpenRate <= 0
|
||||||
valve.Opened = valve.OpenRate >= 100
|
valve.Opened = valve.OpenRate >= 100
|
||||||
valve.Moving = valve.OpenRate != valveController.TargetOpenRate
|
valve.Moving = valve.OpenRate != valveController.TargetOpenRate
|
||||||
fmt.Printf("==>>阀门[%s],OpenRate = %d%% , 全开 = %t , 全关 = %t", valveId, valve.OpenRate, valve.Opened, valve.Closed)
|
//fmt.Printf("==>>阀门[%s],OpenRate = %d%% , 全开 = %t , 全关 = %t , Moving = %t ,Pos = %d\n", valveId, valve.OpenRate, valve.Opened, valve.Closed, valve.Moving, position.Pos)
|
||||||
//
|
//
|
||||||
valveModel, ok := wd.Repo.FindById(valveId).(valveModeler)
|
valveModel, ok := wd.Repo.FindById(valveId).(valveModeler)
|
||||||
if !ok {
|
if !ok {
|
||||||
valveModel = vm
|
valveModel = vm
|
||||||
}
|
}
|
||||||
|
//计算速度
|
||||||
speed := int32((float64(consts.TwoPosMax-consts.TwoPosMin) / float64(valveModel.MaxMoveTime())) * float64(w.Tick()))
|
speed := int32((float64(consts.TwoPosMax-consts.TwoPosMin) / float64(valveModel.MaxMoveTime())) * float64(w.Tick()))
|
||||||
|
targetPos := int32((float64(valveController.TargetOpenRate) / float64(100)) * float64(consts.TwoPosMax-consts.TwoPosMin))
|
||||||
|
targetLen := int32(math.Abs(float64(targetPos - position.Pos)))
|
||||||
|
//修正尾速
|
||||||
|
if speed > targetLen {
|
||||||
|
speed = targetLen
|
||||||
|
}
|
||||||
if valveController.TargetOpenRate < valve.OpenRate {
|
if valveController.TargetOpenRate < valve.OpenRate {
|
||||||
speed = -speed
|
speed = -speed
|
||||||
} else if valveController.TargetOpenRate == valve.OpenRate {
|
} else if valveController.TargetOpenRate == valve.OpenRate {
|
||||||
speed = 0
|
speed = 0
|
||||||
}
|
}
|
||||||
|
position.Speed = speed
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user