列车信息调整

This commit is contained in:
dong 2023-09-05 15:24:34 +08:00
parent 88230487d5
commit 6103863d70
3 changed files with 110 additions and 23 deletions

View File

@ -29,6 +29,19 @@
}}</q-item-label> }}</q-item-label>
</q-item-section> </q-item-section>
</q-item> </q-item>
<q-separator inset />
<q-item v-for="(item, index) in list3" :key="index">
<q-item-section>
<q-item-label>{{ item.label }}</q-item-label>
</q-item-section>
<q-item-section side>
<q-item-label caption>{{
item.formatFn
? item.formatFn(trainInfo.vobcState[item.key])
: trainInfo.vobcState[item.key]
}}</q-item-label>
</q-item-section>
</q-item>
</q-list> </q-list>
</q-card> </q-card>
</template> </template>
@ -47,6 +60,11 @@ interface DynamicKeyType {
key: keyof state.TrainDynamicState; key: keyof state.TrainDynamicState;
formatFn?(v: state.TrainDynamicState[keyof state.TrainDynamicState]): string; formatFn?(v: state.TrainDynamicState[keyof state.TrainDynamicState]): string;
} }
interface VobcStateType {
label: string;
key: keyof state.TrainVobcState;
formatFn?(v: state.TrainVobcState[keyof state.TrainVobcState]): string;
}
const lineStore = useLineStore(); const lineStore = useLineStore();
const trainInfo = ref<ITrainState | null>(); const trainInfo = ref<ITrainState | null>();
const dynamicInfo = ref<state.TrainDynamicState | null>(); const dynamicInfo = ref<state.TrainDynamicState | null>();
@ -92,6 +110,61 @@ const list2: DynamicKeyType[] = [
{ label: '头车雷达速度值', key: 'headRadarSpeed', formatFn: speedFormat }, { label: '头车雷达速度值', key: 'headRadarSpeed', formatFn: speedFormat },
{ label: '尾车雷达速度值', key: 'tailRadarSpeed', formatFn: speedFormat }, { label: '尾车雷达速度值', key: 'tailRadarSpeed', formatFn: speedFormat },
]; ];
const list3: VobcStateType[] = [
//
{ label: '生命信号', key: 'lifeSignal' },
{ label: 'TC1激活状态', key: 'tc1Active', formatFn: upFormat },
{ label: 'TC2激活状态', key: 'tc2Active', formatFn: upFormat },
{
label: '列车方向向前',
key: 'directionForward',
formatFn: upFormat,
},
{
label: '列车方向向后',
key: 'directionBackward',
formatFn: upFormat,
},
{
label: '列车牵引状态',
key: 'tractionStatus',
formatFn: upFormat,
},
{
label: '列车制动状态',
key: 'brakingStatus',
formatFn: upFormat,
},
{
label: '列车紧急制动状态',
key: 'emergencyBrakingStatus',
formatFn: upFormat,
},
{
label: '列车折返状态AR',
key: 'turnbackStatus',
formatFn: upFormat,
},
{ label: '跳跃状态', key: 'jumpStatus', formatFn: upFormat },
{
label: 'ATO模式',
key: 'ato',
formatFn: upFormat,
},
{ label: 'FAM模式', key: 'fam', formatFn: upFormat },
{ label: 'CAM模式', key: 'cam', formatFn: upFormat },
{ label: '牵引安全回路', key: 'tractionSafetyCircuit', formatFn: upFormat },
{ label: '停放制动状态', key: 'parkingBrakeStatus', formatFn: upFormat },
{ label: '保持制动状态', key: 'maintainBrakeStatus', formatFn: upFormat },
{ label: '列车牵引力', key: 'tractionForce', formatFn: tractionForceFormat },
{ label: '列车制动力', key: 'brakeForce', formatFn: tractionForceFormat },
{ label: '列车载荷', key: 'trainLoad', formatFn: trainLoadFormat },
{ label: '列车开左门指令', key: 'leftDoorOpenCommand', formatFn: upFormat },
{ label: '列车开右门指令', key: 'rightDoorOpenCommand', formatFn: upFormat },
{ label: '列车关左门指令', key: 'leftDoorCloseCommand', formatFn: upFormat },
{ label: '列车关右门指令', key: 'rightDoorCloseCommand', formatFn: upFormat },
{ label: '整列车门关好', key: 'allDoorClose', formatFn: upFormat },
];
function upFormat(v: boolean) { function upFormat(v: boolean) {
return v ? '是' : '否'; return v ? '是' : '否';
} }
@ -113,10 +186,10 @@ function resistanceFormat(v: number) {
} }
function speedFormat(v: number) { function speedFormat(v: number) {
let n: string | number = ''; let n: string | number = '';
if (v >= 0 && v < 500) { // if (v >= 0 && v < 500) {
// 500 // 500
n = floatDecimal(v); n = floatDecimal(v / 100);
} // }
return `${n} km/h`; return `${n} km/h`;
} }
function trainLengthFormat(v: number) { function trainLengthFormat(v: number) {
@ -129,6 +202,15 @@ function floatDecimal(v: number, x = 2) {
return n; return n;
} }
function tractionForceFormat(v: number) {
const n = floatDecimal(v / 100);
return `${n} KN`;
}
function trainLoadFormat(v: number) {
const n = floatDecimal(v / 100);
return `${n} ton`;
}
watch( watch(
() => lineStore.selectedGraphics, () => lineStore.selectedGraphics,
(val) => { (val) => {

View File

@ -173,11 +173,16 @@ export class TrainHead extends Container {
arrow.beginFill(aColor, 1); arrow.beginFill(aColor, 1);
arrow.drawPolygon(arrowPoint); arrow.drawPolygon(arrowPoint);
arrow.endFill(); arrow.endFill();
// if (states.mode?.ipModeTrainStoped) { if (states.dynamicState.speed > 0) {
// this.arrow.visible = false; this.arrow.visible = true;
// } else { } else {
// this.arrow.visible = true; this.arrow.visible = false;
// } }
if (states.vobcState.tc1Active || states.vobcState.tc2Active) {
this.pause.visible = true;
} else {
this.pause.visible = false;
}
} }
} }

View File

@ -1287,19 +1287,19 @@ export namespace state {
if (this.curveResistance != 0) if (this.curveResistance != 0)
writer.writeFloat(13, this.curveResistance); writer.writeFloat(13, this.curveResistance);
if (this.speed != 0) if (this.speed != 0)
writer.writeFloat(14, this.speed); writer.writeInt32(14, this.speed);
if (this.headSensorSpeed1 != 0) if (this.headSensorSpeed1 != 0)
writer.writeFloat(15, this.headSensorSpeed1); writer.writeInt32(15, this.headSensorSpeed1);
if (this.headSensorSpeed2 != 0) if (this.headSensorSpeed2 != 0)
writer.writeFloat(16, this.headSensorSpeed2); writer.writeInt32(16, this.headSensorSpeed2);
if (this.tailSensorSpeed1 != 0) if (this.tailSensorSpeed1 != 0)
writer.writeFloat(17, this.tailSensorSpeed1); writer.writeInt32(17, this.tailSensorSpeed1);
if (this.tailSensorSpeed2 != 0) if (this.tailSensorSpeed2 != 0)
writer.writeFloat(18, this.tailSensorSpeed2); writer.writeInt32(18, this.tailSensorSpeed2);
if (this.headRadarSpeed != 0) if (this.headRadarSpeed != 0)
writer.writeFloat(19, this.headRadarSpeed); writer.writeInt32(19, this.headRadarSpeed);
if (this.tailRadarSpeed != 0) if (this.tailRadarSpeed != 0)
writer.writeFloat(20, this.tailRadarSpeed); writer.writeInt32(20, this.tailRadarSpeed);
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -1349,25 +1349,25 @@ export namespace state {
message.curveResistance = reader.readFloat(); message.curveResistance = reader.readFloat();
break; break;
case 14: case 14:
message.speed = reader.readFloat(); message.speed = reader.readInt32();
break; break;
case 15: case 15:
message.headSensorSpeed1 = reader.readFloat(); message.headSensorSpeed1 = reader.readInt32();
break; break;
case 16: case 16:
message.headSensorSpeed2 = reader.readFloat(); message.headSensorSpeed2 = reader.readInt32();
break; break;
case 17: case 17:
message.tailSensorSpeed1 = reader.readFloat(); message.tailSensorSpeed1 = reader.readInt32();
break; break;
case 18: case 18:
message.tailSensorSpeed2 = reader.readFloat(); message.tailSensorSpeed2 = reader.readInt32();
break; break;
case 19: case 19:
message.headRadarSpeed = reader.readFloat(); message.headRadarSpeed = reader.readInt32();
break; break;
case 20: case 20:
message.tailRadarSpeed = reader.readFloat(); message.tailRadarSpeed = reader.readInt32();
break; break;
default: reader.skipField(); default: reader.skipField();
} }