hmi消息增加牵引/制动力比例

This commit is contained in:
joylink_zhangsai 2021-08-06 16:32:33 +08:00
parent 6dee8dfa31
commit 6cadfcf607
2 changed files with 21 additions and 2 deletions

View File

@ -160,6 +160,9 @@ public class TrainHmiDisplay {
*/ */
private int tow; private int tow;
/** 牵引、制动力百分比 */
private int forcePercent;
public TrainHmiDisplay(VirtualRealityTrain train) { public TrainHmiDisplay(VirtualRealityTrain train) {
this.code = train.getCode(); this.code = train.getCode();
this.groupNumber = train.getGroupNumber(); this.groupNumber = train.getGroupNumber();
@ -213,6 +216,17 @@ public class TrainHmiDisplay {
this.parking = train.isParkingAt(); this.parking = train.isParkingAt();
this.inTheStandArea = train.isInTheStandArea(); this.inTheStandArea = train.isInTheStandArea();
this.tow = getTow(train); 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) { private int getTow(VirtualRealityTrain train) {
@ -373,6 +387,11 @@ public class TrainHmiDisplay {
this.tow = tow; this.tow = tow;
map.put("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) { if (map.size() > 0) {
map.put("code", this.code); map.put("code", this.code);
return map; return map;

View File

@ -681,8 +681,8 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
if (linkTrain != null && linkTrain.isEB()) { if (linkTrain != null && linkTrain.isEB()) {
return; return;
} }
this.fk = fk; this.fk = Math.min(fk, getCurrentFkMax());
this.fb = fb; this.fb = Math.min(fb, getCurrentFbMax());
if (fk > 0) { if (fk > 0) {
this.tbControl = TrainTBControl.TRACTION; this.tbControl = TrainTBControl.TRACTION;
} else if (fb > 0) { } else if (fb > 0) {