Przeglądaj źródła

fix 设备测试界面显示添加

zhanghaijun 2 lat temu
rodzic
commit
dd85fe33c2

+ 11 - 0
train-server/src/main/java/top/haijunit/train/controller/DeviceController.java

@@ -5,6 +5,10 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import top.haijunit.common.domain.ResultData;
+import top.haijunit.train.device.entity.DeviceEntity;
+import top.haijunit.train.device.service.DeviceService;
+
+import java.util.List;
 
 /**
  * @author zhang
@@ -16,6 +20,13 @@ import top.haijunit.common.domain.ResultData;
 @RequiredArgsConstructor
 public class DeviceController {
 
+    private final DeviceService deviceService;
+
+    @GetMapping("/all")
+    public ResultData<List<DeviceEntity>> device() {
+        return ResultData.success(deviceService.getAll());
+    }
+
     @GetMapping("/elevator")
     public ResultData<String> elevator() {
         return ResultData.success("");

+ 6 - 0
train-server/src/main/java/top/haijunit/train/device/service/DeviceService.java

@@ -32,6 +32,12 @@ public class DeviceService {
 
     private final DeviceRepository deviceRepository;
 
+
+    public List<DeviceEntity> getAll(){
+        return deviceRepository.findAll();
+    }
+
+
     public DeviceEntity updateDevice(String msgStr) {
         JSONObject message = JSONUtil.parseObj(msgStr);
         if (!message.containsKey("cmd")) {

+ 7 - 0
train-web/src/api/device.ts

@@ -0,0 +1,7 @@
+import request from "@/api/http";
+import { AxiosPromise } from 'axios';
+import { DeviceItem } from '@/types/device'
+
+export function deviceAll(): AxiosPromise<Array<DeviceItem>> {
+  return request({ url: '/api/device/all', method: 'get' })
+}

+ 39 - 0
train-web/src/pages/device/DeviceTest.vue

@@ -0,0 +1,39 @@
+<template>
+  <div class="box">
+    <el-tabs tab-position="left" style="height: 500px" class="demo-tabs">
+      <el-tab-pane v-for="(device, deviceIndex) in deviceList" :key="deviceIndex" :label="device.description">
+        {{ device.description }}
+        <el-table :data="getDevice(device)" stripe style="">
+          <el-table-column prop="code" label="设备名称" />
+          <el-table-column prop="status" label="设备状态" width="180" />
+          <el-table-column prop="" label="操作" width="260" />
+        </el-table>
+      </el-tab-pane>
+    </el-tabs>
+  </div>
+</template>
+<script setup lang="ts">
+import { DeviceType, DeviceItem, deviceTypeSocket as deviceList } from "@/types/device";
+import { deviceAll } from "@/api/device";
+
+const deviceItemAll = ref<DeviceItem[]>([]);
+onMounted(async () => {
+  const res = await deviceAll();
+  deviceItemAll.value = res.data as DeviceItem[];
+});
+function getDevice(deviceType: DeviceType): DeviceItem[] {
+  const list = deviceItemAll.value.filter((item: DeviceItem) => item.command === deviceType.command);
+  console.log(deviceItemAll.value, list, deviceType.description);
+  return list;
+}
+</script>
+<style scoped lang="scss">
+.box {
+  width: 1200px;
+  height: 650px;
+  border: 1px solid #A7C0DF;
+  overflow: hidden;
+  margin: auto;
+  overflow: auto;
+}
+</style>

+ 9 - 5
train-web/src/pages/device/index.vue

@@ -1,16 +1,19 @@
 <template>
   <el-tabs v-model="activeName" class="demo-tabs">
     <el-tab-pane label="AFC设备仿真" name="afcDevice">
-      <device-afc/>
+      <device-afc />
     </el-tab-pane>
     <el-tab-pane label="站台门设备仿真" name="stationDoor">
-      <device-door/>
+      <device-door />
     </el-tab-pane>
     <el-tab-pane label="给排水设备仿真" name="waterDevice">
-      <device-water/>
+      <device-water />
     </el-tab-pane>
     <el-tab-pane label="电扶梯设备仿真" name="elevator">
-      <device-elevator/>
+      <device-elevator />
+    </el-tab-pane>
+    <el-tab-pane label="测试设备" name="test">
+      <device-test></device-test>
     </el-tab-pane>
   </el-tabs>
 </template>
@@ -19,6 +22,7 @@ import DeviceAfc from "./DeviceAfc.vue";
 import DeviceWater from "./DeviceWater.vue";
 import DeviceDoor from "./DeviceDoor.vue";
 import DeviceElevator from "./DeviceElevator.vue";
+import DeviceTest from "./DeviceTest.vue"
 
-const activeName = ref('afcDevice')
+const activeName = ref('test')
 </script>

+ 0 - 4
train-web/src/pages/socket/index.vue

@@ -1,4 +0,0 @@
-<template>
-  <h1>socket test</h1>
-</template>
-<script setup lang="ts"></script>

+ 2 - 3
train-web/src/pages/train/controller/DrewTrain.ts

@@ -27,7 +27,6 @@ export class DrewTrain {
     if (currentItem.switch) {
       const switchList: SwitchItem[] = storeTrain.getSwitchList;
       // 运行在道岔上
-      console.log("运行在道岔上");
       const { x, y } = calculateComponents(train.offset);
       const switchItem: SwitchItem | undefined = switchList.find(item => item.sectionId == currentItem.id);
       switch (switchItem?.type) {
@@ -65,9 +64,9 @@ export class DrewTrain {
     this.canvas.restore();
     this.canvas.save();
     const titleArray: string[] = [];
-    titleArray.push("列车:" + train.trainNo + " " + train.direction);
+    titleArray.push("列车:" + train.trainNo);
     titleArray.push("速度:" + (Number(train.speed) * 3.6).toFixed(2));
-    titleArray.push("区段:" + train.blockNo + ",偏移量:" + train.offset);
+    // titleArray.push("区段:" + train.blockNo + ",偏移量:" + train.offset);
     this.drawTitle(train.direction, position - (trainWidth * 0.5), (position_y - 35), 80, 50, titleArray);
     this.canvas.save();
   }

+ 36 - 36
train-web/src/router/index.ts

@@ -1,50 +1,50 @@
-import {createRouter, createWebHashHistory} from "vue-router";
+import { createRouter, createWebHashHistory } from "vue-router";
 import NProgress from "nprogress";
 
 const routes = [
-    {
-        path: "/",
-        redirect: "/home",
-        component: () => import("@/layout/index.vue"),
-        children: [
-            {
-                path: "/home",
-                name: "首页",
-                component: () => import("@/pages/HomeIndex.vue"),
-            }, {
-                path: "/train",
-                name: "行车控制智能体仿真",
-                component: () => import("@/pages/train/index.vue")
-            }, {
-                path: "/device",
-                name: "综合监控智能体仿真",
-                component: () => import("@/pages/device/index.vue")
-            }, {
-                path: "/situation",
-                name: "场景态势智能体仿真",
-                component: () => import("@/pages/situation/index.vue")
-            }
-        ],
-    }, {
-        path: "/:pathMatch(.*)*",
-        component: () => import("@/pages/404.vue"),
-    },
+  {
+    path: "/",
+    redirect: "/home",
+    component: () => import("@/layout/index.vue"),
+    children: [
+      {
+        path: "/home",
+        name: "首页",
+        component: () => import("@/pages/HomeIndex.vue"),
+      }, {
+        path: "/train",
+        name: "行车控制智能体仿真",
+        component: () => import("@/pages/train/index.vue")
+      }, {
+        path: "/device",
+        name: "综合监控智能体仿真",
+        component: () => import("@/pages/device/index.vue")
+      }, {
+        path: "/situation",
+        name: "场景态势智能体仿真",
+        component: () => import("@/pages/situation/index.vue")
+      }
+    ],
+  }, {
+    path: "/:pathMatch(.*)*",
+    component: () => import("@/pages/404.vue"),
+  },
 ];
 
 const router = createRouter({
-    history: createWebHashHistory(),
-    routes,
+  history: createWebHashHistory(),
+  routes,
 });
 
 router.beforeEach((to, from) => {
-    console.log("beforeEach: to:", to.path, ", from:", from.path);
-    if (!NProgress.isStarted()) {
-        NProgress.start();
-    }
+  console.log("beforeEach: to:", to.path, ", from:", from.path);
+  if (!NProgress.isStarted()) {
+    NProgress.start();
+  }
 });
 router.afterEach((to, from) => {
-    console.log("afterEach: to:", to.path, ", from:", from.path);
-    NProgress.done();
+  console.log("afterEach: to:", to.path, ", from:", from.path);
+  NProgress.done();
 });
 
 export default router;

+ 2 - 0
train-web/src/types/components.d.ts

@@ -14,6 +14,8 @@ declare module 'vue' {
     ElMain: typeof import('element-plus/es')['ElMain']
     ElMenu: typeof import('element-plus/es')['ElMenu']
     ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
+    ElTable: typeof import('element-plus/es')['ElTable']
+    ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
     ElTabPane: typeof import('element-plus/es')['ElTabPane']
     ElTabs: typeof import('element-plus/es')['ElTabs']
     HelloWorld: typeof import('./../components/HelloWorld.vue')['default']

+ 68 - 24
train-web/src/pages/socket/socket.ts

@@ -1,4 +1,20 @@
-export interface deviceType {
+
+export interface DeviceItem {
+  // 唯一标识
+  id: string;
+  // 指令
+  command: number;
+  // 标识编码
+  code: number;
+  // 状态
+  status: number;
+  // 其他信息
+  jsonStr: string;
+  // 所属站台
+  stationId: number;
+}
+
+export interface DeviceType {
   name: string;
   description: string;
   command: number;
@@ -7,50 +23,78 @@ export interface deviceType {
 }
 
 // 列车车门控制 | 列车编号 | 车门状态 (0关 1开)
-export const TRAIN_OPEN_DOOR: deviceType = { command: 10105, name: "TRAIN_OPEN_DOOR", description: "列车车门控制", nameStr: "trainNo", statusStr: "state" };
+export const TRAIN_OPEN_DOOR: DeviceType = { command: 10105, name: "TRAIN_OPEN_DOOR", description: "列车车门控制", nameStr: "trainNo", statusStr: "state" };
 // 站台紧急停车操作指令 | 站台编号 | 运行方向 (1下行 2上行) 状态 (0弹起/复位 1按下)
-export const PLATFORM_PRESSING_STOP: deviceType = { command: 20104, name: "PLATFORM_PRESSING_STOP", description: "站台紧急停车操作指令", nameStr: "platformNo", statusStr: "isPressed" };
+export const PLATFORM_PRESSING_STOP: DeviceType = { command: 20104, name: "PLATFORM_PRESSING_STOP", description: "站台紧急停车操作指令", nameStr: "platformNo", statusStr: "isPressed" };
 // AFC闸机信息 | 闸机编号 | 闸机状态 (0关闭 1开启 2暂停服务 3故障) | 闸机方向状态 (0进站 1出站)
-export const AFC_GATE_MACHINE: deviceType = { command: 10201, name: "AFC_GATE_MACHINE", description: "AFC闸机信息", nameStr: "gateMachineNo", statusStr: "state" };
+export const AFC_GATE_MACHINE: DeviceType = { command: 10201, name: "AFC_GATE_MACHINE", description: "AFC闸机信息", nameStr: "gateMachineNo", statusStr: "state" };
 // AFC自动售票机信息 | 售票机编号 | 状态 (0正常服务 1暂停服务 2故障)
-export const AFC_TICKETING_AUTO: deviceType = { command: 10202, name: "AFC_TICKETING_AUTO", description: "AFC自动售票机信息", nameStr: "tvmNo", statusStr: "state" };
+export const AFC_TICKETING_AUTO: DeviceType = { command: 10202, name: "AFC_TICKETING_AUTO", description: "AFC自动售票机信息", nameStr: "tvmNo", statusStr: "state" };
 // AFC半自动售票机信息
-export const AFC_TICKETING_SEMI: deviceType = { command: 10203, name: "AFC_TICKETING_SEMI", description: "AFC半自动售票机信息", nameStr: "ticketNo", statusStr: "state" };
+export const AFC_TICKETING_SEMI: DeviceType = { command: 10203, name: "AFC_TICKETING_SEMI", description: "AFC半自动售票机信息", nameStr: "ticketNo", statusStr: "state" };
 // AFC闸机操作指令 | 闸机编号 | 闸机状态 (0关闭 1开启 2暂停服务 3故障)
-export const AFC_GATE_MACHINE_STATUS: deviceType = { command: 20201, name: "AFC_GATE_MACHINE_STATUS", description: "AFC闸机操作指令", nameStr: "gateMachineNo", statusStr: "state" };
+export const AFC_GATE_MACHINE_STATUS: DeviceType = { command: 20201, name: "AFC_GATE_MACHINE_STATUS", description: "AFC闸机操作指令", nameStr: "gateMachineNo", statusStr: "state" };
 // AFC自动售票机操作指令 | 售票机编号 | 状态 (0正常服务 1暂停服务 2故障)
-export const AFC_TICKETING_AUTO_STATUS: deviceType = { command: 20202, name: "AFC_TICKETING_AUTO_STATUS", description: "AFC自动售票机操作指令", nameStr: "tvmNo", statusStr: "state" };
+export const AFC_TICKETING_AUTO_STATUS: DeviceType = { command: 20202, name: "AFC_TICKETING_AUTO_STATUS", description: "AFC自动售票机操作指令", nameStr: "tvmNo", statusStr: "state" };
 // AFC半自动售票机操作指令
-export const AFC_TICKETING_SEMI_STATUS: deviceType = { command: 20203, name: "AFC_TICKETING_SEMI_STATUS", description: "AFC半自动售票机操作指令", nameStr: "ticketNo", statusStr: "state" };
+export const AFC_TICKETING_SEMI_STATUS: DeviceType = { command: 20203, name: "AFC_TICKETING_SEMI_STATUS", description: "AFC半自动售票机操作指令", nameStr: "ticketNo", statusStr: "state" };
 // AFC IBP盘操作指令 | 车站编号 | 紧急释放状态 (0释放 | 1按下)
-export const AFC_IBP: deviceType = { command: 20204, name: "AFC_IBP", description: "AFC IBP盘操作指令", nameStr: "stationNo", statusStr: "emergency_release" };
+export const AFC_IBP: DeviceType = { command: 20204, name: "AFC_IBP", description: "AFC IBP盘操作指令", nameStr: "stationNo", statusStr: "emergency_release" };
 
 // ------ 站台名设备
 // 单活动门锁闭状态状态 | 活动门编号 | 锁闭状态 (0关闭锁紧 | 1未关闭锁紧)
-export const PLATFORM_DOOR_LOCK: deviceType = { command: 10301, name: "PLATFORM_DOOR_LOCK", description: "单活动门锁闭状态", nameStr: "platformDoorNo", statusStr: "state" };
+export const PLATFORM_DOOR_LOCK: DeviceType = { command: 10301, name: "PLATFORM_DOOR_LOCK", description: "单活动门锁闭状态", nameStr: "platformDoorNo", statusStr: "state" };
 // 单活动门控制状态 | 活动门编号 | 控制状态 (0自动 1手动开 2手动关 3隔离)
-export const PLATFORM_DOOR_CONTROL: deviceType = { command: 10302, name: "PLATFORM_DOOR_CONTROL", description: "单活动门控制状态", nameStr: "platformDoorNo", statusStr: "state" };
+export const PLATFORM_DOOR_CONTROL: DeviceType = { command: 10302, name: "PLATFORM_DOOR_CONTROL", description: "单活动门控制状态", nameStr: "platformDoorNo", statusStr: "state" };
 // LCW操作指令 | 活动门编号 |  操作指令 (0自动 1手动开 2手动关 3隔离)
-export const PLATFORM_DOOR_LCW: deviceType = { command: 20301, name: "PLATFORM_DOOR_LCW", description: "LCW操作指令", nameStr: "platformDoorNo", statusStr: "optCmd" };
+export const PLATFORM_DOOR_LCW: DeviceType = { command: 20301, name: "PLATFORM_DOOR_LCW", description: "LCW操作指令", nameStr: "platformDoorNo", statusStr: "optCmd" };
 // PSL互锁解除操作指令 | PSL编号 | 操作指令 (0正常 | 1互锁解除)
-export const PSL_LOCK: deviceType = { command: 20302, name: "PSL_LOCK", description: "PSL互锁解除操作指令", nameStr: "pslNo", statusStr: "optCmd" };
+export const PSL_LOCK: DeviceType = { command: 20302, name: "PSL_LOCK", description: "PSL互锁解除操作指令", nameStr: "pslNo", statusStr: "optCmd" };
 // PSL允许操作指令 | PSL编号 | 操作指令 (0允许 | 1未允许)
-export const PSL_CONTROL: deviceType = { command: 20303, name: "PSL_CONTROL", description: "PSL允许操作指令", nameStr: "pslNo", statusStr: "optCmd" };
+export const PSL_CONTROL: DeviceType = { command: 20303, name: "PSL_CONTROL", description: "PSL允许操作指令", nameStr: "pslNo", statusStr: "optCmd" };
 // PSL开门操作指令 | PSL编号 | 操作指令 (0关门 | 1未关门)
-export const PSL_DOOR_OPEN: deviceType = { command: 20304, name: "PSL_DOOR_OPEN", description: "PSL开门操作指令", nameStr: "pslNo", statusStr: "optCmd" };
+export const PSL_DOOR_OPEN: DeviceType = { command: 20304, name: "PSL_DOOR_OPEN", description: "PSL开门操作指令", nameStr: "pslNo", statusStr: "optCmd" };
 // PSL关门操作指令 | PSL编号 | 操作指令	(0关门 | 1未关门)
-export const PSL_DOOR_CLOSE: deviceType = { command: 20305, name: "PSL_DOOR_CLOSE", description: "PSL关门操作指令", nameStr: "pslNo", statusStr: "optCmd" };
+export const PSL_DOOR_CLOSE: DeviceType = { command: 20305, name: "PSL_DOOR_CLOSE", description: "PSL关门操作指令", nameStr: "pslNo", statusStr: "optCmd" };
 // IBP允许操作指令 | 站台门编号 | 操作指令 (0允许 1未允许)
-export const IBP_CONTROL: deviceType = { command: 20306, name: "IBP_CONTROL", description: "IBP允许操作指令", nameStr: "platformDoorNo", statusStr: "optCmd" };
+export const IBP_CONTROL: DeviceType = { command: 20306, name: "IBP_CONTROL", description: "IBP允许操作指令", nameStr: "platformDoorNo", statusStr: "optCmd" };
 // IBP开门操作指令 | 站台门编号 | 操作指令 (0开门 1未开门)
-export const IBP_DOOR_OPEN: deviceType = { command: 20307, name: "IBP_DOOR_OPEN", description: "IBP开门操作指令", nameStr: "platformDoorNo", statusStr: "optCmd" };
+export const IBP_DOOR_OPEN: DeviceType = { command: 20307, name: "IBP_DOOR_OPEN", description: "IBP开门操作指令", nameStr: "platformDoorNo", statusStr: "optCmd" };
 // IBP关门操作指令 | 站台门编号 | 操作指令 (0关门 1未关门)
-export const IBP_DOOR_CLOSE: deviceType = { command: 20308, name: "IBP_DOOR_CLOSE", description: "IBP关门操作指令", nameStr: "platformDoorNo", statusStr: "optCmd" };
+export const IBP_DOOR_CLOSE: DeviceType = { command: 20308, name: "IBP_DOOR_CLOSE", description: "IBP关门操作指令", nameStr: "platformDoorNo", statusStr: "optCmd" };
 // 垂直电梯运行状态 | 垂直电梯编号 | 状态 (0运行 1停止 2禁用)
-export const ELEVATOR_VERTICAL: deviceType = { command: 10401, name: "ELEVATOR_VERTICAL", description: "垂直电梯运行状态", nameStr: "verticalElevatorNo", statusStr: "state" };
+export const ELEVATOR_VERTICAL: DeviceType = { command: 10401, name: "ELEVATOR_VERTICAL", description: "垂直电梯运行状态", nameStr: "verticalElevatorNo", statusStr: "state" };
 // 电扶梯运行状态 | 电扶梯编号 | state (0上行 1下行 2停止 3禁用)
-export const ELEVATOR_HAND: deviceType = { command: 10402, name: "ELEVATOR_HAND", description: "电扶梯运行状态", nameStr: "elevatorNo", statusStr: "state" };
+export const ELEVATOR_HAND: DeviceType = { command: 10402, name: "ELEVATOR_HAND", description: "电扶梯运行状态", nameStr: "elevatorNo", statusStr: "state" };
 // 垂直电梯操作指令 | 垂直电梯编号 | 状态 (0运行 1停止 2禁用)
-export const ELEVATOR_VERTICAL_COMMAND: deviceType = { command: 20401, name: "ELEVATOR_VERTICAL_COMMAND", description: "垂直电梯操作指令", nameStr: "verticalElevatorNo", statusStr: "state" };
+export const ELEVATOR_VERTICAL_COMMAND: DeviceType = { command: 20401, name: "ELEVATOR_VERTICAL_COMMAND", description: "垂直电梯操作指令", nameStr: "verticalElevatorNo", statusStr: "state" };
 // 电扶梯操作指令 | 电扶梯编号 | 状态 (0上行 1下行 2停止 3禁用)
-export const ELEVATOR_HAND_COMMAND: deviceType = { command: 20402, name: "ELEVATOR_HAND_COMMAND", description: "电扶梯操作指令", nameStr: "elevatorNo", statusStr: "state" };
+export const ELEVATOR_HAND_COMMAND: DeviceType = { command: 20402, name: "ELEVATOR_HAND_COMMAND", description: "电扶梯操作指令", nameStr: "elevatorNo", statusStr: "state" };
+
+const deviceTypeArray: DeviceType[] = [
+  TRAIN_OPEN_DOOR,
+  PLATFORM_PRESSING_STOP,
+  AFC_GATE_MACHINE,
+  AFC_TICKETING_AUTO,
+  AFC_TICKETING_SEMI,
+  AFC_GATE_MACHINE_STATUS,
+  AFC_TICKETING_AUTO_STATUS,
+  AFC_TICKETING_SEMI_STATUS,
+  AFC_IBP,
+  PLATFORM_DOOR_LOCK,
+  PLATFORM_DOOR_CONTROL,
+  PLATFORM_DOOR_LCW,
+  PSL_LOCK,
+  PSL_CONTROL,
+  PSL_DOOR_OPEN,
+  PSL_DOOR_CLOSE,
+  IBP_CONTROL,
+  IBP_DOOR_OPEN,
+  IBP_DOOR_CLOSE,
+  ELEVATOR_VERTICAL,
+  ELEVATOR_HAND,
+  ELEVATOR_VERTICAL_COMMAND,
+  ELEVATOR_HAND_COMMAND
+]
+
+export const deviceTypeSocket = deviceTypeArray.filter(item => item.command.toString().startsWith("2"));