diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainHmiDisplay.java b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainHmiDisplay.java index 4cfcb2742..ecf76a436 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainHmiDisplay.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainHmiDisplay.java @@ -160,6 +160,9 @@ public class TrainHmiDisplay { */ private int tow; + /** 牵引、制动力百分比 */ + private int forcePercent; + public TrainHmiDisplay(VirtualRealityTrain train) { this.code = train.getCode(); this.groupNumber = train.getGroupNumber(); @@ -213,6 +216,17 @@ public class TrainHmiDisplay { this.parking = train.isParkingAt(); this.inTheStandArea = train.isInTheStandArea(); this.tow = getTow(train); + this.forcePercent = getForcePercent(train); + } + + private int getForcePercent(VirtualRealityTrain train) { + if (train.getFk() > 0) { + return (int) (train.getFk() / train.getCurrentFkMax() * 100); + } else if (train.getFb() > 0) { + return (int) (train.getFb() / train.getCurrentFbMax() * 100); + } else { + return 0; + } } private int getTow(VirtualRealityTrain train) { @@ -373,6 +387,11 @@ public class TrainHmiDisplay { this.tow = tow; map.put("tow", tow); } + int forcePercent = getForcePercent(train); + if (!Objects.equals(this.forcePercent, forcePercent)) { + this.forcePercent = forcePercent; + map.put("forcePercent", forcePercent); + } if (map.size() > 0) { map.put("code", this.code); return map; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index 685e365ad..cad647e60 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -681,8 +681,8 @@ public class VirtualRealityTrain extends VirtualRealityDevice { if (linkTrain != null && linkTrain.isEB()) { return; } - this.fk = fk; - this.fb = fb; + this.fk = Math.min(fk, getCurrentFkMax()); + this.fb = Math.min(fb, getCurrentFbMax()); if (fk > 0) { this.tbControl = TrainTBControl.TRACTION; } else if (fb > 0) {