道岔状态调整

This commit is contained in:
dong 2023-10-31 13:33:38 +08:00
parent 841b0ec641
commit 82a312bc35
3 changed files with 64 additions and 45 deletions

View File

@ -28,19 +28,12 @@
label="id"
hint=""
/>
<q-input
dense
outlined
readonly
v-model.number="turnoutState.code"
label="名称"
hint=""
/>
<q-input dense outlined readonly v-model="name" label="名称" hint="" />
<div>
<q-checkbox
v-model="turnoutState.normal"
outlined
label="定位"
label="定位(表示)"
:disable="true"
/>
</div>
@ -48,7 +41,23 @@
<q-checkbox
v-model="turnoutState.reverse"
outlined
label="反位"
label="反位(表示)"
:disable="true"
/>
</div>
<div>
<q-checkbox
v-model="turnoutState.dw"
outlined
label="定位(实际)"
:disable="true"
/>
</div>
<div>
<q-checkbox
v-model="turnoutState.fw"
outlined
label="反位(实际)"
:disable="true"
/>
</div>
@ -56,22 +65,19 @@
</q-card>
</template>
<script setup lang="ts">
import { Turnout } from 'src/graphics/turnout/Turnout';
import { ITurnoutState, Turnout } from 'src/graphics/turnout/Turnout';
import { useLineStore } from 'src/stores/line-store';
import { ref, watch, onMounted } from 'vue';
import { SetSwitchParams, setSwitchPosition } from 'src/api/Simulation';
import { useQuasar } from 'quasar';
import { ApiError } from 'src/boot/axios';
import { request } from 'src/protos/request';
import { TurnoutStates } from 'src/drawApp/graphics/TurnoutInteraction';
const $q = useQuasar();
const lineStore = useLineStore();
const turnoutState = ref({
id: '',
code: '',
normal: false,
reverse: false,
});
const turnoutState = ref<TurnoutStates>(new TurnoutStates());
const name = ref('');
watch(
() => lineStore.selectedGraphics,
@ -79,22 +85,14 @@ watch(
if (val?.length == 1 && val[0].type == Turnout.Type) {
setTurnoutState(val[0] as Turnout);
} else {
turnoutState.value = {
id: '',
code: '',
normal: false,
reverse: false,
};
turnoutState.value = new TurnoutStates();
name.value = '';
}
}
);
function setTurnoutState(turnout: Turnout) {
turnoutState.value = {
id: turnout.datas.id,
code: turnout.datas.code,
normal: turnout.states.normal || false,
reverse: turnout.states.reverse || false,
};
turnoutState.value = turnout.states.clone() as TurnoutStates;
name.value = turnout.datas.code;
}
onMounted(() => {
@ -112,6 +110,9 @@ const options = [
{ label: '取消失表故障', value: request.Turnout.Operation.CancelSB },
{ label: '设置挤岔故障', value: request.Turnout.Operation.SetJC },
{ label: '取消挤岔故障', value: request.Turnout.Operation.CancelJC },
{ label: '强制定位', value: request.Turnout.Operation.ForceDw },
{ label: '强制反位', value: request.Turnout.Operation.ForceFw },
{ label: '取消强制', value: request.Turnout.Operation.CancelForce },
];
function toDo(item: { label: string; value: number }) {
if (!lineStore.simulationId) return;
@ -121,11 +122,7 @@ function toDo(item: { label: string; value: number }) {
deviceId: turnoutState.value.id,
operation: item.value,
};
setSwitchPosition(obj)
.then(() => {
$q.notify({ type: 'positive', message: '修改道岔状态成功' });
})
.catch((err) => {
setSwitchPosition(obj).catch((err) => {
const error = err as ApiError;
$q.notify({
type: 'negative',
@ -133,4 +130,21 @@ function toDo(item: { label: string; value: number }) {
});
});
}
watch(
() => lineStore.socketStates,
(val) => {
if (val && turnoutState.value.id) {
const find = val.find((item) => {
return (
item.graphicType == Turnout.Type &&
(item as ITurnoutState).id == turnoutState.value.id
);
});
if (find) {
turnoutState.value = find.clone() as TurnoutStates;
}
}
}
);
</script>

View File

@ -196,11 +196,11 @@ export class Turnout extends JlGraphic {
doRepaint(): void {
// console.log(this.states);
const { pointB, pointC } = this.datas;
if (this.states.normal) {
if (this.states.dw) {
this.graphics.fork.paint(pointB[0]);
this.graphics.label.style.stroke = TurnoutConsts.normalLabelColor;
this.graphics.fork.visible = true;
} else if (this.states.reverse) {
} else if (this.states.fw) {
this.graphics.fork.paint(pointC[0]);
this.graphics.label.style.stroke = TurnoutConsts.reverseLabelColor;
this.graphics.fork.visible = true;

View File

@ -55,7 +55,10 @@ export namespace request {
SetSB = 5,
CancelSB = 6,
SetJC = 7,
CancelJC = 8
CancelJC = 8,
ForceDw = 9,
ForceFw = 10,
CancelForce = 11
}
}
export class TurnoutOperationReq extends pb_1.Message {
@ -293,9 +296,11 @@ export namespace request {
export namespace Section {
export enum AxleOperation {
Drst = 0,
Pdrst = 1,
TrainIn = 2,
TrainOut = 3
Pdrst = 1
}
export enum SectionOperation {
SetFaultOcc = 0,
CancelFaultOcc = 1
}
}
}