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