update websocket
This commit is contained in:
@@ -8,17 +8,17 @@ export default function Kiln() {
|
||||
const ctx = useContext(SocketContext);
|
||||
|
||||
const infos = [
|
||||
{ label: '窑炉压力', value: ctx.runState?.kilnPressure || '0Pa' },
|
||||
{ label: '循环水温度', value: ctx.runState?.waterTemp || '0℃' },
|
||||
{ label: '循环水流量', value: ctx.runState?.waterFlow || '0㎡/h' },
|
||||
{ label: '循环水压力', value: ctx.runState?.waterPressure || '0Pa' },
|
||||
{ label: '助燃风压力', value: ctx.runState?.combustionAirPressure || '0℃' },
|
||||
{ label: '碹顶加权温度', value: ctx.runState?.topTemp || '0℃' },
|
||||
{ label: '窑炉压力', value: ctx.kilnInfo?.kilnPressure || '0Pa' },
|
||||
{ label: '循环水温度', value: ctx.kilnInfo?.waterLoopTemperature || '0℃' },
|
||||
{ label: '循环水流量', value: ctx.kilnInfo?.waterLoopFlow || '0㎡/h' },
|
||||
{ label: '循环水压力', value: ctx.kilnInfo?.waterLoopPressure || '0Pa' },
|
||||
{ label: '助燃风压力', value: ctx.kilnInfo?.windPressure || '0℃' },
|
||||
{ label: '碹顶加权温度', value: ctx.kilnInfo?.topTemperature || '0℃' },
|
||||
{
|
||||
label: '压缩气压力',
|
||||
value: ctx.runState?.compressedAirPressure || '0Pa',
|
||||
value: ctx.kilnInfo?.gasPressure || '0Pa',
|
||||
},
|
||||
{ label: '融化加权温度', value: ctx.runState?.meltTemp || '0℃' },
|
||||
{ label: '融化加权温度', value: ctx.kilnInfo?.meltTemperature || '0℃' },
|
||||
];
|
||||
|
||||
return (
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useState, useEffect } from 'react';
|
||||
const SocketContext = React.createContext();
|
||||
|
||||
export const SocketContextProvider = (props) => {
|
||||
const [kilnInfo, setkilnInfo] = useState(null);
|
||||
const [runState, setRunState] = useState(null);
|
||||
const [hisState, setHisState] = useState(null);
|
||||
|
||||
@@ -19,8 +20,12 @@ export const SocketContextProvider = (props) => {
|
||||
if ('data' in e) {
|
||||
console.log('[ws] data ===> ', e.data);
|
||||
if (e.data == '连接成功') return;
|
||||
|
||||
let incommingData = JSON.parse(e.data);
|
||||
switch (incommingData.type) {
|
||||
case 'kiln-info':
|
||||
console.log('设置窑炉信息');
|
||||
setkilnInfo(incommingData.data);
|
||||
case 'RunData':
|
||||
console.log('run data arrived, set 运行时数据');
|
||||
setRunState(incommingData.data);
|
||||
@@ -35,7 +40,7 @@ export const SocketContextProvider = (props) => {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<SocketContext.Provider value={{ runState, hisState }}>
|
||||
<SocketContext.Provider value={{ kilnInfo, runState, hisState }}>
|
||||
{props.children}
|
||||
</SocketContext.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user