4 changed files with 175 additions and 3 deletions
@ -0,0 +1,87 @@ |
|||
import express from "express"; |
|||
import { delay } from "../utils/helper"; |
|||
import { wsSend } from "../utils/wss"; |
|||
const router = express.Router(); |
|||
|
|||
import points from "../utils/measure.json"; |
|||
let ptIndex = 0; |
|||
let intervalId: ReturnType<typeof setInterval>; |
|||
|
|||
router.post("/cache-measurement", async (req, res) => { |
|||
await delay(100); |
|||
// setTimeout(() => {
|
|||
// wsSend(req.app.locals["wss"], {
|
|||
// type: "cmd",
|
|||
// data: {
|
|||
// commandId: req.body.commandId,
|
|||
// status: "D0000",
|
|||
// },
|
|||
// });
|
|||
// }, 2000);
|
|||
res.json({ status: 0 }); |
|||
}); |
|||
|
|||
router.post("/start-measurement", (req, res) => { |
|||
setTimeout(() => { |
|||
ptIndex = 0; |
|||
wsSend(req.app.locals["wss"], { |
|||
messageType: "EVENT", |
|||
data: { |
|||
event: "START_RECORD_SIG", |
|||
}, |
|||
path: "/measurement-task/get-task-state", |
|||
}); |
|||
}); |
|||
intervalId = setInterval(() => { |
|||
if (ptIndex >= points.length) { |
|||
clearInterval(intervalId); |
|||
// ptIndex = 0;
|
|||
return; |
|||
} |
|||
wsSend(req.app.locals["wss"], { |
|||
messageType: "EVENT", |
|||
data: { |
|||
x: points[ptIndex].x, |
|||
y: points[ptIndex].y, |
|||
}, |
|||
path: "/measurement-task/profile-record-ctrl-sig", |
|||
}); |
|||
ptIndex = ptIndex + 2; |
|||
}, 10); |
|||
|
|||
res.json({ status: 0 }); |
|||
}); |
|||
router.post("/stop-measurement", async (req, res) => { |
|||
ptIndex = 0; |
|||
clearInterval(intervalId); |
|||
|
|||
res.json({ status: 0 }); |
|||
}); |
|||
router.post("/analyze-measurement", async (req, res) => { |
|||
await delay(100); |
|||
// setTimeout(() => {
|
|||
// wsSend(req.app.locals["wss"], {
|
|||
// type: "cmd",
|
|||
// data: {
|
|||
// commandId: req.body.commandId,
|
|||
// status: "D0000",
|
|||
// },
|
|||
// });
|
|||
// }, 2000);
|
|||
res.json({ status: 0 }); |
|||
}); |
|||
|
|||
router.post("/save-report", async (req, res) => { |
|||
await delay(100); |
|||
// setTimeout(() => {
|
|||
// wsSend(req.app.locals["wss"], {
|
|||
// type: "cmd",
|
|||
// data: {
|
|||
// commandId: req.body.commandId,
|
|||
// status: "D0000",
|
|||
// },
|
|||
// });
|
|||
// }, 2000);
|
|||
res.json({ status: 0 }); |
|||
}); |
|||
export default router; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue