rename
This commit is contained in:
parent
39a75ef213
commit
b9f191459f
@ -1,5 +1,5 @@
|
|||||||
import { WebSocket, WebSocketServer } from 'ws';
|
import { WebSocket, WebSocketServer } from 'ws';
|
||||||
import demoData from './demo.json';
|
import template from './template.json';
|
||||||
import utils from './utils';
|
import utils from './utils';
|
||||||
|
|
||||||
const wss = new WebSocketServer({ port: 9800 });
|
const wss = new WebSocketServer({ port: 9800 });
|
||||||
@ -64,27 +64,27 @@ function sendMsg(ws: WebSocket, type: MsgType) {
|
|||||||
let data: ResponseData | ResponseDataComplex = {};
|
let data: ResponseData | ResponseDataComplex = {};
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'kiln-info':
|
case 'kiln-info':
|
||||||
for (const key in demoData.kilnInfo) {
|
for (const key in template.kilnInfo) {
|
||||||
data[key] = utils.getRandom(
|
data[key] = utils.getRandom(
|
||||||
demoData.kilnInfo[key as keyof typeof demoData.kilnInfo],
|
template.kilnInfo[key as keyof typeof template.kilnInfo],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'energy-cost':
|
case 'energy-cost':
|
||||||
for (const key in demoData.energyCost) {
|
for (const key in template.energyCost) {
|
||||||
data[key] = utils.getRandom(
|
data[key] = utils.getRandom(
|
||||||
demoData.energyCost[key as keyof typeof demoData.energyCost],
|
template.energyCost[key as keyof typeof template.energyCost],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'run-state':
|
case 'run-state':
|
||||||
data = demoData.runState;
|
data = template.runState;
|
||||||
break;
|
break;
|
||||||
case 'realtime':
|
case 'realtime':
|
||||||
/** 天然气 实时流量 */
|
/** 天然气 实时流量 */
|
||||||
data.gasii = demoData.realtime.gasii.map((v) => utils.getRandom(v));
|
data.gasii = template.realtime.gasii.map((v) => utils.getRandom(v));
|
||||||
/** 助燃风 实时流量 */
|
/** 助燃风 实时流量 */
|
||||||
data.wind = demoData.realtime.wind.map((v) => utils.getRandom(v));
|
data.wind = template.realtime.wind.map((v) => utils.getRandom(v));
|
||||||
break;
|
break;
|
||||||
case 'his-trend':
|
case 'his-trend':
|
||||||
const hisTrend: {
|
const hisTrend: {
|
||||||
@ -94,26 +94,26 @@ function sendMsg(ws: WebSocket, type: MsgType) {
|
|||||||
gas: {},
|
gas: {},
|
||||||
wind: {},
|
wind: {},
|
||||||
};
|
};
|
||||||
Object.keys(demoData.hisTrend.gas).forEach((key) => {
|
Object.keys(template.hisTrend.gas).forEach((key) => {
|
||||||
hisTrend.gas[key] = demoData.hisTrend.gas[
|
hisTrend.gas[key] = template.hisTrend.gas[
|
||||||
key as keyof typeof demoData.hisTrend.gas
|
key as keyof typeof template.hisTrend.gas
|
||||||
].map((v) => utils.getRandom(v));
|
].map((v) => utils.getRandom(v));
|
||||||
});
|
});
|
||||||
Object.keys(demoData.hisTrend.wind).forEach((key) => {
|
Object.keys(template.hisTrend.wind).forEach((key) => {
|
||||||
hisTrend.wind[key] = demoData.hisTrend.wind[
|
hisTrend.wind[key] = template.hisTrend.wind[
|
||||||
key as keyof typeof demoData.hisTrend.wind
|
key as keyof typeof template.hisTrend.wind
|
||||||
].map((v) => utils.getRandom(v));
|
].map((v) => utils.getRandom(v));
|
||||||
});
|
});
|
||||||
data = hisTrend;
|
data = hisTrend;
|
||||||
break;
|
break;
|
||||||
case 'gas':
|
case 'gas':
|
||||||
// data = demoData.gas;
|
// data = template.gas;
|
||||||
break;
|
break;
|
||||||
case 'kiln-top':
|
case 'kiln-top':
|
||||||
// data = demoData.kilnTop;
|
// data = template.kilnTop;
|
||||||
break;
|
break;
|
||||||
case 'kiln-bottom':
|
case 'kiln-bottom':
|
||||||
// data = demoData.kilnBottom;
|
// data = template.kilnBottom;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// data = 'You are connected!';
|
// data = 'You are connected!';
|
||||||
|
Loading…
Reference in New Issue
Block a user