From 448082e74ff11be21d626ab5e77c1e3863c28e3c Mon Sep 17 00:00:00 2001 From: gtz <535262213@qq.com> Date: Mon, 11 Sep 2023 16:04:44 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=8D=A2=E7=81=AB20min=EF=BC=8C=E7=BC=A9?= =?UTF-8?q?=E6=94=BE=E6=A0=A1=E6=AD=A3=EF=BC=8C=E6=8D=A2=E7=81=AB=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E9=A2=84=E7=BD=AE'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CenterTopData/LeftBoxes/index.jsx | 8 ++++---- src/pages/index.jsx | 2 +- websocket/server.ts | 7 ++++++- websocket/template.json | 6 +++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/CenterTopData/LeftBoxes/index.jsx b/src/components/CenterTopData/LeftBoxes/index.jsx index 6416531..aff4208 100644 --- a/src/components/CenterTopData/LeftBoxes/index.jsx +++ b/src/components/CenterTopData/LeftBoxes/index.jsx @@ -9,10 +9,10 @@ import cls from './leftbox.module.less'; const Chart2 = () => { const ctx = useContext(SocketContext); - let [time, setTime] = useState([0, 0]); + let [time, setTime] = useState([19, 28]); useEffect(() => { - const restTime = ctx.runState?.lastFireChangeTime; + const restTime = ctx.runState?.lastFireChangeTime || '19分28秒'; if (restTime == null) return; console.log('restTime is:', restTime); let timer = null; @@ -77,7 +77,7 @@ const Chart2 = () => { { icon: icon1, label: '换火时间', - value: ctx.runState?.fireChangeTime || '00:00', + value: ctx.runState?.fireChangeTime || '19:56', }, { icon: icon3, @@ -87,7 +87,7 @@ const Chart2 = () => { { icon: icon2, label: '当前火向', - value: ctx.runState?.fireDirection || '东火', + value: ctx.runState?.fireDirection || '南火', }, ]; diff --git a/src/pages/index.jsx b/src/pages/index.jsx index a6ef0ef..659141e 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -11,7 +11,7 @@ import { SocketContextProvider } from '../store/socket-data-provider'; import MainContainer from '../components/yx-dark/MainContainer'; export default function index() { - const [value, setValue] = useState(50); + const [value, setValue] = useState(100); const v = (value / 100).toFixed(2); const styles = { diff --git a/websocket/server.ts b/websocket/server.ts index 3b26f81..f60341c 100644 --- a/websocket/server.ts +++ b/websocket/server.ts @@ -4,6 +4,7 @@ import utils from './utils'; const wss = new WebSocketServer({ port: 9800 }); const frequency = 10; // seconds +const frequency1 = 1200; // seconds wss.on('connection', function (ws, req) { // console.log("ws", ws); console.log( @@ -26,7 +27,6 @@ wss.on('connection', function (ws, req) { const timer = setInterval(() => { sendMsg(ws, 'kiln-info'); // 窑炉信息 - sendMsg(ws, 'run-state'); // 运行状态 sendMsg(ws, 'energy-cost'); // 运行状态 sendMsg(ws, 'realtime'); sendMsg(ws, 'his-trend'); @@ -35,9 +35,14 @@ wss.on('connection', function (ws, req) { // sendMsg(ws, 'kiln-bottom'); }, frequency * 1000); + const timer1 = setInterval(() => { + sendMsg(ws, 'run-state'); // 运行状态 + }, frequency1 * 1000); + ws.on('close', function () { console.log('停止监听'); clearInterval(timer); + clearInterval(timer1); }); }); diff --git a/websocket/template.json b/websocket/template.json index 74df9b8..9d4496d 100644 --- a/websocket/template.json +++ b/websocket/template.json @@ -17,9 +17,9 @@ "gasii": "...m³" }, "runState": { - "lastFireChangeTime": "3分28秒", - "fireChangeTime": "20:00", - "fireDirection": "东火" + "lastFireChangeTime": "19分28秒", + "fireChangeTime": "19:56", + "fireDirection": "南火" }, "fan": [ ["8#压延冷却风机", "4373Hz", "正常"],